File size: 1,301 Bytes
3c88a0f
 
 
 
1
2
3
4
5
{"type": "session", "harness": "opencode", "id": "chess-0090", "name": "Chess Board Representation"}
{"type": "message", "message": {"role": "system", "content": "You are an expert chess programmer."}}
{"type": "message", "message": {"role": "user", "content": "Explain chess board representations for programming"}}
{"type": "message", "message": {"role": "assistant", "content": "Board representation maps the 8x8 chessboard to data structures for search, evaluation, and move generation.\n\nPiece-centric: one bitboard (64-bit word) per piece type. White pawns, black knights, etc. each get their own 64-bit integer. One-bits = occupied squares. Fast for set operations (AND, OR, XOR, popcount).\n\nSquare-centric: array[64] storing piece type at each square. Mailbox: 8x8 array. 0x88: 16-byte array where upper nibble = file, lower = rank. Off-board squares have bit 0x88 set (cheap legality check).\n\nHybrid: bitboards for piece positions + 8x8 array for quick square-to-piece lookup.\n\nFull position: board + side to move + castling rights (4 bits) + en passant square + halfmove clock + fullmove counter. Represented as FEN string.\n\nBitboard operations: shift by +1 (east), -1 (west), +8 (north), -8 (south). Diagonals: +7, +9, -7, -9. Masks for files, ranks, diagonals precomputed."}}