I am a junior programmer and I know the basics of pascal and C ++. I made a Tic Tac Toe game with Player-Computer, and the game is over.
The computer generates a random place where Os goes on the table, and this is bad.
I thought I needed several procedures that check each winning position, and the computer should also try to block the Xs player or make a winning position, BUT this would be a lot of time lost due to all if.
Then I thought of a simpler version with some types of ifs, but it would still take a lot of time.
Then I thought deeper: how about game 4? How on earth someone will be able to check every available space and how it would be possible for someone to perform a function that absolutely checks any gain or progress in the position of the player / computer, Oh and wait, which is NOT ALL, what if the player does some tricks, why does it lock the computer? How would a computer know this?!? Of course, this will take time to program. And I'm not talking about something that seems more impossible: Chess.
So here I am, asking myself what SHOULD be a simpler way for a computer to search and solve some problems than tons of ifs.
In this case, if any of you know any way to resolve this issue, how can I manage to make the simplest procedure for blocking and beating a player in the game TicTacToe?
If someone wants to check my code or use it: http://pastebin.com/jhyUn7d1
source share