Changes

Jump to: navigation, search

Pieces

45 bytes added, 12:38, 29 June 2021
no edit summary
There are six types of pieces for each side, in total twelve different men. Since only one piece may occupy one [[Squares|square]] at a time, one usually expands the range of piece codes with the Nil-Piece aka empty square, often encoded as zero. Depending on the [[Board Representation|board representation]], some programmers introduce an artificial blocking piece, which surrounds the embedded [[8x8 Board|8x8 boards]] inside a [[10x12 Board|10x12 board]] for cheaper off the board tests in offset [[Move Generation|move generation]].
For cheaper extraction, most programmers prefer distinct coding of piece-types and the color of piece. Quite common is to use three bits to encode the piece-type plus one bit or [[General Setwise Operations#TheTwosComplement|Two's Complement]] (not recommend for languages with zero based array indices, like [[C]], [[Cpp|C++]] or [[Java]]) for the color.
Other programs distinguish not only piece-type and color, but enumerate all 32 pieces from their [[Initial Position|initial position]], which label or code does not change during the course of a game (even after a possible [[Promotions|promotion]] of a pawn) and might be one-to-one associated with the bit-position of a 32-bit [[Piece-Sets|piece set]], and/or are used to index a [[Piece-Lists|piece list]] containing the current [[Squares|square]] the piece resides on.

Navigation menu