add uci support
This commit is contained in:
parent
e7af512d93
commit
d649358c12
13 changed files with 618 additions and 127 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "evaluation.h"
|
||||
#include "movegen.h"
|
||||
#include "repetition.h"
|
||||
|
||||
// Material values
|
||||
const int piece_value[12] = {100, 320, 330, 500, 900, 20000,
|
||||
|
|
@ -197,6 +198,22 @@ int evaluate_position(const GameState *state) {
|
|||
score -= pst_king_mid[63 - sq];
|
||||
}
|
||||
|
||||
// Add randomness to break symmetry in equal positions
|
||||
score += (int)(hash_position(state) % 10) - 5;
|
||||
|
||||
// Encourage piece activity
|
||||
int white_pieces = __builtin_popcountll(state->occ_white);
|
||||
int black_pieces = __builtin_popcountll(state->occ_black);
|
||||
|
||||
// Slight bonus for having pieces in the center
|
||||
U64 center = 0x0000001818000000ULL; // e4, e5, d4, d5
|
||||
U64 extended_center = 0x00003C3C3C3C0000ULL; // c3-f3 to c6-f6
|
||||
|
||||
score += __builtin_popcountll(state->occ_white & center) * 5;
|
||||
score -= __builtin_popcountll(state->occ_black & center) * 5;
|
||||
score += __builtin_popcountll(state->occ_white & extended_center) * 2;
|
||||
score -= __builtin_popcountll(state->occ_black & extended_center) * 2;
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
|
|
@ -204,9 +221,21 @@ int evaluate_position(const GameState *state) {
|
|||
int evaluate(const GameState *state) {
|
||||
int score = evaluate_material(state) + evaluate_position(state);
|
||||
|
||||
// Mobility bonus (simplified)
|
||||
// Mobility bonus
|
||||
GameState temp_state = *state;
|
||||
Move moves[256];
|
||||
|
||||
// Add repetition penalty to avoid draw by repetition everytime
|
||||
U64 current_hash = hash_position(state);
|
||||
for (int i = 0; i < state->history.position_count; i++) {
|
||||
if (state->history.positions[i].hash == current_hash) {
|
||||
if (state->history.positions[i].count >= 2) {
|
||||
score -= 50; // Penalty for positions appearing twice
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
temp_state.side_to_move = 0; // White
|
||||
int white_mobility = generate_moves(&temp_state, moves);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue