The link to the code is https://github.com/Adam-Kulju/Patricia and the plan is that it will contain both the engine and filtering programs to grab different kinds of "aggressive positions" out of larger datasets (I plan to use Willow datasets at first).
I have several filtering programs already wrote up so started on my engine a couple days ago. I got a basic movegen working, with a perft of 20m nodes per second non bulk. It's much faster than Willow's and the code looks a lot nicer too. For example here is my attack detection code. It still needs comments and more descriptive variable names in places but it's a million times neater than Willow code.
Code: Select all
bool attacks_square(Position position, int sq, int color) {
int opp_color = color ^ 1, v = -1;
for (int d : AttackRays) {
v++;
int temp_pos = sq + d;
while (!out_of_board(temp_pos)) {
int piece = position.board[temp_pos];
if (!piece) {
temp_pos += d;
continue;
} else if (get_color(piece) == opp_color) {
break;
}
piece -= color;
if (piece == Pieces::WQueen || (piece == Pieces::WRook && v < 4) ||
(piece == Pieces::WBishop) && v > 3){
return true;
}
else if (piece == Pieces::WPawn) {
if (temp_pos == sq + d && (color ? (v > 5) : (v == 4 || v == 5))) {
return true;
}
}
else if (piece == Pieces::WKing && temp_pos == sq + d) {
return true;
}
break;
}
temp_pos = sq + KnightAttacks[v];
if (!out_of_board(temp_pos) &&
position.board[temp_pos] - color == Pieces::WKnight) {
return true;
}
}
return false;
}