HooverChessUtils_PgnReader 0.9.0
Loading...
Searching...
No Matches
Public Attributes | List of all members
hoover_chess_utils::pgn_reader::CompressedPosition_FixedLength Struct Reference

A position encoded in 192 bits. More...

#include <position-compress-fixed.h>

Public Attributes

std::uint64_t occupancy
 Occupancy mask.
 
std::array< std::uint32_t, 4U > dataPlanes
 Data planes.
 

Detailed Description

A position encoded in 192 bits.

The encoding scheme is as follows:

  1. Field occupancy determines the squares that are occupied, same encoding as SquareSet. All other squares are empty.
  2. For every occupied square, the data planes specify an encoded 4-bit piece/square value (CompressedPosition_PieceEncoding).
  3. For the Nth occupied square, the Nth bits of the data planes encode the value as follows:
    value = BIT_N(dataPlanes[0]) + 2*BIT_N(dataPlanes[1]) + 4*BIT_N(dataPlanes[2]) + 8*BIT_N(dataPlanes[3])

Properties of the position other than the piece configuration are encoded as follows:

Property Encoding
Side to move Encoded in the white king: CompressedPosition_PieceEncoding::WHITE_KING_IN_TURN or CompressedPosition_PieceEncoding::WHITE_KING_NOT_IN_TURN.
Castling rights Encoded in the rooks: CompressedPosition_PieceEncoding::WHITE_ROOK_CANNOT_CASTLE, CompressedPosition_PieceEncoding::WHITE_ROOK_CAN_CASTLE, CompressedPosition_PieceEncoding::BLACK_ROOK_CANNOT_CASTLE, CompressedPosition_PieceEncoding::BLACK_ROOK_CAN_CASTLE.
En passant square Encoded as the en passant capturable pawn: CompressedPosition_PieceEncoding::EP_PAWN. The color of the en passant capturable pawn is the opposite of the side to move. The en passant square is inferred from the en passant capturable pawn position (retreat by 1 square).

The usual chess position restrictions apply:

  1. There must be exactly one white king, indicated by either CompressedPosition_PieceEncoding::WHITE_KING_IN_TURN or CompressedPosition_PieceEncoding::WHITE_KING_NOT_IN_TURN.
  2. There must be exactly one black king
  3. The en-passant capturable pawn must be on the 4th rank (white pawn) or 5th rank (black pawn).
  4. Castling rights:
    1. CompressedPosition_PieceEncoding::WHITE_ROOK_CAN_CASTLE may be present only on the 1st rank.
    2. CompressedPosition_PieceEncoding::BLACK_ROOK_CAN_CASTLE may be present only on the 8th rank.
    3. If a CompressedPosition_PieceEncoding::WHITE_ROOK_CAN_CASTLE is present, then white king must be on the 1st rank
    4. If a CompressedPosition_PieceEncoding::BLACK_ROOK_CAN_CASTLE is present, then black king must be on the 8th rank
    5. There can be at most one rook that can castle on either side (left/right) of the corresponding king.
Remarks
The encoding scheme is designed for fast compression and decompression of the position represented by ChessBoard.

Member Data Documentation

◆ dataPlanes

std::array<std::uint32_t, 4U> hoover_chess_utils::pgn_reader::CompressedPosition_FixedLength::dataPlanes

Data planes.

◆ occupancy

std::uint64_t hoover_chess_utils::pgn_reader::CompressedPosition_FixedLength::occupancy

Occupancy mask.

See also
SquareSet

The documentation for this struct was generated from the following file: