AI in a dynamic Tic-Tac-Toe Game

Started by
14 comments, last by Qudeid 16 years, 1 month ago
Quote:Original post by Sneftel
Quote:Original post by Qudeid
Actually, it seems like I'm totally blocked in my head now, because I can't solve the problem of determining who wins... Theoretically is it easy, 3 of X or O in a row column or diagonally. As with AI in the old version this was easy because I knew every single way of how one can win, this time it isn't the case, obviously.

Determining wins in tic-tac-toe isn't difficult, just annoying. Count consecutive Xes in each row; count consecutive Xes in each column; count consecutive Xes in each diagonal. Do the same for Os.


Actually, just checking the row, column & diagonals of the last move will be fine...
Advertisement
Quote:Original post by Atridas
Actually, just checking the row, column & diagonals of the last move will be fine...
Isn't that great? It's one of the best examples of "solve the right problem" that everyone falls prey to once in a while. That should be in a freakin' text book or something. Or a hiring exam. It's so obvious that a lot of people shoot from the hip and miss.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Hi there,

back again.
The "victory check" is up and running.

I've now done some to the AI, but the problem I am experiencing is... well the AI just puts its marker on 0/0... that's it.. each and everytime, even overriding my own choice :-/

And using the debugger is quite a bit... difficult to do, especially to follow this many steps down etc.


Oh oh oh.. stop.. Update!
It now doesn't override anymore and it doesn't set its marker only on 0/0. But unfortunately it just goes like this

0/0, 1/0, 2/0... etc.
If that way is "blocked" it will just jump to the next free position

Another Update...
I've gotten so far that it tries to win, only problem is... it wants to win, no matter what.

[Edited by - Qudeid on February 19, 2008 5:17:58 PM]
When debugging recursion like this, work backwards from the endgame. Start with a board with only one space available, just as a sanity check. Then try a board with two spaces available: one should be a win, the other should be a draw. See if it chooses the win space. Then try a board with two spaces available: one should lead to a draw, the other should lead to a loss. Starting from an empty board is not going to be a useful way to debug.
d'oh...
sounds more than sane (while you were talking about sanity).
big thanks to you, Sneftel!
I think I've got it now. It doesn't place its marker in the middle, if it is available (for example in the beginning when the computer begins.) but beside that, it is quite cool.

About performance, the first move takes quite some time to calculate. Not super much time, but still noticable, very noticable. I will either try Alpha Beta, or I just implement a depth. But that's another story.

Thanky ou very much for your help!

This topic is closed to new replies.

Advertisement