0x88
The 0x88 chess board representation is a square-centric method of representing the chess board in computer chess programs. The number 0x88 is a hexadecimal integer (136 , 210 , 10001000 ). The rank and file positions are each represented by a nibble (hexadecimal digit), and the bit gaps simplify a number of computations to bitwise operations. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
The 0x88 chess board representation is a square-centric method of representing the chess board in computer chess programs. The number 0x88 is a hexadecimal integer (136 , 210 , 10001000 ). The rank and file positions are each represented by a nibble (hexadecimal digit), and the bit gaps simplify a number of computations to bitwise operations. ==Layout== In the 0x88 board representation, the layout is spread out to cover an 8-by-16 board, equal to the size of two adjacent chessboards. Each square of the 8-by-16 matrix is assigned a number as can be seen in the board layout table. In this scheme each nibble represents a rank or a file, so that the 8-bit integer 0x42 represents the square at (4,2) in zero-based numbering, i.e. c5 in standard algebraic notation. Adding 16 to a number for a square results in the number for the square one row above, and subtracting 16 results in the number for the square one row below. To move from one column to another the number is increased or decreased by one. In hexadecimal notation, legal chess positions (A1-H8) are always below 0x88. This layout simplifies many computations that chess programs need to perform by allowing bitwise operations instead of comparisons. \text{square}_{0\rm{x}88} = (\text{rank}_\text{0 to 7} Thus, a1 corresponds to 00000000_2 , with all 8 of the bits set to 0 , b2 corresponds to 00010001_2 , and h8 corresponds to 01110111_2 . To convert an 0x88 value to a file-rank coordinate pair: \text{file}_\text{0 to 7} = \text{square}_{0\rm{x}88}\ \&\ 7 \text{rank}_\text{0 to 7} = ( \text{square}_{0\rm{x}88}\ >> 4 ) Note: In the above formulas, > represent left and right logical bit shift operations respectively while & represents bitwise and. ==Applications== ===Off-the-board detection=== Off-the-board detection is a feature of chess programs which determines whether a piece is on or off the legal chess board. In 0x88, the highest bit of each nibble represents whether a piece is on the board or not. Specifically, out of the 8 bits to represent a square, the fourth and the eighth must both be 0 for a piece to be located within the board. This allows off-the-board detection by bitwise operations. If $square AND 0x88 (or, in binary, 0b10001000 ) is non-zero, then the square is not on the board. This bitwise operation requires fewer computer resources than integer comparisons. This makes calculations such as illegal move detection faster. ===Square relations=== The difference of valid 0x88 coordinates A and B is unique with respect to distance and direction, which is not true for classical packed three-bit rank and file coordinates. That makes lookups for Manhattan distance, possible piece attacks, and legal piece moves more resource-friendly. While classical square coordinates in the 0–63 range require 4K-sized tables (64×64), the 0x88 difference takes 1/16 that or 256-sized tables—or even 16 less. An offset of 119 (0x77 as the maximum valid square index) is added, to make ±119 a 0–238 range (a size of 240 for alignment reasons). 0x88Diff = 0x77 + A − B ==References== ==External links== Chess board representations by Robert Hyatt How Zarkov Plays Chess by John Stanback The 0x88 representation from Mediocre Chess by Jonatan Pettersson
Cite this
"0x88". 1765459529. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1326893455 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy