My Tic-Tac-Toe program
Posted: Wed May 12, 2010 8:10 pm
Hi, I've been working on a Tic-Tac-Toe program, and have it pretty much done, I have AI implemented, so far it looks something like this
It's pretty simple ai but it works, well it at least plays the game by itself, I think I may have to do some tinkering to the algorithm to make it a better player though.
other than the AI it is pretty much as you would think a Tic-Tac-Toe program would work.
Code: Select all
-first I check to see if there is a piece on the center square, if there is not one there then it places one on there. (right now the AI plays second and that is probably the best strategy)
-if there is a piece on the center square, it then puts one on a corner square, (which I think is the best alternative)
-after the first move it then goes into thinking for itself
-it checks to see if enemy pieces are on the horizontal lines, if there is an enemy piece it adds 1 to each square (not including the square a piece is on).
-it does this check for the vertical, and diagonal lines too.
-it then repeats that process for the ally pieces.
-I then have it find out which square has the highest value and it places a piece on that square.
other than the AI it is pretty much as you would think a Tic-Tac-Toe program would work.