Bricabrac - Tscp181 : 59.5/100 53-34-13 (110101=11101=0=11=1100=011001111111100==101010101=0=11110=10111010111101=01100001100110=010011=01101) 60% +70

I know that 100 games is not enough but it is good enough for now. It is a lot better than the first attempt for sure.

Bricabrac - Tscp181 : 9.0/100 6-88-6 (0100000000000000001000000000000000010000000000000=000000000=000000=000000000=000=000010100000=100000) 9% -402

The resulting PSTs are generated by really crude code. For example, wpPST[sq] = wrow * wrow * wrow + cenCol; cannot really be tuned. And it is quite arbitrary to begin with. If wrow was floating point then at least it could be multiplied by another floating point so it can be tuned. Or is there just a much better formula to begin with.

**Any suggestions?**Or maybe just load values into an array and use an automated tuning method. I really could use some advice on this.

Anyway, if one wants to see the crude eval code that at least equaled PeSTO in my engine here it is.

Code: Select all

```
void InitSearch(Thread* t) {
u64 pieces, moves, captures;
u32 sq;
s32 col, wrow, brow, cenCol, cenRow, sum, x, y;
u64 wPawns, wKnights, wBishops, wRooks, wQueens;
u64 bPawns, bKnights, bBishops, bRooks, bQueens;
u64 allPieces = piece[WHITE] | piece[BLACK];
SplitBB blocks;
u64* type[] = {
nullptr,
&wPawns, &wKnights, &wBishops, &wRooks, &wRooks, &wQueens, nullptr, nullptr,
&bPawns, &bKnights, &bBishops, &bRooks, &bRooks, &bQueens, nullptr, nullptr,
};
wPawns = wKnights = wBishops = wRooks = wQueens = 0;
bPawns = bKnights = bBishops = bRooks = bQueens = 0;
for (sq = A1; sq <= H8; sq++) {
if (type[board[sq]] != nullptr) *type[board[sq]] |= one << sq;
}
for (sq = A1; sq <= H8; sq++) {
col = x = sq & 7;
wrow = y = 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] = 40;
else wpPST[sq] = wrow * wrow * wrow + cenCol;
wpPST[sq] += ply * wrow / 32;
}
// black pawns
if (sq < A8 && sq > H1) {
if (brow == 1) bpPST[sq] = 40;
else bpPST[sq] = brow * brow * brow + cenCol;
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) * 32;
wnPST[sq] += cenRow * cenRow + cenCol * cenCol + wrow;
wnPST[sq] -= (!cenRow || !cenCol) * 30;
// black knights
captures = knightMoves[sq] & (wRooks | wQueens | king[WHITE]);
bnPST[sq] = __popcnt64(moves) * 4 + __popcnt64(captures) * 32;
bnPST[sq] += cenRow * cenRow + cenCol * cenCol + brow;
bnPST[sq] -= (!cenRow || !cenCol) * 20;
// 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) * 3 + __popcnt64(captures) * 32;
// wbPST[sq] += cenCol * cenRow * cenRow;
// black bishops
captures = moves & (wRooks | wQueens | king[WHITE]);
moves ^= captures;
bbPST[sq] = __popcnt64(moves) * 3 + __popcnt64(captures) * 32;
// bbPST[sq] += cenCol * cenRow * cenRow;
// 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) * 32;
wrPST[sq] += cenRow + wrow == 6 * 40;
// black rooks
captures = moves & (wQueens | king[WHITE]);
moves ^= captures;
brPST[sq] = __popcnt64(moves) * 2 + __popcnt64(captures) * 32;
brPST[sq] += cenRow + brow == 6 * 40;
// 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) * 32;
//black queens
captures = moves & king[WHITE];
moves ^= captures;
bqPST[sq] = __popcnt64(moves) + __popcnt64(captures) * 32;
// white king
sum = (5000 - mat[BLACK]) >> 6;
wkPST[sq] = (cenCol + cenRow) * sum;
// black king
sum = (5000 - mat[WHITE]) >> 6;
bkPST[sq] = (cenCol + cenRow) * sum;
}
// white pawn specifics
wpPST[E2] -= (board[E1] == WC) * 40;
wpPST[E3] += (board[E1] == WC) * 20;
wpPST[E4] += (board[E1] == WC) * 40;
wpPST[D2] -= (board[E1] == WC) * 40;
wpPST[D3] += (board[E1] == WC) * 20;
wpPST[D4] += (board[E1] == WC) * 40;
// black pawn specifics
bpPST[E7] -= (board[E8] == BC) * 40;
bpPST[E6] += (board[E8] == BC) * 20;
bpPST[E5] += (board[E8] == BC) * 40;
bpPST[D7] -= (board[E8] == BC) * 40;
bpPST[D6] += (board[E8] == BC) * 20;
bpPST[D5] += (board[E8] == BC) * 40;
// white knight specifics
wnPST[G1] -= (board[E1] == WC) * 20;
wnPST[B1] -= (board[E1] == WC) * 20;
wnPST[C3] -= (board[C2] == WP) * 40;
// black knight specifics
bnPST[G8] -= (board[E8] == BC) * 20;
bnPST[B8] -= (board[E8] == BC) * 20;
bnPST[C6] -= (board[C7] == BP) * 40;
// white bishop specifics
wbPST[F1] -= (board[E1] == WC) * 20;
wbPST[C1] -= (board[E1] == WC) * 20;
wbPST[D3] -= (board[D2] == WP) * 60;
wbPST[E3] -= (board[E2] == WP) * 60;
// black bishop specifics
bbPST[F8] -= (board[E8] == BC) * 20;
bbPST[C8] -= (board[E8] == BC) * 20;
bbPST[D6] -= (board[D7] == BP) * 60;
bbPST[E6] -= (board[E7] == BP) * 60;
// white queen specifics
wqPST[E2] -= (board[F1] == WB) * 40;
wqPST[D3] -= (board[F1] == WB) * 40;
wqPST[D2] -= (board[C1] == WB) * 40;
wqPST[E3] -= (board[C1] == WB) * 40;
wqPST[D1] += (board[B1] == WN) * 10;
wqPST[D1] += (board[C1] == WB) * 10;
wqPST[D1] += (board[F1] == WB) * 10;
wqPST[D1] += (board[G1] == WN) * 10;
// black queen specifics
bqPST[E7] -= (board[F8] == BB) * 40;
bqPST[D6] -= (board[F8] == BB) * 40;
bqPST[D7] -= (board[C8] == BB) * 40;
bqPST[E6] -= (board[C8] == BB) * 40;
bqPST[D8] += (board[B8] == BN) * 10;
bqPST[D8] += (board[C8] == BB) * 10;
bqPST[D8] += (board[F8] == BB) * 10;
bqPST[D8] += (board[G8] == BN) * 10;
// white king specifics
wkPST[G1] += (board[E1] == WC) * 50;
wrPST[F1] += (board[E1] == WC) * 50;
// black king specifics
bkPST[G8] += (board[E8] == BC) * 50;
brPST[F8] += (board[E8] == BC) * 50;
pos[WHITE] = 0;
pos[BLACK] = 0;
mat[WHITE] = 0;
mat[BLACK] = 0;
pieces = piece[WHITE];
while (pieces) {
_BitScanForward64(&sq, pieces);
pieces ^= one << sq;
mat[WHITE] += value[board[sq]];
pos[WHITE] += pcePST[board[sq]][sq];
}
pieces = piece[BLACK];
while (pieces) {
_BitScanForward64(&sq, pieces);
pieces ^= one << sq;
mat[BLACK] += value[board[sq]];
pos[BLACK] += pcePST[board[sq]][sq];
}
}
```