AI query

Blitz3D Forums/Blitz3D Programming/AI query

Nicstt(Posted 2006) [#1]
I have been writing a word game for some time now, a passing resemblance to scrabble, but with enough differences (i hope) to not cause problems.

I am now at the stage to start writing the computer opponent AI and I am looking for thoughts from others.:)

I have the words set in various lengths 2 to 15 atm. To arrange difficulty levels I am considering setting a max number of words each level can have.

Would that work you think?

For the AI aspect I am trying to break down my actions into basic steps and look at programming each aspect.

eg:

look at letters I have and try to make words

also look at making words that I am missing say 1, 2 or 3 letters from.

look for places that words can fit

and calculate the best place for word.

Some basic ideas I have.


_PJ_(Posted 2006) [#2]
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 ;)


WolRon(Posted 2006) [#3]
and ensures the AI chooses the best score possible!
I wouldn't use the word ensures, more like strengthens the odds.

The longest word (in Scrabble at least) isn't necessarily the highest scorer.


Nicstt(Posted 2006) [#4]
thanks for your comments, appreciate them