minimax-pkg
Drake 1 year ago
parent 4ad9875c01
commit a2dfb8b6c8

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

@ -106,7 +106,12 @@ fn evaluate_piece_square(board: ChessBoard, square: Square, playing_as: Color) -
(mg_value, eg_value, gamephase)
}
fn static_board_eval(board: ChessBoard, playing_as: Color, move_history: Vec<ChessBoard>) -> f64 {
fn static_board_eval(
board: ChessBoard,
playing_as: Color,
move_history: Vec<ChessBoard>,
last_move: ChessMove,
) -> f64 {
// basic material counting + midgame or endgame determination
let mut our_mg_value: f64 = 0.0;
let mut our_eg_value: f64 = 0.0;
@ -160,21 +165,17 @@ fn static_board_eval(board: ChessBoard, playing_as: Color, move_history: Vec<Che
}
});
/* // deprioritize king movement
if board.piece_on(mov.get_source()).unwrap_or(Piece::Pawn) == Piece::King && !are_we_in_check {
current_eval -= 12.5;
// 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;
}
}
}
// incentivize capturing if material value of capturer is lower than material value of captured
// FIXME: this should take into account whether a piece is protected at all (and if so let pieces be captured by ones of equal and above importance)
if let (Some(captured_piece), Some(capturing_piece)) = (
old_board.piece_on(mov.get_dest()),
old_board.piece_on(mov.get_source()),
) {
current_eval +=
(get_piece_value(Some(captured_piece)) - get_piece_value(Some(capturing_piece)))
} */
current_eval
}
@ -182,6 +183,7 @@ fn static_board_eval(board: ChessBoard, playing_as: Color, move_history: Vec<Che
pub struct Board {
pub current_board: ChessBoard,
pub board_history: Vec<ChessBoard>,
pub last_move: ChessMove,
}
pub struct Game;
@ -211,6 +213,7 @@ impl minimax::Game for Game {
Some(Board {
current_board: b.current_board.make_move_new(m),
board_history: new_board_history,
last_move: m,
})
}
@ -230,6 +233,7 @@ impl minimax::Evaluator for Evaluator {
b.current_board,
b.current_board.side_to_move(),
b.board_history.clone(),
b.last_move.clone(),
) as i16
}
}

@ -105,6 +105,7 @@ fn main() {
.choose_move(&EvalBoard {
current_board: board,
board_history: move_history.clone(),
last_move: Default::default(),
})
.unwrap();

Loading…
Cancel
Save