Ttt

This is a discussion on Ttt within the Game Programming forums, part of the General Programming Boards category; As my first game ive decided to attempt TTT, im fairly sure i can do the board, input, etc. The ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    21

    Ttt

    As my first game ive decided to attempt TTT, im fairly sure i can do the board, input, etc. The parts that baffle me are the AI and Checking for a win.

    I pondered to check for a win via a 'if a O is found look for an adjacent one' but a:

    O| |
    ------
    O|O|

    Arrangement would confuse it, bearing in mind ill be using an array for the board, can someone point me in the right direction with the AI and Checking for a win ?

    Any help appreciated

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    The easiest way to check for a win is to just hard code all the possible ways to win. It's infallible. Have the array hold whether the space is occupied and by whom. On my tic-tac-toe game I made two bool arrays in two dimentions, like this:

    Code:
    bool SPACE[9][2]
    The 9 is for the number of pieces and the two is for the things above. Checking it is simple then. This is just how I made my game, there are many ways that will work just as good/better.
    As for AI, I hardcoded a functions to check if the computer or the user could win on that turn. If so, win or block the user. Also, I made the computer take the center if it was open because that presents the most options for winning, but some people think it's not always the best idea. Then I made some pretty rough coded functions to see what space would be the best to take. They weren't very great, so I won't post them. That part of making the AI has to be the hardest, because it involves some higher level "thinking", vs. just blocking spaces. I hope this helps you. Good luck!

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    21
    cheers, ill give it a try.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. language translator (having problems in tokenizing)
    By jumbo2410 in forum C Programming
    Replies: 2
    Last Post: 03-23-2009, 06:29 AM
  2. comparing structures
    By sleepywalker in forum C Programming
    Replies: 15
    Last Post: 02-16-2009, 02:15 PM
  3. polymorphism
    By slaveofthenet in forum C++ Programming
    Replies: 15
    Last Post: 07-10-2003, 12:50 PM
  4. TTT Problem
    By librab103 in forum C Programming
    Replies: 8
    Last Post: 07-03-2003, 10:28 PM
  5. Where to start
    By Unregistered in forum Game Programming
    Replies: 36
    Last Post: 05-07-2002, 12:05 AM

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