Board Representation

Home * Board Representation

A chess program needs an internal board representation to maintain chess positions for its search, evaluation and game-play. Beside modelizing the chessboard with its piece-placement, some additional information is required to fully specify a chess position, such as side to move, castling rights, possible en passant target square and the number of reversible moves to keep track on the fifty-move rule.

To begin with, we further elaborate on the pure data structures to represent the board and its piece-placement. There are piece centric and square centric representations as well as hybrid solutions.

= Piece Centric= A piece centric representation keeps lists, arrays or sets of all pieces still on the board - with the associated information which square they occupy. A popular piece centric representative is the set-wise bitboard-approach. One 64-bit word for each piece type, where one-bits associate their occupancy.
 * Piece-Lists
 * Piece-Sets
 * Bitboards

= Square Centric= The square centric representation implements the inverse association - is a square empty or is it occupied by a particular piece? The most popular square centric representations, mailbox or it's 0x88-enhancements - are basically arrays of direct piece-codes including the empty square and probably out of board codes. Hybrid solutions may further refer piece-list entries.
 * Mailbox
 * 8x8 Board
 * 10x12 Board
 * 0x88
 * Vector Attacks

=Hybrid Solutions= While different algorithms and tasks inside a chess program might prefer one of these associations, it is quite common to use redundant board representations with elements of both. Bitboard approaches often keep a 8x8 board to determine a piece by square, while square centric board array approaches typically keep piece-lists and/or piece-sets to avoid scanning the board for move generation purposes.

=Move Generation= With a board representation, one big consideration is the generation of moves. This is essential to the game playing aspect of a chess program, and it must be completely correct. Writing a good move generator is often the first basic step of creating a chess program.
 * Move Generation
 * Perft

=Make and Unmake=
 * Incremental Updates
 * Copy-Make
 * Make Move
 * Unmake Move
 * Bitboard Update By Move

=See Also=
 * Array of Nibbles
 * Attack and Defend Maps
 * Chess Position
 * Extended Position Description (EPD)
 * Forsyth-Edwards Notation (FEN)
 * Chinese Chess Board Representation
 * Graphics Programming
 * Quad-Bitboards

=Publications=
 * Claude Shannon (1949). Programming a Computer for Playing Chess. pdf from The Computer History Museum
 * Alex Bell (1972). Games Playing with Computers. Allen & Unwin, ISBN-13: 978-0080212227
 * Dan Spracklen, Kathe Spracklen (1978). First Steps in Computer Chess Programming. BYTE, Vol. 3, No. 10, pdf from The Computer History Museum
 * Vladan Vučković (2008). The Compact Chessboard Representation. ICGA Journal, Vol. 31, No. 3
 * Vladan Vučković (2012). An Alternative Efficient Chessboard Representation based on 4-Bit Piece Coding. Yugoslav Journal of Operations Research, Vol. 22, No. 1, pdf

=Forum Posts=

1999

 * Datastructures in computer chess by Gustav Grundin, rgcc, May 11, 1999
 * How do you represent chess boards in your chess programms by Brian Nielsen, CCC, September 22, 1999
 * Re: How do you represent chess boards in your chess programms by Sven Reichard, CCC, September 29, 1999

2000 ...

 * Differences between 0x88 ,10x12 and Bitboards!? by Axel Grüttner, CCC, November 19, 2002
 * Fruit's Board Representation? by Steve Maughan, Winboard Programming Forum, April 27, 2005
 * Board representation : 0x88 or 10x12 ? by Philippe, Winboard Forum, March 02, 2006
 * Board Types in '08 by Joshua Shriver, CCC, June 28, 2008

2010 ...

 * I'm Puzzled - Storing Piece Info & Magic Move Gen... by Steve Maughan, CCC, March 27, 2013
 * Table-less bitboards (bitrays?) by Harm Geert Muller, CCC, June 18, 2013
 * Best Board Representation for 32bit CPUs by net, Winboard Forum, July 14, 2013
 * Some questions from a beginner by Tim Hagen, CCC, March 30, 2016
 * best board representation for variants (javascript) ? by Mahmoud Uthman, CCC, December 10, 2017 » JavaScript, Chess Variants

=External Links=
 * Board representation (chess) from Wikipedia
 * Chapter 3: Board Games - 3.1 CHESS from Alex Bell (1972). Games Playing with Computers. Allen & Unwin, ISBN-13: 978-0080212227
 * Chess board representations by Robert Hyatt
 * Board representations | Lecture notes by David Eppstein, April 8, 1997
 * Chess Board Representations by Paul Verhelst
 * Chess Programming - The Chess Board by Thomas Petzke
 * board representation definition from |Financial Times Lexicon
 * Representation of Chess Game - Computer Architecture and Languages Laboratory, University of Maribor

=References= Up one Level