1001Ferramentas
Games

Tic-Tac-Toe vs CPU

Jogo da velha contra a CPU (jogada aleatória).

Sua vez (X)

Beating an opponent that plays at random

Tic-tac-toe between two attentive adults always ends in a draw, which is exactly why it gets old fast. Here the opponent is the machine, but a machine that does not think: it picks a free square at random every turn. The result is a two-minute game you can genuinely win, as long as you set up the right move before luck gets in the way.

The CPU never evaluates the board. It lists the empty squares and picks one with equal probability, so it never blocks your line on purpose and never chases its own three in a row. If it wins, that was chance. Your win is checked right after your move, before the machine replies, so completing a line ends the game immediately.

The strategy that almost always works is building two threats at once, a fork: open with the centre or a corner and create two lines, because a random pick rarely covers both. You always play X and always move first. There are no difficulty levels, no running score and no two-player mode. Restart clears the board, and nothing is stored or sent anywhere.

Frequently asked questions

Can I win every time?
Almost every time, but not always. Since the machine picks at random, now and then it blocks your line by accident and the game ends in a draw.
Is there a hard mode?
No. Every reply is a random choice among the empty squares, with no position evaluation at all.
Can I play as O or against another person?
No. You play X and always move first; the other side is always the machine.

Related Tools