Piece positions on a board.
Properties are sets of squares, like board.occupied for all occupied squares, board[color] for all pieces of that color, and board[role] for all pieces of that role. When modifying the properties directly, take care to keep them consistent.
board.occupied
board[color]
board[role]
All occupied squares.
All squares occupied by pieces known to be promoted. This information is relevant in chess variants like Crazyhouse.
Finds the unique king of the given color, if any.
color
Resets all pieces to the default starting position for standard chess.
Put piece onto square, potentially replacing an existing piece. Returns the existing piece, if any.
piece
square
Removes and returns the piece from the given square, if any.
Static
Piece positions on a board.
Properties are sets of squares, like
board.occupied
for all occupied squares,board[color]
for all pieces of that color, andboard[role]
for all pieces of that role. When modifying the properties directly, take care to keep them consistent.