Advertisement

A tic-tac-toe superbot

Started by January 07, 2005 05:07 AM
25 comments, last by Solias 20 years, 1 month ago
Quote:
Original post by iMalc
You're making this way too hard for yourself. Your code shouldn't have to know anything about particular cases of where to go. For TTT use a simple minimax algorithm and pretty much all you have to do is tell it what a win and a loss look like. Then it will always pick the best move, guaranteed.
No more "Oops I missed the case where..."


Thank you far the link, I will certainly try to implement it. However, I'd like to try other styles, too. Any suggestions on the 'teching'?
Quote:
Original post by Sijmen
or should I let him learn some tactics, by deliberately losing (as player) when the bot makes a good move?


Yes, its called training the bot.
-----------------Always look on the bright side of Life!
Advertisement
Quote:
Original post by A Guy from CRO
Quote:
Original post by Sijmen
or should I let him learn some tactics, by deliberately losing (as player) when the bot makes a good move?


Yes, its called training the bot.


I came that far, but I was just wondering if I just just keep playing, or train the bot with a goal - that his, learn it a certain tactic. Probably I'll go for training it then.
There isn't much training to do with Tic Tac Toe, cause u've only got 5983 possible gamestates(Thats including endstates and the blank board).
-----------------Always look on the bright side of Life!
You should use minimax (w/ alphabeta, to make this very, very fast). You should also use a hash table, with a hash that recognises congruent positions (ie. Flips, ect.).

You then record which is the best move to take, using the hash table (as your updating it). You could use two different hashes, Computed two completely different ways, before stringing them together, to make it harder to get a collission.

You then just look up via the hash-table, the best possible move for it.

Thats assuming 3*3 ttt, 4*4 would need a different approach.

From,
Nice coder


Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Quote:
Original post by A Guy from CRO
There isn't much training to do with Tic Tac Toe, cause u've only got 5983 possible gamestates(Thats including endstates and the blank board).


That number I wrote was under the assumption that the bord is fixed. If you can rotate the board then the number of gamestates goes down drasticly.
-----------------Always look on the bright side of Life!
Advertisement
@Sijmen: If you are real keen on the training concept, have a look at Artifical Neural Networks, although it may be overkill for TTT, the results may be quite interesting and could be applied to other applications.

Unfortunately, I haven't done any work with ANN since Uni, and that didn't include too much programming, so I couldn't help you with that.
When you showed how you played against the computer player, I didn't see much of a problem. The way the Xs moved is impossible to beat in actual tic-tac-toe, only to draw. So basically, it was a slight error if any.

I've beaten human players in tic-tac-toe with that tactic(:
-----------------------------Play Stompy's Revenge! Now!
This is probobly not the solution you wanted, as it looks like you are doing some serious experimenting with AI, and related techniques.

However, Tic-Tac-Toe, being a simple game has a simple solution.
I am certain there is a brute force strategy that the computer could use to every game win or stalement the player.

(Also, a basic strategy is go for middle first, and in your sample game I didnt see this happening, which is odd since it is a crucial spot)

Look into it some more!

I would write more, but the longer the post I write the more likely it is to be blatently ignored :P
- Jacob
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
Kevlar-X, its called minimax. And it solves the entire game in a few seconds.
Implement AlphaBeta and it will be solved in <1 sec.

Get some good move ordering, (like even using the evaluation function, to sort moves), and it'll be very very fast.

Its not too hard, you know....

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.

This topic is closed to new replies.

Advertisement