Solving engine for TicTacToe
<p>I'm 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 all finished.</p>

<p>The computer generates a random place where the Os go on the table and that's not good.</p>

<p>I thought that i should multiple procedures that check every winning position and the computer should else try to block the player's Xs or to make a winning position, BUT this would have been lots of time lost cause all of the if's.</p>

<p>Then I thought of a simpler version with some kind of ifs but it would still have been taking lots of time to do.</p>

<p>Then i thought deeper: What about a find-four game? How in the earth someone would manage to check every space available and how it would've been possible that someone could make a function that checks absolutely any winning or progress of player/computer position, Oh and wait, that's not ALL, what if the player is doing some tricks so he blocks the computer? How would the computer know that?!? For sure, that would take ages to program. And I am not talking about something that seems more impossible: Chess.</p>

<p>So here I am, asking myself that there SHOULD be a way more simpler way the computer should search and solve some problems than tons of ifs. </p>

<p>In this case, if any of you know any way of solving this, how can i manage to make the simplest procedure to block and beat the player in a TicTacToe game?</p>

<p>If someone wants to check my code or use it: <a href="http://pastebin.com/jhyUn7d1" rel="nofollow">http://pastebin.com/jhyUn7d1</a></p>
