Code: Select all
for (sq = A1; sq <= H8; sq++) {
col = sq & 7;
wrow = sq >> 3;
brow = 7 - wrow;
cenCol = col < 4 ? col : 7 - col;
cenRow = wrow < 4 ? wrow : 7 - wrow;
// white pawns
if (sq > H1 && sq < A8) {
if (wrow == 1) wpPST[sq] = 12;
else wpPST[sq] = cenCol * cenCol + wrow * wrow;
wpPST[sq] += ply * wrow / 32;
}
// black pawns
if (sq < A8 && sq > H1) {
if (brow == 1) bpPST[sq] = 12;
else bpPST[sq] = cenCol * cenCol + brow * brow;
bpPST[sq] += ply * brow / 32;
}
// knights
moves = knightMoves[sq] & ~allPieces;
// white knights
captures = knightMoves[sq] & (bRooks | bQueens | king[BLACK]);
wnPST[sq] = __popcnt64(moves) * 4 + __popcnt64(captures) * 16;
wnPST[sq] += (cenRow + cenRow) * (cenCol + cenCol);
// black knights
captures = knightMoves[sq] & (wRooks | wQueens | king[WHITE]);
bnPST[sq] = __popcnt64(moves) + __popcnt64(captures) * 16;
bnPST[sq] += (cenRow + cenRow) * (cenCol + cenCol);
// bishops
blocks.bb = allPieces & b7e[sq];
blocks.bb = ((blocks.l32 >> 8) | blocks.h32);
moves = bss[sq][blocks.r1][0]
& bss[sq][blocks.r2][1]
& bss[sq][blocks.r3][2];
// white bishops
captures = moves & (bRooks | bQueens | king[BLACK]);
moves ^= captures;
wbPST[sq] = __popcnt64(moves) * 4 + __popcnt64(captures) * 16;
wbPST[sq] += (cenRow * cenCol) + wrow;
// black bishops
captures = moves & (wRooks | wQueens | king[WHITE]);
moves ^= captures;
bbPST[sq] = __popcnt64(moves) * 4 + __popcnt64(captures) * 16;
bbPST[sq] += (cenRow * cenCol) + brow;
// rooks
blocks.bb = allPieces & rob[sq];
moves = qss[sq][(blocks.bb >> (sq & 56)) & 127][0]
& qss[sq][blocks.r2][1]
& qss[sq][blocks.r3][2]
& qss[sq][blocks.r4][3]
& qss[sq][blocks.r5][4]
& qss[sq][blocks.r6][5]
& qss[sq][blocks.r7][6]
& rob[sq];
// white rooks
captures = moves & (bQueens | king[BLACK]);
moves ^= captures;
wrPST[sq] = __popcnt64(moves) * 2 + __popcnt64(captures) * 16;
wrPST[sq] += cenRow + wrow == 6 * 20;
// black rooks
captures = moves & (wQueens | king[WHITE]);
moves ^= captures;
brPST[sq] = __popcnt64(moves) * 2 + __popcnt64(captures) * 16;
brPST[sq] += cenRow + brow == 6 * 20;
// queens
blocks.bb = allPieces & rob[sq];
moves = qss[sq][(blocks.bb >> (sq & 56)) & 127][0]
& qss[sq][blocks.r2][1]
& qss[sq][blocks.r3][2]
& qss[sq][blocks.r4][3]
& qss[sq][blocks.r5][4]
& qss[sq][blocks.r6][5]
& qss[sq][blocks.r7][6];
// white queens
captures = moves & king[BLACK];
moves ^= captures;
wqPST[sq] = __popcnt64(moves) + __popcnt64(captures) * 16;
// wqPST[sq] += (cenRow * cenCol) + wrow;
//black queens
captures = moves & king[WHITE];
moves ^= captures;
bqPST[sq] = __popcnt64(moves) + __popcnt64(captures) * 16;
// bqPST[sq] += (cenRow * cenCol) + brow;
// white king
sum = (2200 - mat[BLACK]) >> 6;
wkPST[sq] = (cenCol + cenRow) * sum;
// black king
sum = (2200 - mat[WHITE]) >> 6;
bkPST[sq] = (cenCol + cenRow) * sum;
}
// white pawn specifics
wpPST[E2] -= (board[E1] == WC) * 20;
wpPST[E4] += (board[E1] == WC) * 20;
// black pawn specifics
bpPST[E7] -= (board[E8] == BC) * 20;
bpPST[E5] += (board[E8] == BC) * 20;
// white king specifics
wkPST[G1] += (board[E1] == WC) * 40;
// black king specifics
bkPST[G8] += (board[E8] == BC) * 40;
Here is my best game.
[pgn][Event "Computer chess game"]
[Site "DESKTOP-HFVHK2B"]
[Date "2021.10.23"]
[Round "?"]
[White "mjshe"]
[Black "Bricabrac"]
[Result "0-1"]
[BlackElo "2200"]
[ECO "D07"]
[Opening "QGD"]
[Time "23:48:18"]
[Variation "Chigorin, 3.Nf3"]
[WhiteElo "2400"]
[TimeControl "120+6"]
[Termination "normal"]
[P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