Generate random chess position

From Rosetta Code
Revision as of 09:07, 11 December 2015 by Grondilu (talk | contribs) (Created page with "{{draft task}} The purpose of this task is to generate a random chess position in FEN format. The position does not have to be realistic or even balanced, but it ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Generate random chess position is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

The purpose of this task is to generate a random chess position in FEN format. The position does not have to be realistic or even balanced, but it must comply to the following rules and guidelines :

  • there is one and only one king of each color (one black king and one white king);
  • the kings must not be placed on adjacent squares;
  • there can not be any pawn in the promotion square (no white pawn in the eighth rank, and no black pawn in the first rank);
  • in addition to the kings, 0 up to 32 pieces of either color can be added. There is no requirement for material balance between sides;
  • it is white's turn, it is assumed that both sides have lost castling rights and that there is no possibility for *en passant* (the FEN should thus end in w - - 0 1);