↑↓ move · ↵ open · esc close

Games and search

How does a program choose a move?

Each game is its own project, with its own rules. They share one question: given a position, which move is best, and how far ahead must the search look? More games will be added.

The series
01In progress
Searching a map

Pathfinding

A*, Dijkstra and friends on a grid: five ways to pick the next cell, small enough to watch.

TypeScriptA*Visualisation
Open the project→
02In progress
Searching a game

Tic-tac-toe

Minimax with alpha-beta pruning: the same idea of a search, but against an opponent who answers back.

TypeScriptMinimaxAlpha-beta
Open the project→
03Shipped
A connection game

HEX

A shortest-path evaluation feeds an alpha-beta search. Raise the depth and watch the positions examined.

TypeScriptCanvasAlpha-beta
Open the project→
04Shipped
Flipping a board

Othello

Corners, edges and mobility decide the game, so the evaluation matters as much as the search. Pick the algorithm that plays you.

TypeScriptCanvasMinimaxAlpha-betaMonte Carlo
Open the project→
05Shipped
Five opponents, one board

Connect Four

Few moves per turn, so the searches can go deep. Compare minimax, alpha-beta and Monte Carlo on the same position.

TypeScriptCanvasMinimaxAlpha-betaMonte Carlo
Open the project→
06In progress
A game with phases

Mills

Placing, moving and flying change the rules mid-game. Finished in C++; the browser version is next.

C++Raylib
Open the project→
Why they belong together

Each game needs the same three things: a way to represent a position, a way to score it, and a way to skip what is not worth searching.