Minimax is the textbook idea behind computer opponents in two-player games like chess. The computer imagines the moves it could make, then the replies its opponent could make, then its own answers, and so on, building a tree of possible futures. It assumes it will pick the move that's best for itself (maximising) and that its opponent will pick the reply that's worst for it (minimising). Working back up the tree, it chooses the move with the best guaranteed outcome.
Real game programs add tricks to search faster, like skipping branches that can't matter, but the core idea is the same.
How depth makes difficulty
The further ahead a program looks, the stronger it plays. That's roughly how Jessie Games' computer levels differ:
- Easy plays loosely, sometimes mostly at random, and can miss a block.
- Medium looks a few moves ahead, and in games like Four in a Row never misses an immediate win or block.
- Hard searches much deeper. In Reversi it plays the endgame perfectly, counting out the exact final score.
Jessie Games' computer opponents run on your own device, with a limit on how much they search per move so they reply quickly, which is also why they work offline.
Example
In Four in a Row, the computer considers dropping a disc in column 4. It sees that you could then reply in column 5 and set up a double threat. Since that line is bad for it, it rejects column 4 and picks a move where your best reply still leaves it safe.
Tip
You can use the same idea yourself: before each move, ask "what's my opponent's best reply?" It's the habit that separates good players from lucky ones.