AI query

Blitz3D Forums/Blitz3D Programming/AI query

The first step is defie a dictionary for your AI to choose words from.

depending on your game, it may be bet to split the dictionary up into words of a particular length - i.e. a separate file for 3 letter words, a seperate file for 4 letter words etc.

Search for LONGEST words first, then down to SHORTEST - this may take longer to 'think', but allows you to implement AI difficulty levels and ensures the AI chooses the best score possible!

Here's a PSEUDOCODE example of how I would approach the scrabble AI:


Search the grid
If a letter is encountered Store that letter in A$
Check the surrounding grid-squares for blank space
If Blank space, count along in that row until next letter apparent.
Add that letter to B$ and it's distance as dist% spaces from the A$ letter.
Check dictionary for words INSTRING$("A$....B$")
If none found, search for words beginning with A$ of less than space% length. If found apply temporary score to longest available.

If there IS an INSTRING$("A$....B$") word, extend the check for A$...B$...C$ etc etc.
apply a temporary score when found
Continue searching grid.


It's gonna be complex and the above will need a lot more detail obviously with dealing with things like Letter Values.



Hope this helps, it's easier to think about than it is to try and explain heh ;)