Skip to content

rgambee/knight-grid

Repository files navigation

Knight Grid

This app creates striking patterns by placing chess pieces according to a set of simple rules. It's a lovely example of emergent behavior.

I got the idea from this Numberphile video featuring Neil Sloane. Credit also goes to Jonas Karlsson for inspiring parts of the design.

Examples

Here are a handful of interesting examples. Click the links to open them in the app. If you find a pattern you like, you can click the Share button to copy its URL.

https://rgambee.github.io/knight-grid/?players=f25959-2.1%2C598cf2-3.1&n=200 Knight Grid pattern 1

https://rgambee.github.io/knight-grid/?players=f25959-1.0%2C598cf2-4.3&n=1000 Knight Grid pattern 2

https://rgambee.github.io/knight-grid/?players=f25959-2.1%2C598cf2-2.1%2C66d980-3.3%2Cf2d959-1.0&n=1000 Knight Grid pattern 3

https://rgambee.github.io/knight-grid/?players=f25959-1.1%2C598cf2-3.1%2C66d980-4.2%2Cf2d959-3.0&n=1000 Knight Grid pattern 4

https://rgambee.github.io/knight-grid/?players=f25959-1.1%2C598cf2-2.2%2C66d980-3.3%2Cf2d959-4.4&n=1000 Knight Grid pattern 5

Explanation

Placement Rules

The board is an infinite grid. The squares are numbered, starting with 1 in the center and spiraling outward.

Each player has exactly one type of piece they can play. A knight is the classic example. On each turn, the player places a piece in the lowest-numbered square which is not threatened by an opponent.

See the Numberphile video for a clearer explanation.

Piece Types

The game works best with leaping pieces, i.e. non-sliding ones which can move in any direction. Only one standard chess piece meets these criteria: the knight. But we can use alternative pieces to create different patterns.


Copyright © 2026 Robert Gambee

About

Simple rules, surprising patterns

Resources

License

Stars

Watchers

Forks

Contributors