-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This project was my attempt at building a chess engine from scratch, and it is definitely not the most efficient. At its current state, it can analyse about 4,000 positions a second. At depth 4, it takes about 3-5 minutes to analyse around 2 million positions.
The Game is represented with a long[12] board array that contains bitboards of each type (in progress). It also stores other information such as En Passant, Castling Rights and Move Clocks. The Piece 2D array representation was replaced by the bitboard representation for greater efficiency. It allowed for simple development but added overhead for accessing data.
The following breakdown how the array matches up with a typical chess board, where the rank numbers was aligned to the array indices.
Each of the long indices represent the following:
w_pawn
w_knight
w_bishop
w_rook
w_queen
w_king
b_pawn
b_knight
b_bishop
b_rook
b_queen
b_king
Typical Chess Board
* Black
[A8][B8][C8][D8][E8][F8][G8][H8]
[A7][B7][C7][D7][E7][F7][G7][H7]
[A6][B6][C6][D6][E6][F6][G6][H6]
[A5][B5][C5][D5][E5][F5][G5][H5]
[A4][B4][C4][D4][E4][F4][G4][H4]
[A3][B3][C3][D3][E3][F3][G3][H3]
[A2][B2][C2][D2][E2][F2][G2][H2]
[A1][B1][C1][D1][E1][F1][G1][H1]
* White
*
Little-Endian File-Rank Mapping
long representation
A1 = 0b1L
A2 = 0b01L
A3 = 0b001L
A4 = 0b00001L
A5 = 0b000001L
A6 = 0b0000001L
A7 = 0b00000001L
A8 = 0b000000001L
B1 = 0b0000000001L
...
H8 = 0b0000000000000000000000000000000000000000000000000000000000000001L
ARRAY REFERENCE TABLE
* WHITE
[A1][B1][C1][D1][E1][F1][G1][H1]
[A2][B2][C2][D2][E2][F2][G2][H2]
[A3][B3][C3][D3][E3][F3][G3][H3]
[A4][B4][C4][D4][E4][F4][G4][H4]
[A5][B5][C5][D5][E5][F5][G5][H5]
[A6][B6][C6][D6][E6][F6][G6][H6]
[A7][B7][C7][D7][E7][F7][G7][H7]
[A8][B8][C8][D8][E8][F8][G8][H8]
* BLACK
*
Piece[][] Representation
WHITE
[0,0][1,0][2,0][3,0][4,0][5,0][6,0][7,0]
[0,1][1,1][2,1][3,1][4,1][5,1][6,1][7,1]
[0,2][1,2][2,2][3,2][4,2][5,2][6,2][7,2]
[0,3][1,3][2,3][3,3][4,3][5,3][6,3][7,3]
[0,4][1,4][2,4][3,4][4,4][5,4][6,4][7,4]
[0,5][1,5][2,5][3,5][4,5][5,5][6,5][7,5]
[0,6][1,6][2,6][3,6][4,6][5,6][6,6][7,6]
[0,7][1,7][2,7][3,7][4,7][5,7][6,7][7,7]
BLACK
A File = [0,y] B File = [1,y]
C File = [2,y] D File = [3,y]
E File = [4,y] F File = [5,y]
G File = [6,y] H File = [7,y]
1st Rank = [x,0] 2nd Rank = [x,1]
3rd Rank = [x,2] 4th Rank = [x,3]
5th Rank = [x,4] 6th Rank = [x,5]
7th Rank = [x,6] 8th Rank = [x,7]