Tic Tac Toe

I am a newbie to game development and this is my first try so bear with me.
Here is a recursive algorithm to emulate single player vs. computer tic tac toe or any possible game for this matter.
The algorithm is as follows:
*For the time being assume that this algorithm gives us the best move possible.
1. Make any arbitrary move.
2. Use this function(recursive call) to make a move for the Player.
3. Using this function(recursive call), make a move for the Computer.
4. Repeat steps 2 and 3 until one of the players win
5. If Computer wins, the arbitrary move made was correct---> Function ends here.
6. Otherwise, make another arbitrary move and proceed with step 2.

Logically this seems alright to me. But is it possible to realize this in code? I'm trying but I am not too sure because if this were correct, we could easily simulate all single player games where decision making is involved quite easily. If this has flaws, please point them out. Any help shall be appreciated!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!