TicTacToe

This is a discussion on TicTacToe within the C++ Programming forums, part of the General Programming Boards category; Well guys I get to write a tic tac toe program for my class. This sux. In this program the ...

  1. #1
    neoground73
    Guest

    TicTacToe

    Well guys I get to write a tic tac toe program for my class. This sux. In this program the computer must beable to move by itself playing against the player. Now the catch is the computer has to be smart enough to at least tie with the user. Any ideas on how to do this?

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    yes! a minimax algorithm, if ever you get to make this algorithm inside your game, hope you could share it to me!!

    search google for minimax,

  3. #3
    neoground73
    Guest
    Umm I can't seem to find any minimax algorithm that will compile under visual c++ 6.9

    Any one know about this algorithm?

  4. #4
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    What? You don't need to use something like a minimax algorithm for Tic-Tac-Toe!

    Think about Tic-Tac-Toe for a second. What's the only 'strategy' the computer can make? It prevents you from getting 3 in a row.

    So... using a matrix, parse the matrix after the player moves and check for any potential wins (2 adjacent X/Os)... then have the computer move to the 3rd position...

    There's a little more to it, but it's not complicated.

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    first write the game without using any computer moves. Then try to add rules for the computer to follow. Things like: if you move first, always select the central box. If you move second, never select the central box. Always look block a possible winning move. etc.

  6. #6
    neoground73
    Guest
    Yeah guys im already working on the rules for the comp and i have finished the user part. I was juz asking what minimax was. I never expected to use it. So what is it?

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    well okey you don't really need a minimax algo but heck it'll absoluely make your program better and prof. looking rathar than having long list of if else statements and besides this is a tremenedous practice,

    http://www.generation5.org/minimax.shtml

    try that but there's another one really good tutorial with a sample source code, can't find it right now at google,

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    254
    Originally posted by BMJ
    What? You don't need to use something like a minimax algorithm for Tic-Tac-Toe!

    Think about Tic-Tac-Toe for a second. What's the only 'strategy' the computer can make? It prevents you from getting 3 in a row.

    So... using a matrix, parse the matrix after the player moves and check for any potential wins (2 adjacent X/Os)... then have the computer move to the 3rd position...

    There's a little more to it, but it's not complicated.
    yes but then you can still trap the computer

    you would also want to add moving to one of the corners if the user takes the middle and if the user takes a corner then take the middle... there will still be a couple traps letf but that should minimize it...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TicTacToe AI
    By Loic in forum C++ Programming
    Replies: 9
    Last Post: 05-28-2007, 01:37 PM
  2. C++ Tictactoe
    By vinter in forum C++ Programming
    Replies: 6
    Last Post: 04-03-2007, 09:56 PM
  3. tictactoe symbol entering problem
    By ademkiv in forum C Programming
    Replies: 1
    Last Post: 03-21-2006, 10:53 AM
  4. Tictactoe problem
    By endo in forum Windows Programming
    Replies: 3
    Last Post: 04-10-2005, 09:36 AM
  5. TicTacToe OOP
    By NickESP in forum C++ Programming
    Replies: 4
    Last Post: 02-07-2003, 10:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21