StrategoGame.org

Stratego vs Computer: How the AI Plays

Writing a Stratego computer is hard for one reason: hidden information. A chess engine sees the whole board. A Stratego engine that sees your ranks is cheating, and players can feel it. The opponent here is built to play only on what it could legitimately know.

What the AI knows

That's it. In code, the game state is passed through a redact() step that replaces every unrevealed rank of yours with “unknown” before the AI sees it. An automated test swaps hidden pieces (for example, your Marshal with your Flag) and checks that the AI's move doesn't change.

How it chooses a move

  1. Imagine an army. It deals your unknown pieces a set of ranks that fits all the evidence, weighted by experience: unmoved back-row pieces are likelier to be Bombs or the Flag, pieces that attack a lot are likelier to be officers.
  2. Search that world. It looks one to four moves ahead in that imagined position and scores the results: material, safety of revealed pieces, flag protection, pressure on likely flag squares.
  3. Repeat. It imagines dozens of different armies within its time budget.
  4. Pick the robust move. The chosen move is the one with the best average across all imagined armies, so it avoids moves that only work if a guess is right.

This “sample and search” approach is a classic technique for imperfect-information games. It runs entirely in your browser in a background thread, so the page stays smooth while the AI thinks, and nothing is sent to a server.

The four levels

LevelStyleLook-aheadThink time
CadetLearning the ropes. Makes loose moves and attacks rashly.1 move~0.1 s
CaptainSolid fundamentals. Protects its flag and trades sensibly.2 moves (+1 in the endgame)~0.3 s
ColonelReads your moves, hunts revealed pieces, sets up bluffs.3 moves (+1 in the endgame)~0.7 s
MarshalDeep search over many possible enemy armies. Bring a plan.3 moves (+1 in the endgame)~1.8 s

Challenge the AI   Tips to beat it

FAQ

Does the Stratego computer cheat?

No. Before each move the AI is handed a copy of the game in which every unrevealed rank of yours is erased. It cannot read what it does not have.

Which AI level should I start with?

Start with Captain if you know the rules, Cadet if you are learning. Move up when you win two games in a row; your record per level is shown after each game.

Why does the AI sometimes attack a Bomb?

Because it really does not know where your Bombs are. It estimates the odds from which pieces have moved and where they stand, and sometimes the odds are wrong — just as for a human.