Jump to content


Tic Tac Toe - AI Help


9 replies to this topic

#1 Cuculetzu

    New Member

  • Members
  • Pip
  • 2 posts

Posted 28 January 2007 - 11:40 PM

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.

#2 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 29 January 2007 - 12:09 AM

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....iki/Tic-tac-toe

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

#3 Cuculetzu

    New Member

  • Members
  • Pip
  • 2 posts

Posted 29 January 2007 - 11:38 PM

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?

#4 CppMan

    New Member

  • Members
  • Pip
  • 3 posts

Posted 14 May 2007 - 05:12 PM

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

#5 zakaluka

    New Member

  • Members
  • Pip
  • 8 posts

Posted 15 May 2007 - 02:56 AM

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....Minimax_theorem.

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

Regards,

zakaluka.

#6 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2718 posts

Posted 18 May 2007 - 02:12 PM

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.

#7 pater

    Valued Member

  • Members
  • PipPipPip
  • 117 posts

Posted 18 May 2007 - 02:31 PM

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.

#8 utdiscant

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 21 December 2007 - 04:55 AM

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.

#9 Reedbeta

    DevMaster Staff

  • Administrators
  • 5305 posts
  • LocationBellevue, WA

Posted 21 December 2007 - 06:22 AM

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?
reedbeta.com - developer blog, OpenGL demos, and other projects

#10 utdiscant

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 22 December 2007 - 03:37 AM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users