Original Post
Hey!
I developed a tic tac toe in visual c++, Allegro. It's only player1 vs player2 at the moment.Now I want to make a singleplayer option. How would I make the AI block me from getting 3 in a row? would it be done by checking if there is a mark at place a and C then put the marker in B?
lets say this is the board:
[1]|[2]|[3]
-----------
[4]|[5]|[6]
-----------
[7]|[8]|[9]
would I make it check if there is a marker at lets say 1 and 3, and if there are it would check if 2 is marked,(game would be over if I had a cross there but if he had put one there it wouldn't)if it isnt it would place a O there. but then, how could I make it so if he had for example 1 and 3 and i had 4 and 6, then how could i do so he does not block instead of win there?
please give me a hint. note that I'm not really asking for code, only how it would be done :)
I developed a tic tac toe in visual c++, Allegro. It's only player1 vs player2 at the moment.Now I want to make a singleplayer option. How would I make the AI block me from getting 3 in a row? would it be done by checking if there is a mark at place a and C then put the marker in B?
lets say this is the board:
[1]|[2]|[3]
-----------
[4]|[5]|[6]
-----------
[7]|[8]|[9]
would I make it check if there is a marker at lets say 1 and 3, and if there are it would check if 2 is marked,(game would be over if I had a cross there but if he had put one there it wouldn't)if it isnt it would place a O there. but then, how could I make it so if he had for example 1 and 3 and i had 4 and 6, then how could i do so he does not block instead of win there?
please give me a hint. note that I'm not really asking for code, only how it would be done :)