Tic Tac Toe - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Tic Tac Toe

iRitchieiRitchie Posts: 2Member
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.