PDA

Click to See Complete Forum and Search --> : Tic Tac Toe Questions


ravcam
Jan 7th, 2000, 03:26 AM
Yes. I recently made a program like this. What I did was make the user enter a selection as to who would go first. If the computer went first it would always move to the center square. If it was second it would first move to the center square and if not possible move to one of the corners. If the computer had made the first move and the player had made his first move it would search for a corner to move to. The only other time it would be nessacary to program a move other than the logic moves mentioned in the second message is if the computer has the center square and the player ocuppies 2 squares directly adjacent on the same plain. By this move the program should be able to check for a block and be able to almost randomly select a move in a dead end game to keep the player on their toes. By the way, using this statagy will allow the computer to make 85% of games tie and win 5% and lose 10%.(or at least that is what I have calculated) Try it! Also the source code is not currently availabe for me to show you, unfortuatly the game got wiped out when I formated! O well, shows you why you should make back up copies!

Drinky
Jan 7th, 2000, 10:39 AM
Play yourself or a friend a number of times.

Think about each move of each game and write down why you put your O or X in each square.

E.G: Player one places an X in the top left corner. So I place my O in the bottom right which prevents a win win situation for X in two moves.

After a number of games you'll have a series of AI routines written in English (if your 1st language is english, not if it's not but you get the idea).

(hard bit) Code it so that the computer makes the decisions you did.

------------------
Third year Software Engineering Student.

On placement at the University of Manchester
playing with expensive cool things...:)
http://drinky.u4l.com
wizard_03@hotmail.com

ravcam
Jan 8th, 2000, 11:44 AM
I agree! The same procedure metioned above gave me a very complex If Then procedure if I ploted evry game. You would definatly condense the code into something useable. After the first 4 moves(9 moves to a game) the logical procedures from #1 will last the game.