# Position Representation

## Bitboard

Bitboard is the best presentation of a chess position. Main advantage of that representation is a speed becaus it based on bitwise operations. The presentation contains a set of 64-bit integer numbers. Both sides have six numbers for all different types of pieces. For example, the position below has the following white pawns presentation:

0 0 0 0 0 0 0 0 |

The 64-bit presentation allows a fast move generator and a fast evaluation function. For example, the expression (WhitePawns << 8) & ~AllSquares is used to represent all possible destination squares of white pawns for one square up. Let us see this expression in grater detail. Firstly, the presentation of white pieces was shifted by 8 bits or moved for one square up. Then with negation of presentation of all pieces we get presentation of empty squares. Finally, with bitwise operation AND between both presentations we get presentation of destination squares. This presentation and presentation of white pawns enables generating all possible moves for white pawns for one square up. Similarly, we can calculate all possible moves for pawns, knights, and the king. For generating moves for sliding pieces we use addition information which is described below.

## Rotated bitboard

The standard bitboard presentation described above is very useful in generating moves for all pieces except sliding ones (bishop, rock, queen). Rotated bitboard provides additional information for certain types of pieces, namely the sliding ones. Bitboard is rotated by 45, 90, and 135 degreees. The 45 and 135 degrees rotations are used for calculating diagonal and the 90 degrees for calculating vertical moves. The speedup of rotated bitboard relies on quick discovery of attacks on certain squares without the need to use program loops which is the case for all other representations.