Click the squares to play. Human is blue, AI is red. Play against the computer and represent humanity! No pressure...
The computer chooses based on the highest valued space. If a space has been marked, it has no value. Otherwise, they all start with 1 point + how many victories they are involved in. But the value of a space jumps to the max if there is about to be a three-in-a-row. The value of the upper left spot is 4 because the ai can win by filling the top row, the left column or by filling in the diagonal from upper left to lower right. So there are 3 victories it's a part of. So its value is 4 (1+3). But if the player fills in the upper right spot, the value of the upper left spot changes to 3 because it can't help the ai get victory through the upper row anymore. One of the victories is gone. The ai scans through the list in the same way each time, so if there are spots tied for the highest value, it will take the first one it comes to every time.