c++ - Checking a char array for words by cycling through it with a string of chars -


i'm working on game right that's connect 4, letters instead of colored checkers. player "drops" letter tile grid, , can claim word if letter 1 played. word checked see if in grid (which array of structs contain letter value (char) , boolean value determine whether tile "empty". have coded human player's turn, i.e. 1 takes user input. computer turn, turning out problematic.

the computer player should @ letter tiles has remaining (each 'player' has string containing every letter in alphabet set of vowels; every time player plays tile, respective tile erased string), , choose drop column give largest amount of points; length of word correlates amount of points.

right now, human code goes little this; input letter -> input desired row -> game checks see if lowest row of column open -> tile placed in lowest available row of column -> player asked if claim word -> player inputs word -> game checks every row, column, , diagonal line check word in grid -> game checks word contains letter used -> game checks dictionary (a text file) see if word valid word (that in dictionary) -> human player awarded points correlating length of word.

so, computer player's turn, figured should start looking words 7 letters long. however, have no idea how this. have large multitude of strings can use check words against; string "hstr1" first row of grid, "vstr1" first column of grid, , "dstr1" first diagonal line of letters, top left bottom right.

what i'm trying do, able make program @ grid, , think "are there incomplete words completed letter have remaining in letter choice string?" of course start looking words 7 letters long (or six? since word should 1 letter short of 'complete'), , if cannot find 7 letter words, go down six, , five, until there no 3 letter words claimable.

i've made load of progress in coding game, 1 thing has stumped me completely. if me come pseudocode this, greatly, appreciate it. don't have anywhere else turn help, , game due in 5 days.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -