-
Couldn't load subscription status.
- 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 board is represented by a long[12] array that contains bitboards of each type (in progress). It stores other information about the game 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
*
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
*
long[] representation
* WHITE
[0][ 8][16][24][32][40][48][56]
[1][ 9][17][25][33][41][49][57]
[2][10][18][26][34][42][50][58]
[3][11][19][27][35][43][51][59]
[4][12][20][28][36][44][52][60]
[5][13][21][29][37][45][53][61]
[6][14][22][30][38][46][54][62]
[7][15][23][31][39][47][55][63]
* BLACK
*
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]