Tic Tac Toe - AI Help

De76e03aa6b5b0bf675c1e8a990da52f
0
Cuculetzu 101 Jan 28, 2007 at 23:40

Hi,
I made a simple console game Tic Tac Toe using C++. I made it to be played by two humans using the keyboard. I want to make this game to be played by one human against computer’s artificial intelligence. I need some help, some ideas. I will post my game tomorrow.
Please, give me some ideas.
Sorry for my english.

9 Replies

Please log in or register to post a reply.

A9102969e779768e6f0b8cb87e864c94
0
dave_ 101 Jan 29, 2007 at 00:09

This is probably the most trivial problem in AI. Its easy to work out the correct move if you just implement the rules http://en.wikipedia.org/wiki/Tic-tac-toe

To give the AI a difficulty use a random move and the smarter the AI, the less it makes random moves

De76e03aa6b5b0bf675c1e8a990da52f
0
Cuculetzu 101 Jan 29, 2007 at 23:38

Thank you for the link. I will read all that informations about tic tac toe strategy. Implementing rules for AI is pretty hard for me now, but i will learn how to do that.
I want to post my game, but how?
Should I upload it on a server?

A2c56b2956f1b8f0f81ad0f331f843a6
0
CppMan 101 May 14, 2007 at 17:12

When making a tic-tac-like game, the AI should work like this:

  1. Check if there is a tile that you can win in 1 move
    if there is no such tile:
  2. Check if there is a tile that your opponent can win in 1 move
    if there is no such tile:
  3. Check if there is a tile that can make two tiles apply to the rule #1
    if there is no such tile:
  4. Check if there is a tile that your opponent can make two tiles apply to the rule #2
    if there is no such tile:
  5. implement your own AI form this point

You can see similiar scheme in javascript on my gomoku site http://gomoku.atspace.com

Peace

4784967f380c98050f6be2285ab5791a
0
zakaluka 101 May 15, 2007 at 02:56

If you want to learn more about this kind of reasoning in-depth, take a look at the Minimax decision-making strategy at http://en.wikipedia.org/wiki/Minimax_theorem.

Alpha-beta pruning (http://en.wikipedia.org/wiki/Alpha-beta_pruning) is the way to really speed up the Minimax algorithm.

Regards,

zakaluka.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 May 18, 2007 at 14:12

the whole game is so simple you could record every single counter
move for every square manually in a lookuptable.

u can do chess like this, but without as much success because there
is too many permutations.

6d318bb67270aa12b325e2cd7b64ff7a
0
pater 101 May 18, 2007 at 14:31

Just a small tip: It’s also fun to have a tic-tac-toe game, where the player will have to try to loose instead of win. I remember having a big time in an adventure game (don’t remember it’s name right now…) where a quest involved letting the opponent win in a tic-tac-toe game. Unfortunatelly, that opponent was doing everything so blatamly wrong that it was actually quite tricky to do.

F640abf404f67c7e9a51a24d44dde700
0
utdiscant 101 Dec 21, 2007 at 04:55

i’ve implemented a tic tac toe game with a trainable neural network to play against and train. It took a while, but eventually it learned how to play as good as a human being, and even better.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 21, 2007 at 06:22

I’m not really sure why anyone would implement a tic-tac-toe game with NNs. The game can easily be solved exactly using minimax search with alpha-beta pruning on modern machines. The strategy for this game is so simple that even humans can easily work out the optimal strategy with a little thought. Surely if one is trying to learn how to use NNs for game AI, there are better examples of applications?

F640abf404f67c7e9a51a24d44dde700
0
utdiscant 101 Dec 22, 2007 at 03:37

I knot NN’s are the way to go in Tic Tac Toe, but i was learning about the theory behind NN and Tic Tac Toe was fairly easy and fast to implement, and ever better, the network was easy and fast to train, so it didn’t take long to see if my code actually worked as it should.