i don't even know

minimax-pkg
Drake 12 months ago
parent a2dfb8b6c8
commit 607fc63f4f

Binary file not shown.

Binary file not shown.

@ -20,4 +20,4 @@ pub const INFO: Info = Info {
};
// FIXME: this needs to be configurable via UCI
pub const DEPTH: u8 = 7;
pub const DEFAULT_DEPTH: u8 = 7;

@ -53,52 +53,52 @@ fn square_to_index(square: Square, playing_as: Color) -> usize {
idx
}
fn evaluate_piece_square(board: ChessBoard, square: Square, playing_as: Color) -> (f64, f64, f64) {
let mut mg_value: f64 = 0.0;
let mut eg_value: f64 = 0.0;
let mut gamephase: f64 = 0.0;
fn evaluate_piece_square(board: ChessBoard, square: Square, playing_as: Color) -> (i16, i16, i16) {
let mut mg_value: i16 = 0;
let mut eg_value: i16 = 0;
let mut gamephase: i16 = 0;
let piece = board.piece_on(square);
match piece {
Some(Piece::Pawn) => {
mg_value += get_piece_value(piece)
+ (piece_tables::MIDGAME_PAWNS[square_to_index(square, playing_as)] / 10.0);
+ (piece_tables::MIDGAME_PAWNS[square_to_index(square, playing_as)]);
eg_value += get_piece_value(piece)
+ (piece_tables::ENDGAME_PAWNS[square_to_index(square, playing_as)] / 10.0);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece).floor() as usize];
+ (piece_tables::ENDGAME_PAWNS[square_to_index(square, playing_as)]);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece) as usize];
}
Some(Piece::Knight) => {
mg_value += get_piece_value(piece)
+ (piece_tables::MIDGAME_HORSEYS[square_to_index(square, playing_as)] / 10.0);
+ (piece_tables::MIDGAME_HORSEYS[square_to_index(square, playing_as)]);
eg_value += get_piece_value(piece)
+ (piece_tables::ENDGAME_HORSEYS[square_to_index(square, playing_as)] / 10.0);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece).floor() as usize];
+ (piece_tables::ENDGAME_HORSEYS[square_to_index(square, playing_as)]);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece) as usize];
}
Some(Piece::Bishop) => {
mg_value += get_piece_value(piece)
+ (piece_tables::MIDGAME_BISHOPS[square_to_index(square, playing_as)] / 10.0);
+ (piece_tables::MIDGAME_BISHOPS[square_to_index(square, playing_as)]);
eg_value += get_piece_value(piece)
+ (piece_tables::ENDGAME_BISHOPS[square_to_index(square, playing_as)] / 10.0);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece).floor() as usize];
+ (piece_tables::ENDGAME_BISHOPS[square_to_index(square, playing_as)]);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece) as usize];
}
Some(Piece::Rook) => {
mg_value += get_piece_value(piece)
+ (piece_tables::MIDGAME_ROOKS[square_to_index(square, playing_as)] / 10.0);
+ (piece_tables::MIDGAME_ROOKS[square_to_index(square, playing_as)]);
eg_value += get_piece_value(piece)
+ (piece_tables::ENDGAME_ROOKS[square_to_index(square, playing_as)] / 10.0);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece).floor() as usize];
+ (piece_tables::ENDGAME_ROOKS[square_to_index(square, playing_as)]);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece) as usize];
}
Some(Piece::Queen) => {
mg_value += get_piece_value(piece)
+ (piece_tables::MIDGAME_QUEENS[square_to_index(square, playing_as)] / 10.0);
+ (piece_tables::MIDGAME_QUEENS[square_to_index(square, playing_as)]);
eg_value += get_piece_value(piece)
+ (piece_tables::ENDGAME_QUEENS[square_to_index(square, playing_as)] / 10.0);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece).floor() as usize];
+ (piece_tables::ENDGAME_QUEENS[square_to_index(square, playing_as)]);
gamephase += piece_tables::GAMEPHASE[get_piece_value(piece) as usize];
}
Some(Piece::King) => {
mg_value += piece_tables::MIDGAME_KINGS[square_to_index(square, playing_as)] / 10.0;
eg_value += piece_tables::ENDGAME_KINGS[square_to_index(square, playing_as)] / 10.0;
mg_value += piece_tables::MIDGAME_KINGS[square_to_index(square, playing_as)];
eg_value += piece_tables::ENDGAME_KINGS[square_to_index(square, playing_as)];
}
None => {}
}
@ -111,13 +111,13 @@ fn static_board_eval(
playing_as: Color,
move_history: Vec<ChessBoard>,
last_move: ChessMove,
) -> f64 {
) -> i16 {
// basic material counting + midgame or endgame determination
let mut our_mg_value: f64 = 0.0;
let mut our_eg_value: f64 = 0.0;
let mut opponent_mg_value: f64 = 0.0;
let mut opponent_eg_value: f64 = 0.0;
let mut gamephase: f64 = 0.0;
let mut our_mg_value: i16 = 0;
let mut our_eg_value: i16 = 0;
let mut opponent_mg_value: i16 = 0;
let mut opponent_eg_value: i16 = 0;
let mut gamephase: i16 = 0;
board.color_combined(playing_as).for_each(|square| {
let tmp_gamephase;
@ -135,9 +135,9 @@ fn static_board_eval(
let mg_score = our_mg_value - opponent_mg_value;
let eg_score = our_eg_value - opponent_eg_value;
let mg_phase = gamephase.min(24.0);
let eg_phase = 24.0 - mg_phase;
let mut current_eval = (mg_score * mg_phase + eg_score * eg_phase) / 24.0;
let mg_phase = gamephase.min(24);
let eg_phase = 24 - mg_phase;
let mut current_eval = (mg_score * mg_phase + eg_score * eg_phase) / 24 / 5;
// checking heuristic
let mut are_we_in_check = false;
@ -147,10 +147,10 @@ fn static_board_eval(
.filter(|sq| board.color_on(*sq).unwrap() == playing_as)
.for_each(|_| {
if !are_we_in_check {
current_eval -= 66.6;
current_eval -= 10;
are_we_in_check = true;
} else {
current_eval -= 12.5;
current_eval -= 7;
}
});
board
@ -158,24 +158,13 @@ fn static_board_eval(
.filter(|sq| board.color_on(*sq).unwrap() == !playing_as)
.for_each(|_| {
if !is_opponent_in_check && move_history.len() > 10 {
current_eval += 5.0;
current_eval += 5;
is_opponent_in_check = true;
} else {
current_eval += 3.5;
current_eval += 3;
}
});
// ripoff quiescence search except way worse (makes eval go down if opossing side can make any captures on the next move)
let iter = MoveGen::new_legal(&board);
if board.side_to_move() != playing_as {
for mov in iter {
if let Some(_) = board.piece_on(mov.get_dest()) {
current_eval -= 10.0;
break;
}
}
}
current_eval
}
@ -234,6 +223,15 @@ impl minimax::Evaluator for Evaluator {
b.current_board.side_to_move(),
b.board_history.clone(),
b.last_move.clone(),
) as i16
)
}
fn generate_noisy_moves(&self, state: &Board, moves: &mut Vec<<Self::G as minimax::Game>::M>) {
let iter = MoveGen::new_legal(&state.current_board);
for mov in iter {
if let Some(_) = state.current_board.piece_on(mov.get_dest()) {
moves.push(mov)
}
}
}
}

@ -9,34 +9,62 @@ use eval::{Board as EvalBoard, Evaluator};
use minimax::{IterativeOptions, ParallelOptions, ParallelSearch, Strategy};
use std::io::{self, BufRead};
use std::process;
use std::str::FromStr;
use std::{process, unimplemented};
use vampirc_uci::parse_one;
use vampirc_uci::{UciMessage, UciOptionConfig, UciTimeControl};
use crate::config::DEPTH;
use crate::config::DEFAULT_DEPTH;
struct Options {
pub en_passant: bool,
pub depth: i64,
}
fn main() {
let mut board: Option<Board> = None;
let mut move_history: Vec<Board> = vec![];
let mut options: Options = Options {
en_passant: false,
depth: DEFAULT_DEPTH.into(),
};
for line in io::stdin().lock().lines() {
let msg: UciMessage = parse_one(&line.unwrap());
match msg {
UciMessage::Uci => {
println!(
"{}\n{}\n{}",
"{}\n{}\n{}\n{}",
UciMessage::Id {
name: Some(INFO.to_name()),
author: Some(INFO.to_author())
},
UciMessage::Option(UciOptionConfig::Check {
name: "EnPassant".to_owned(),
default: Some(false)
default: Some(options.en_passant)
}),
UciMessage::Option(UciOptionConfig::Spin {
name: "Depth".to_owned(),
default: Some(options.depth),
min: Some(0),
max: None
}),
UciMessage::UciOk {}
)
}
UciMessage::SetOption { name, value } => match name.as_str() {
"EnPassant" => {
options.en_passant = match value.as_deref().unwrap_or_default() {
"true" => true,
"false" => false,
_ => options.en_passant,
}
}
"Depth" => {
options.depth = value.unwrap_or_default().parse().unwrap_or(options.depth)
}
_ => unimplemented!(),
},
UciMessage::IsReady => {
println!("{}", UciMessage::ReadyOk)
}
@ -96,11 +124,18 @@ fn main() {
if let Some(board) = board {
let mut strat = ParallelSearch::new(
Evaluator::default(),
IterativeOptions::new().verbose(),
IterativeOptions::new()
.verbose()
.with_null_window_search(true)
.with_countermoves()
.with_countermove_history()
.with_singular_extension()
.with_quiescence_search_depth(2)
.with_table_byte_size(8 * 1024 * 1024 * 1024),
ParallelOptions::new().with_background_pondering(),
);
strat.set_max_depth(DEPTH);
strat.set_max_depth(DEFAULT_DEPTH);
let mov = strat
.choose_move(&EvalBoard {
current_board: board,

@ -1,147 +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];
pub const GAMEPHASE: [i16; 12] = [0, 0, 1, 1, 1, 1, 2, 2, 4, 4, 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,
pub const MIDGAME_PAWNS: [i16; 64] = [
0, 0, 0, 0, 0, 0, 0, 0,
98, 134, 61, 95, 68, 126, 34, -11,
-6, 7, 26, 31, 65, 56, 25, -20,
-14, 13, 6, 21, 23, 12, 17, -23,
-27, -2, -5, 12, 17, 6, 10, -25,
-26, -4, -4, -10, 3, 3, 33, -12,
-35, -1, -20, -23, -15, 24, 38, -22,
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,
pub const ENDGAME_PAWNS: [i16; 64] = [
0, 0, 0, 0, 0, 0, 0, 0,
178, 173, 158, 134, 147, 132, 165, 187,
94, 100, 85, 67, 56, 53, 82, 84,
32, 24, 13, 5, -2, 4, 17, 17,
13, 9, -3, -7, -7, -8, 3, -1,
4, 7, -6, 1, 0, -5, -1, -8,
13, 8, 8, 10, 13, 0, 2, -7,
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,
pub const MIDGAME_HORSEYS: [i16; 64] = [
-167, -89, -34, -49, 61, -97, -15, -107,
-73, -41, 72, 36, 23, 62, 7, -17,
-47, 60, 37, 65, 84, 129, 73, 44,
-9, 17, 19, 53, 37, 69, 18, 22,
-13, 4, 16, 13, 28, 19, 21, -8,
-23, -9, 12, 10, 19, 17, 25, -16,
-29, -53, -12, -3, -1, 18, -14, -19,
-105, -21, -58, -33, -17, -28, -19, -23,
];
#[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,
pub const ENDGAME_HORSEYS: [i16; 64] = [
-58, -38, -13, -28, -31, -27, -63, -99,
-25, -8, -25, -2, -9, -25, -24, -52,
-24, -20, 10, 9, -1, -9, -19, -41,
-17, 3, 22, 22, 22, 11, 8, -18,
-18, -6, 16, 25, 16, 17, 4, -18,
-23, -3, -1, 15, 10, -3, -20, -22,
-42, -20, -10, -5, -2, -20, -23, -44,
-29, -51, -23, -15, -22, -18, -50, -64,
];
#[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,
pub const MIDGAME_BISHOPS: [i16; 64] = [
-29, 4, -82, -37, -25, -42, 7, -8,
-26, 16, -18, -13, 30, 59, 18, -47,
-16, 37, 43, 40, 35, 50, 37, -2,
-4, 5, 19, 50, 37, 37, 7, -2,
-6, 13, 13, 26, 34, 12, 10, 4,
0, 15, 15, 15, 14, 27, 18, 10,
4, 15, 16, 0, 7, 21, 33, 1,
-33, -3, -14, -21, -13, -12, -39, -21,
];
#[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,
pub const ENDGAME_BISHOPS: [i16; 64] = [
-14, -21, -11, -8, -7, -9, -17, -24,
-8, -4, 7, -12, -3, -13, -4, -14,
2, -8, 0, -1, -2, 6, 0, 4,
-3, 9, 12, 9, 14, 10, 3, 2,
-6, 3, 13, 19, 7, 10, -3, -9,
-12, -3, 8, 10, 13, 3, -7, -15,
-14, -18, -7, -1, 4, -9, -15, -27,
-23, -9, -23, -5, -9, -16, -5, -17,
];
#[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,
pub const MIDGAME_ROOKS: [i16; 64] = [
32, 42, 32, 51, 63, 9, 31, 43,
27, 32, 58, 62, 80, 67, 26, 44,
-5, 19, 26, 36, 17, 45, 61, 16,
-24, -11, 7, 26, 24, 35, -8, -20,
-36, -26, -12, -1, 9, -7, 6, -23,
-45, -25, -16, -17, 3, 0, -5, -33,
-44, -16, -20, -9, -1, 11, -6, -71,
-19, -13, 1, 17, 16, 7, -37, -26,
];
#[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,
pub const ENDGAME_ROOKS: [i16; 64] = [
13, 10, 18, 15, 12, 12, 8, 5,
11, 13, 13, 11, -3, 3, 8, 3,
7, 7, 7, 5, 4, -3, -5, -3,
4, 3, 13, 1, 2, 1, -1, 2,
3, 5, 8, 4, -5, -6, -8, -11,
-4, 0, -5, -1, -7, -12, -8, -16,
-6, -6, 0, 2, -9, -9, -11, -3,
-9, 2, 3, -1, -5, -13, 4, -20,
];
#[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,
pub const MIDGAME_QUEENS: [i16; 64] = [
-28, 0, 29, 12, 59, 44, 43, 45,
-24, -39, -5, 1, -16, 57, 28, 54,
-13, -17, 7, 8, 29, 56, 47, 57,
-27, -27, -16, -16, -1, 17, -2, 1,
-9, -26, -9, -10, -2, -4, 3, -3,
-14, 2, -11, -2, -5, 2, 14, 5,
-35, -8, 11, 2, 8, 15, -3, 1,
-1, -18, -9, 10, -15, -25, -31, -50,
];
#[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,
pub const ENDGAME_QUEENS: [i16; 64] = [
-9, 22, 22, 27, 27, 19, 10, 20,
-17, 20, 32, 41, 58, 25, 30, 0,
-20, 6, 9, 49, 47, 35, 19, 9,
3, 22, 24, 45, 57, 40, 57, 36,
-18, 28, 19, 47, 31, 34, 39, 23,
-16, -27, 15, 6, 9, 17, 10, 5,
-22, -23, -30, -16, -16, -23, -36, -32,
-33, -28, -22, -43, -5, -32, -20, -41,
];
#[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,
pub const MIDGAME_KINGS: [i16; 64] = [
-65, 23, 16, -15, -56, -34, 2, 13,
29, -1, -20, -7, -8, -4, -38, -29,
-9, 24, 2, -16, -20, 6, 22, -22,
-17, -20, -12, -27, -30, -25, -14, -36,
-49, -1, -27, -39, -46, -44, -33, -51,
-14, -14, -22, -46, -44, -30, -15, -27,
1, 7, -8, -64, -43, -16, 9, 8,
-15, 36, 12, -54, 8, -28, 24, 14,
];
#[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,
pub const ENDGAME_KINGS: [i16; 64] = [
-74, -35, -18, -18, -11, 15, 4, -17,
-12, 17, 14, 17, 17, 38, 23, 11,
10, 17, 23, 15, 20, 45, 44, 13,
-8, 22, 24, 27, 26, 33, 26, 3,
-18, -4, 21, 24, 27, 23, 9, -11,
-19, -3, 11, 21, 23, 16, 7, -9,
-27, -11, 4, 13, 14, 4, -5, -17,
-53, -34, -21, -11, -28, -14, -24, -43,
];

@ -1,22 +1,22 @@
use chess::Piece;
pub const PAWN: f64 = 1.0;
pub const PAWN: i16 = 1;
pub const HORSEY: f64 = 3.0;
pub const HORSEY: i16 = 3;
pub const BISHOP: f64 = 5.0;
pub const BISHOP: i16 = 5;
pub const ROOK: f64 = 5.5;
pub const ROOK: i16 = 5;
pub const QUEEN: f64 = 10.0;
pub const QUEEN: i16 = 10;
pub fn get_piece_value(piece: Option<Piece>) -> f64 {
pub fn get_piece_value(piece: Option<Piece>) -> i16 {
match piece {
Some(Piece::Pawn) => PAWN,
Some(Piece::Knight) => HORSEY,
Some(Piece::Bishop) => BISHOP,
Some(Piece::Rook) => ROOK,
Some(Piece::Queen) => QUEEN,
_ => 0.0,
_ => 0,
}
}

Loading…
Cancel
Save