Rewrite the entirety of board eval or something idk
Co-authored-by: Tymon <nomyTx@users.noreply.github.com>minimax-pkg
parent
cd79853be0
commit
0790e688ef
@ -1 +1,2 @@
|
||||
/target
|
||||
inkwell-regression-testing
|
@ -1,5 +1,5 @@
|
||||
# 1.666.0-rc
|
||||
- [ ] Ability to evaluate game state (whether it's early/mid/end-game)
|
||||
- [ ] Piece tables
|
||||
- [x] Ability to evaluate game state (whether it's early/mid/end-game)
|
||||
- [x] Piece tables
|
||||
- [ ] Draw prevention (via `chess`'s Game struct?)
|
||||
- [ ] Basic king safety (ie castling when appropriate, not always playing the double triple decker bongcloud)
|
@ -0,0 +1,147 @@
|
||||
// piece tables originally sourced from https://www.talkchess.com/forum3/viewtopic.php?f=2&t=68311&start=19 via https://www.chessprogramming.org/PeSTO%27s_Evaluation_Function
|
||||
|
||||
pub const GAMEPHASE: [f64; 12] = [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const MIDGAME_PAWNS: [f64; 64] = [
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
98.0, 134.0, 61.0, 95.0, 68.0, 126.0, 34.0, -11.0,
|
||||
-6.0, 7.0, 26.0, 31.0, 65.0, 56.0, 25.0, -20.0,
|
||||
-14.0, 13.0, 6.0, 21.0, 23.0, 12.0, 17.0, -23.0,
|
||||
-27.0, -2.0, -5.0, 12.0, 17.0, 6.0, 10.0, -25.0,
|
||||
-26.0, -4.0, -4.0, -10.0, 3.0, 3.0, 33.0, -12.0,
|
||||
-35.0, -1.0, -20.0, -23.0, -15.0, 24.0, 38.0, -22.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const ENDGAME_PAWNS: [f64; 64] = [
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
178.0, 173.0, 158.0, 134.0, 147.0, 132.0, 165.0, 187.0,
|
||||
94.0, 100.0, 85.0, 67.0, 56.0, 53.0, 82.0, 84.0,
|
||||
32.0, 24.0, 13.0, 5.0, -2.0, 4.0, 17.0, 17.0,
|
||||
13.0, 9.0, -3.0, -7.0, -7.0, -8.0, 3.0, -1.0,
|
||||
4.0, 7.0, -6.0, 1.0, 0.0, -5.0, -1.0, -8.0,
|
||||
13.0, 8.0, 8.0, 10.0, 13.0, 0.0, 2.0, -7.0,
|
||||
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const MIDGAME_HORSEYS: [f64; 64] = [
|
||||
-167.0, -89.0, -34.0, -49.0, 61.0, -97.0, -15.0, -107.0,
|
||||
-73.0, -41.0, 72.0, 36.0, 23.0, 62.0, 7.0, -17.0,
|
||||
-47.0, 60.0, 37.0, 65.0, 84.0, 129.0, 73.0, 44.0,
|
||||
-9.0, 17.0, 19.0, 53.0, 37.0, 69.0, 18.0, 22.0,
|
||||
-13.0, 4.0, 16.0, 13.0, 28.0, 19.0, 21.0, -8.0,
|
||||
-23.0, -9.0, 12.0, 10.0, 19.0, 17.0, 25.0, -16.0,
|
||||
-29.0, -53.0, -12.0, -3.0, -1.0, 18.0, -14.0, -19.0,
|
||||
-105.0, -21.0, -58.0, -33.0, -17.0, -28.0, -19.0, -23.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const ENDGAME_HORSEYS: [f64; 64] = [
|
||||
-58.0, -38.0, -13.0, -28.0, -31.0, -27.0, -63.0, -99.0,
|
||||
-25.0, -8.0, -25.0, -2.0, -9.0, -25.0, -24.0, -52.0,
|
||||
-24.0, -20.0, 10.0, 9.0, -1.0, -9.0, -19.0, -41.0,
|
||||
-17.0, 3.0, 22.0, 22.0, 22.0, 11.0, 8.0, -18.0,
|
||||
-18.0, -6.0, 16.0, 25.0, 16.0, 17.0, 4.0, -18.0,
|
||||
-23.0, -3.0, -1.0, 15.0, 10.0, -3.0, -20.0, -22.0,
|
||||
-42.0, -20.0, -10.0, -5.0, -2.0, -20.0, -23.0, -44.0,
|
||||
-29.0, -51.0, -23.0, -15.0, -22.0, -18.0, -50.0, -64.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const MIDGAME_BISHOPS: [f64; 64] = [
|
||||
-29.0, 4.0, -82.0, -37.0, -25.0, -42.0, 7.0, -8.0,
|
||||
-26.0, 16.0, -18.0, -13.0, 30.0, 59.0, 18.0, -47.0,
|
||||
-16.0, 37.0, 43.0, 40.0, 35.0, 50.0, 37.0, -2.0,
|
||||
-4.0, 5.0, 19.0, 50.0, 37.0, 37.0, 7.0, -2.0,
|
||||
-6.0, 13.0, 13.0, 26.0, 34.0, 12.0, 10.0, 4.0,
|
||||
0.0, 15.0, 15.0, 15.0, 14.0, 27.0, 18.0, 10.0,
|
||||
4.0, 15.0, 16.0, 0.0, 7.0, 21.0, 33.0, 1.0,
|
||||
-33.0, -3.0, -14.0, -21.0, -13.0, -12.0, -39.0, -21.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const ENDGAME_BISHOPS: [f64; 64] = [
|
||||
-14.0, -21.0, -11.0, -8.0, -7.0, -9.0, -17.0, -24.0,
|
||||
-8.0, -4.0, 7.0, -12.0, -3.0, -13.0, -4.0, -14.0,
|
||||
2.0, -8.0, 0.0, -1.0, -2.0, 6.0, 0.0, 4.0,
|
||||
-3.0, 9.0, 12.0, 9.0, 14.0, 10.0, 3.0, 2.0,
|
||||
-6.0, 3.0, 13.0, 19.0, 7.0, 10.0, -3.0, -9.0,
|
||||
-12.0, -3.0, 8.0, 10.0, 13.0, 3.0, -7.0, -15.0,
|
||||
-14.0, -18.0, -7.0, -1.0, 4.0, -9.0, -15.0, -27.0,
|
||||
-23.0, -9.0, -23.0, -5.0, -9.0, -16.0, -5.0, -17.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const MIDGAME_ROOKS: [f64; 64] = [
|
||||
32.0, 42.0, 32.0, 51.0, 63.0, 9.0, 31.0, 43.0,
|
||||
27.0, 32.0, 58.0, 62.0, 80.0, 67.0, 26.0, 44.0,
|
||||
-5.0, 19.0, 26.0, 36.0, 17.0, 45.0, 61.0, 16.0,
|
||||
-24.0, -11.0, 7.0, 26.0, 24.0, 35.0, -8.0, -20.0,
|
||||
-36.0, -26.0, -12.0, -1.0, 9.0, -7.0, 6.0, -23.0,
|
||||
-45.0, -25.0, -16.0, -17.0, 3.0, 0.0, -5.0, -33.0,
|
||||
-44.0, -16.0, -20.0, -9.0, -1.0, 11.0, -6.0, -71.0,
|
||||
-19.0, -13.0, 1.0, 17.0, 16.0, 7.0, -37.0, -26.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const ENDGAME_ROOKS: [f64; 64] = [
|
||||
13.0, 10.0, 18.0, 15.0, 12.0, 12.0, 8.0, 5.0,
|
||||
11.0, 13.0, 13.0, 11.0, -3.0, 3.0, 8.0, 3.0,
|
||||
7.0, 7.0, 7.0, 5.0, 4.0, -3.0, -5.0, -3.0,
|
||||
4.0, 3.0, 13.0, 1.0, 2.0, 1.0, -1.0, 2.0,
|
||||
3.0, 5.0, 8.0, 4.0, -5.0, -6.0, -8.0, -11.0,
|
||||
-4.0, 0.0, -5.0, -1.0, -7.0, -12.0, -8.0, -16.0,
|
||||
-6.0, -6.0, 0.0, 2.0, -9.0, -9.0, -11.0, -3.0,
|
||||
-9.0, 2.0, 3.0, -1.0, -5.0, -13.0, 4.0, -20.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const MIDGAME_QUEENS: [f64; 64] = [
|
||||
-28.0, 0.0, 29.0, 12.0, 59.0, 44.0, 43.0, 45.0,
|
||||
-24.0, -39.0, -5.0, 1.0, -16.0, 57.0, 28.0, 54.0,
|
||||
-13.0, -17.0, 7.0, 8.0, 29.0, 56.0, 47.0, 57.0,
|
||||
-27.0, -27.0, -16.0, -16.0, -1.0, 17.0, -2.0, 1.0,
|
||||
-9.0, -26.0, -9.0, -10.0, -2.0, -4.0, 3.0, -3.0,
|
||||
-14.0, 2.0, -11.0, -2.0, -5.0, 2.0, 14.0, 5.0,
|
||||
-35.0, -8.0, 11.0, 2.0, 8.0, 15.0, -3.0, 1.0,
|
||||
-1.0, -18.0, -9.0, 10.0, -15.0, -25.0, -31.0, -50.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const ENDGAME_QUEENS: [f64; 64] = [
|
||||
-9.0, 22.0, 22.0, 27.0, 27.0, 19.0, 10.0, 20.0,
|
||||
-17.0, 20.0, 32.0, 41.0, 58.0, 25.0, 30.0, 0.0,
|
||||
-20.0, 6.0, 9.0, 49.0, 47.0, 35.0, 19.0, 9.0,
|
||||
3.0, 22.0, 24.0, 45.0, 57.0, 40.0, 57.0, 36.0,
|
||||
-18.0, 28.0, 19.0, 47.0, 31.0, 34.0, 39.0, 23.0,
|
||||
-16.0, -27.0, 15.0, 6.0, 9.0, 17.0, 10.0, 5.0,
|
||||
-22.0, -23.0, -30.0, -16.0, -16.0, -23.0, -36.0, -32.0,
|
||||
-33.0, -28.0, -22.0, -43.0, -5.0, -32.0, -20.0, -41.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const MIDGAME_KINGS: [f64; 64] = [
|
||||
-65.0, 23.0, 16.0, -15.0, -56.0, -34.0, 2.0, 13.0,
|
||||
29.0, -1.0, -20.0, -7.0, -8.0, -4.0, -38.0, -29.0,
|
||||
-9.0, 24.0, 2.0, -16.0, -20.0, 6.0, 22.0, -22.0,
|
||||
-17.0, -20.0, -12.0, -27.0, -30.0, -25.0, -14.0, -36.0,
|
||||
-49.0, -1.0, -27.0, -39.0, -46.0, -44.0, -33.0, -51.0,
|
||||
-14.0, -14.0, -22.0, -46.0, -44.0, -30.0, -15.0, -27.0,
|
||||
1.0, 7.0, -8.0, -64.0, -43.0, -16.0, 9.0, 8.0,
|
||||
-15.0, 36.0, 12.0, -54.0, 8.0, -28.0, 24.0, 14.0,
|
||||
];
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const ENDGAME_KINGS: [f64; 64] = [
|
||||
-74.0, -35.0, -18.0, -18.0, -11.0, 15.0, 4.0, -17.0,
|
||||
-12.0, 17.0, 14.0, 17.0, 17.0, 38.0, 23.0, 11.0,
|
||||
10.0, 17.0, 23.0, 15.0, 20.0, 45.0, 44.0, 13.0,
|
||||
-8.0, 22.0, 24.0, 27.0, 26.0, 33.0, 26.0, 3.0,
|
||||
-18.0, -4.0, 21.0, 24.0, 27.0, 23.0, 9.0, -11.0,
|
||||
-19.0, -3.0, 11.0, 21.0, 23.0, 16.0, 7.0, -9.0,
|
||||
-27.0, -11.0, 4.0, 13.0, 14.0, 4.0, -5.0, -17.0,
|
||||
-53.0, -34.0, -21.0, -11.0, -28.0, -14.0, -24.0, -43.0,
|
||||
];
|
@ -0,0 +1,22 @@
|
||||
use chess::Piece;
|
||||
|
||||
pub const PAWN: f64 = 1.0;
|
||||
|
||||
pub const HORSEY: f64 = 3.0;
|
||||
|
||||
pub const BISHOP: f64 = 5.0;
|
||||
|
||||
pub const ROOK: f64 = 5.5;
|
||||
|
||||
pub const QUEEN: f64 = 10.0;
|
||||
|
||||
pub fn get_piece_value(piece: Option<Piece>) -> f64 {
|
||||
match piece {
|
||||
Some(Piece::Pawn) => PAWN,
|
||||
Some(Piece::Knight) => HORSEY,
|
||||
Some(Piece::Bishop) => BISHOP,
|
||||
Some(Piece::Rook) => ROOK,
|
||||
Some(Piece::Queen) => QUEEN,
|
||||
_ => 0.0,
|
||||
}
|
||||
}
|
Loading…
Reference in new issue