Game programming

Moderators: None (Apply to moderate this forum)
Number of threads: 2070
Number of posts: 5361

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Tic Tac Toe Posted by iRitchie on 12 May 2011 at 6:44 AM
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!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.