GenerateRandomSearch

Random Chess Position Generator

Most random chess positions are impossible. Not merely unlikely — impossible: no game could ever have produced them, because a bishop is on the wrong colour for the pawns around it, or a side has more pieces than it could have kept, or the player not to move is somehow in check. Scattering pieces and checking a few rules does not fix that, because whether a position is reachable is a question about the game that led to it, and no amount of staring at the board answers it. So this plays a game instead. Every position comes with the moves that reach it from the opening, and you can replay them on any board and arrive at the same place.

What this generator does

Plays a game of legal moves from the standard opening position, stopping at the length you asked for or when the game ends, and hands over the resulting board, its FEN and the moves that produced it.

How to use this tool

  1. Choose how many moves to play, counting each side's move separately.
  2. Generate, and copy the FEN into your board or engine of choice.
  3. Replay the move list underneath if you want to see how the position came about — or to check that it does.
  4. Play fewer moves for an opening-like position, more for a thinned-out middlegame or an endgame.
  5. Switch to a random arrangement if you want any board that breaks no placement rule, and do not need it to be reachable.

Understanding the controls

Position
Played out from the opening, which comes with the game that reaches it; or a random arrangement, which comes with nothing and claims nothing.
Moves played
How long the game runs, counting each side's move separately. Short games look like openings; long ones thin the board out. A game that ends in checkmate or stalemate stops there.
Extra pieces
In arrangement mode only: how many pieces to scatter beyond the two kings, between none and twenty-four.
Seed
Any word reproduces exactly the same game, so it can be shared or set up again later.

Common use cases

  • Visualisation and analysis practice from positions that could really occur
  • Endgame and middlegame drills that a coach can vouch for
  • Test positions for a board renderer or FEN parser, including castling rights and en passant
  • A worked example of how a position and its history relate, for teaching
  • Producing the same position and the same game twice from a seed

How this generator works

The rules of chess are implemented in full — castling on both sides with all four of its conditions, capture in passing, promotion to any of the four pieces, and the requirement that a move never leave your own king in check. A move is chosen at random from those the rules allow, played, and the process repeats. Because the position is arrived at by playing, it is reachable by construction; and because the moves are kept, that is something you can check rather than something you have to take on trust. Before a position is shown, its own move list is replayed from the opening using nothing but the text of the moves, and the result must match the published FEN exactly — side to move, castling rights and en passant square included. The move generator itself is held to the published move counts for standard test positions, which are unforgiving of exactly the mistakes this kind of code makes.

Randomness and fairness

Each move is drawn at random from the legal moves available, using the browser's cryptographically secure generator. A seed replaces that with a repeatable source so the same game comes out again; a seeded game is reproducible and explicitly not cryptographically secure.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Random play is not good play: these are positions a game could reach, not ones a game between two competent players would.
  • A game stops after a hundred moves without a capture or a pawn move, so it never runs past the point where a draw could have been claimed.
  • Repetition is not tracked, so a long game may pass through the same position more than once.
  • Random play very rarely ends in checkmate — measured, twice in forty games of three hundred moves — so most positions are simply where the game was stopped.
  • The arrangement setting still makes no claim to be reachable, and gives no move list, because there is none to give.

Privacy and your data

The position and its FEN are produced in your browser. Neither the board nor your seed is transmitted or stored.