View Single Post
  #2 (permalink)  
Old 06-04-2007, 04:41 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

I made a great tutorial on on tic-tac-toe [but in Java] the idea is pretty much the same.

I haven't looked at your code yet, but I will as I am very interested. However, it will take me a while to understand your code, and in the meantime you could make some headway. So...

To figure out who's turn it is, I have a variable increment each time a move is made. The variable [say i] starts off at 0 and if

if ( i % 2 = 0 )
// X goes
else
// O goes

to check if it is a tie, just check if i == 9, if it is 9 than there are no more moves that can be made -- the game is a tie and the game is over. Display a message and your done.

As for the AI, you just need a whole bunch of else if's [you can look at my code in the Java tutorial section for how I implemented it AI, I'm sure you can understand what is going on -- the syntax is very similar]
Reply With Quote