Im developing an application which represents the popular game of TicTacToe, its configured for 2 players, my project is to let user play vs computer. I need guide lines on how to module such behavior.
the game: In a game of Tic Tac Toe, two players take turns marking an available cell in a 3x3 grid with their respective tokens(either X or O). When one player has placed 3 tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the spaces on the grid have been filled with tokens and neither player has achieved a win.
So you need to come up with how the computer will react to any given board setup. That's not too hard with TicTacToe, as there are only a limited number of situations that can be encountered. Before considering a move you'd probably want to check if the opponent has two in row with the third one open (in which case you'd put the piece on the open field). The corners are important, so it's good to put pieces there if possible (and if the opponents move was to put the first piece in a corner, then the computer needs to put its first piece in the opposing corner). Try to write down all the "rules" you as a human use during a match, and then see if you can translate those to code. [ January 13, 2007: Message edited by: Ulf Dittmer ]
What's that smell? I think this tiny ad may have stepped in something.