switch to builtin_popcountll for board eval
This commit is contained in:
parent
e1fe8ee603
commit
05a0b2b7f1
31
src/eval.c
31
src/eval.c
@ -38,26 +38,19 @@ move *findBest(move* moves, size_t size, game* g){
|
||||
|
||||
int evaluateBoard(game *game) {
|
||||
int score = 0;
|
||||
score += __builtin_popcountll(game->white.pawns) * PAWN_VALUE;
|
||||
score += __builtin_popcountll(game->white.knights) * KNIGHT_VALUE;
|
||||
score += __builtin_popcountll(game->white.bishops) * BISHOP_VALUE;
|
||||
score += __builtin_popcountll(game->white.rooks) * ROOK_VALUE;
|
||||
score += __builtin_popcountll(game->white.queen) * QUEEN_VALUE;
|
||||
score += __builtin_popcountll(game->white.king) * KING_VALUE;
|
||||
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
long long bit = 1LL << i;
|
||||
if (game->white.pawns & bit) score += PAWN_VALUE;
|
||||
else if (game->white.knights & bit) score += KNIGHT_VALUE;
|
||||
else if (game->white.bishops & bit) score += BISHOP_VALUE;
|
||||
else if (game->white.rooks & bit) score += ROOK_VALUE;
|
||||
else if (game->white.queen & bit) score += QUEEN_VALUE;
|
||||
else if (game->white.king & bit) score += KING_VALUE;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
long long bit = 1LL << i;
|
||||
if (game->black.pawns & bit) score -= PAWN_VALUE;
|
||||
else if (game->black.knights & bit) score -= KNIGHT_VALUE;
|
||||
else if (game->black.bishops & bit) score -= BISHOP_VALUE;
|
||||
else if (game->black.rooks & bit) score -= ROOK_VALUE;
|
||||
else if (game->black.queen & bit) score -= QUEEN_VALUE;
|
||||
else if (game->black.king & bit) score -= KING_VALUE;
|
||||
}
|
||||
score -= __builtin_popcountll(game->black.pawns) * PAWN_VALUE;
|
||||
score -= __builtin_popcountll(game->black.knights) * KNIGHT_VALUE;
|
||||
score -= __builtin_popcountll(game->black.bishops) * BISHOP_VALUE;
|
||||
score -= __builtin_popcountll(game->black.rooks) * ROOK_VALUE;
|
||||
score -= __builtin_popcountll(game->black.queen) * QUEEN_VALUE;
|
||||
score -= __builtin_popcountll(game->black.king) * KING_VALUE;
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user