Skip to content

Commit d2b06b5

Browse files
fix: broken unit tests
bench: 1740232
1 parent ebda7bd commit d2b06b5

File tree

3 files changed

+18
-38
lines changed

3 files changed

+18
-38
lines changed

engine/src/evaluation.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: Thursday, November 21st 2024
55
* Author: Paul Tsouchlos (DeveloperPaul123) ([email protected])
66
* -----
7-
* Last Modified: Tue Mar 18 2025
7+
* Last Modified: Mon Mar 24 2025
88
* -----
99
* Copyright (c) 2024 Paul Tsouchlos (DeveloperPaul123)
1010
* GNU General Public License v3.0 or later
@@ -15,10 +15,9 @@
1515
use chess::{bitboard_helpers, board::Board, moves::Move, pieces::Piece, side::Side};
1616

1717
use crate::{
18-
hce_values::{ByteKnightValues, GAME_PHASE_MAX},
18+
hce_values::{ByteKnightValues, GAME_PHASE_MAX, GAMEPHASE_INC},
1919
history_table,
2020
phased_score::{PhaseType, PhasedScore},
21-
psqt::GAMEPHASE_INC,
2221
score::{LargeScoreType, Score, ScoreType},
2322
traits::{Eval, EvalValues},
2423
ttable::TranspositionTableEntry,
@@ -228,7 +227,7 @@ mod tests {
228227

229228
#[test]
230229
fn score_stability() {
231-
// These values were determined empirically by running this test and manually copy/pasting the results
230+
// These values were determined empirically by running this test and manually copy/pasting the results.
232231
// If any changes are made to the evaluation function, these values will need to be updated or the test will need to be augmented with the new evaluation values.
233232

234233
// standard EPD suite FEN positions
@@ -364,13 +363,13 @@ mod tests {
364363
];
365364

366365
let scores: [ScoreType; 128] = [
367-
0, 56, 488, 499, -488, -499, 980, -980, 445, 458, -445, -458, 0, 9, 14, 12, -9, -14,
368-
-12, -488, -499, 488, 499, -980, 980, -445, -458, 445, 458, 0, -9, -14, -12, 9, 14, 12,
369-
2, 1, 0, -342, 406, -2, -1, 3, 342, -406, 0, -29, 634, -628, 25, 29, -634, 628, 0, -1,
370-
0, 1, -925, -990, -77, 929, -990, 77, 162, 95, -162, -95, 69, -162, -95, 162, 95, -69,
371-
59, 59, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -2, -27, 7, 4, 7, -4, -7, -169, 9, 27, -7, -4,
372-
-7, 4, 7, 169, -9, -4, 3, 4, -3, 9, -9, 0, 4, -3, -4, 3, -9, 9, 0, -3, 15, 26, 42, 3,
373-
-15, -26, -42, 37, 53,
366+
0, 34, 589, 597, -589, -597, 1142, -1142, 512, 538, -512, -538, 0, 7, 15, 12, -7, -15,
367+
-12, -589, -597, 589, 597, -1142, 1142, -512, -538, 512, 538, 0, -7, -15, -12, 7, 15,
368+
12, 2, 0, 0, -397, 476, -2, 0, 5, 397, -476, -22, -43, 718, -744, 27, 43, -718, 744, 0,
369+
-6, 0, 6, -1094, -1192, -37, 1072, -1192, 37, 204, 222, -204, -222, 90, -204, -222,
370+
204, 222, -90, 23, 23, 0, 0, 0, 15, -15, -13, 0, 0, 0, -15, 15, 13, -15, 15, 8, 9, -8,
371+
-9, -214, -7, 15, -15, -8, -9, 8, 9, 214, 7, -3, 2, 3, -2, 7, -7, 0, 3, -2, -3, 2, -7,
372+
7, 0, -11, 9, 31, 53, 11, -9, -31, -53, 41, 25,
374373
];
375374

376375
let eval = ByteKnightEvaluation::default();

engine/src/hce_values.rs

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ use chess::{
77

88
use crate::{
99
phased_score::{PhasedScore, S},
10+
score::ScoreType,
1011
traits::EvalValues,
1112
};
1213

14+
/// Game phase increment for each piece
15+
/// Ordered to match the indexing of [`Piece`]
16+
/// King, Queen, Rook, Bishop, Knight, Pawn
17+
pub const GAMEPHASE_INC: [ScoreType; 6] = [0, 4, 2, 1, 1, 0];
18+
19+
/// Maximum game phase
1320
pub const GAME_PHASE_MAX: i32 = 24;
1421

1522
/// Piece-Square Tables, ordered by the ordinality of the pieces. See ['pieces::Piece']
@@ -93,29 +100,3 @@ impl EvalValues for ByteKnightValues {
93100
PSQTS[piece as usize][square::flip_if(side == Side::White, square) as usize]
94101
}
95102
}
96-
97-
#[cfg(test)]
98-
mod tests {
99-
use chess::board::Board;
100-
101-
use super::*;
102-
use crate::{evaluation::Evaluation, psqt::Psqt, traits::Eval};
103-
104-
#[test]
105-
fn verify_values_match_pesto() {
106-
let values = ByteKnightValues::default();
107-
let eval = Evaluation::new(values);
108-
109-
let psqt = Psqt::new();
110-
111-
let board =
112-
Board::from_fen("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1")
113-
.unwrap();
114-
115-
let score = psqt.evaluate(&board);
116-
println!("{}", score);
117-
let new_eval_score = eval.eval(&board);
118-
println!("{}", new_eval_score);
119-
assert_eq!(score, new_eval_score);
120-
}
121-
}

src/bin/hce-tuner/epd_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55

66
use anyhow::{Result, anyhow};
77
use chess::{bitboard_helpers, board::Board, pieces::Piece, side::Side};
8-
use engine::{hce_values::GAME_PHASE_MAX, psqt::GAMEPHASE_INC};
8+
use engine::{hce_values::GAME_PHASE_MAX, hce_values::GAMEPHASE_INC};
99

1010
use crate::{offsets::Offsets, tuning_position::TuningPosition};
1111

0 commit comments

Comments
 (0)