411 REFERENCE · Wikipedia
0x88
Reference material by Wikipedia contributors. This retains its source identity and is not 411 news reporting.
Method of representing a chessboard in software
a chess programming concept the number 0x88 (number)
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 (13610, 2108, 100010002). 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.Hyatt 2013
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.Schalk 2008 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.Østensen 2016
+ 0x88 board layoutHyatt 2013 0x00 (a) 0x01 (b) 0x02 (c) 0x03 (d) 0x04 (e) 0x05 (f) 0x06 (g) 0x07 (h) 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x70 (8) 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 0x60 (7) 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 0x50 (6) 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 0x40 (5) 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 0x30 (4) 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0x20 (3) 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 0x10 (2) 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 0x00 (1) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Algebraic notation and conversion
thumb|right|Squares on a chess board with algebraic notation
Algebraic notation (chess)
The modern standard to identify the squares on a chessboard and moves in a game is algebraic notation, whereby each square of the board is identified by a unique coordinate pair — a letter between a and h for the horizontal coordinate, known as the file, and a number between 1 and 8 for the vertical coordinate, known as the rank.
In computer chess, file-rank coordinates are internally represented as integers ranging from 0 to 7, with file a mapping to 0 through to file h mapping to 7, while the rank coordinate is shifted down by one to the range 0 to 7.
An advantage of the 0x88 coding scheme is that values can be easily converted between 0x88 representation and file-rank coordinates using only bitwise operations, which are simple and efficient for computer processors to work with. To convert a zero-based file-rank coordinate to 0x88 value:
Thus, a1 corresponds to , with all 8 of the bits set to , b2 corresponds to , and h8 corresponds to .Hyatt 2013
To convert an 0x88 value to a file-rank coordinate pair:
Note: In the above formulas, << and >> 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.Dailly Gotojuch Henning Lawson 2008 This allows off-the-board detection by bitwise and operations. If $square AND 0x88 (or, in binary, 0b10001000) is non-zero, then the square is not on the board.Reul 2009 This bitwise operation requires fewer computer resources than integer comparisons. This makes calculations such as illegal move detection faster.Reul 2009
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.Moreland 2007
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).Moreland 2007
0x88Diff = 0x77 + A − B
Adoption
Bitboard#Chess bitboards
Though the 0x88 representation was initially popular, it has been mostly replaced by the system of bitboards.Keen 2009
References
Works cited
http://www.cis.uab.edu/hyatt/boardrep.html Chess program board representations Hyatt Robert 2013 Robert Hyatt https://web.archive.org/web/20130212063528/http://www.cis.uab.edu/hyatt/boardrep.html dead 12 February 2013 6 March 2020
Reul Fritz Max Heinrich New architectures in computer chess 2009 Gildeprint, TICC Dissertation Series 6 https://research.tilburguniversity.edu/en/publications/new-architectures-in-computer-chess 9789490122249
Østensen Emil Fredrik University of Oslo Autumn 2016 Master in programming and networks University of Oslo https://www.duo.uio.no/bitstream/handle/10852/53769/master.pdf
http://www.brucemo.com/compchess/programming/0x88.htm https://web.archive.org/web/20070716111804/http://www.brucemo.com/compchess/programming/0x88.htm dead 2007-07-16 0x88 Move Generation Moreland Bruce 2007-07-16 2020-03-12
http://www.cs.man.ac.uk/~schalk/3192/notes.pdf COMP30191 The Theory of Games and Game Models Schalk Andrea August 7, 2008 University of Manchester Department of Computer Science 2020-03-18
https://www.labri.fr/perso/fleury/courses/pdp/Board_Games/Chess/LitReview.pdf A History of Computer Chess Keen Ben November 2009 Laboratoire Bordelais de Recherche en Informatique 2020-03-23 2020-03-23 https://web.archive.org/web/20200323045059/https://www.labri.fr/perso/fleury/courses/pdp/Board_Games/Chess/LitReview.pdf dead
https://www.researchgate.net/publication/268426213 Chess Mantis A Chess Engine Dailly Paul Gotojuch Dominik Henning Neil Lawson Keir Macdonald Alec Tajaddinov Tamerlan March 18, 2008 2020-03-23
External links
Chess board representations by Robert Hyatt
How Zarkov Plays Chess https://web.archive.org/web/20200819041139/http://john.stanback.net/zarkov/zarkov_methods.html 2020-08-19 by John Stanback
The 0x88 representation from Mediocre Chess https://web.archive.org/web/20180820110756/http://mediocrechess.varten.org/index.html 2018-08-20 by Jonatan Pettersson
Category:Computer chess