How the computer player works

The ideas behind WallOut's computer player, for developers who want to build their own.

Shortest paths

Everything starts with a breadth-first search from each pawn to its goal row. The length of that path is the best simple measure of who is ahead. The same search tells you whether a wall is legal: after the wall, every player must still have a path.

Which walls are worth trying

There can be over a hundred legal walls each turn, far too many to search. A wall can only slow a rival if it cuts the shortest path you found for them, so those few walls are the ones worth searching first. Walls that touch the path without cutting it can set up a two-wall trap, so they are worth a look at the top level.

Alpha-beta search

The stronger levels search ahead with alpha-beta and iterative deepening: a shallow search first, then deeper ones while time allows. A transposition table remembers positions already seen, and searching the most promising moves first makes the pruning work.

The evaluation

At the end of a line the position is scored mostly by the difference in path lengths, adjusted for the walls each player has left and for whose turn it is.

An exact endgame

Once both players have no walls left, the board cannot change. The rest is a pure race, and it can be solved exactly by working backwards over every pair of pawn squares. Our computer plays those endgames perfectly.

An opening book

The two strongest levels open from a book built from their own games against each other, so their first moves vary.

More about the game

  • vs chess
  • Free with friends
  • Quoridor meaning
  • Barricade strategy
  • Path finding game
  • Printable rules

Is WallOut's AI open source?

No. The code is not public, but this page explains the ideas behind it.

How do you check that a wall is legal?

Place it, then run a breadth-first search for every player. If any player has no path to their goal, the wall is not allowed.

Why not search every wall?

There can be over a hundred legal walls each turn. Only walls that cut a rival's shortest path can slow them, so those are searched first.

What algorithm does the strongest level use?

Alpha-beta search with iterative deepening and a transposition table, an exact solver once the walls run out, and an opening book.

Can I play against it?

Yes. Six computer players, free in the browser.