|
@@ -16,7 +16,7 @@ enum MoveUndo {
|
|
Promotion {
|
|
Promotion {
|
|
promoted_to: PieceType,
|
|
promoted_to: PieceType,
|
|
promoted_to_before: Bitboard,
|
|
promoted_to_before: Bitboard,
|
|
-
|
|
|
|
|
|
+ pawns_before: Bitboard
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -59,14 +59,15 @@ pub fn search(game: &Game, depth: i32) -> (Move, SearchInfo) {
|
|
|
|
|
|
let mut valued_moves = moves.iter().map(|mov| {
|
|
let mut valued_moves = moves.iter().map(|mov| {
|
|
let new_game = apply_move(game, *mov);
|
|
let new_game = apply_move(game, *mov);
|
|
|
|
+ //info!("searching {}", mov.to_string());
|
|
let val = -negamax(&new_game, &mut si, -beta, -alpha, depth - 1);
|
|
let val = -negamax(&new_game, &mut si, -beta, -alpha, depth - 1);
|
|
|
|
+ info!("searched {} -> {}", mov.to_string(), val);
|
|
|
|
|
|
if val > alpha {
|
|
if val > alpha {
|
|
alpha = val - ALPHA_OFFSET;
|
|
alpha = val - ALPHA_OFFSET;
|
|
//info!("updated alpha to {}", alpha);
|
|
//info!("updated alpha to {}", alpha);
|
|
}
|
|
}
|
|
|
|
|
|
- info!("searched {} = {}", mov.to_string(), val);
|
|
|
|
(*mov, -val)
|
|
(*mov, -val)
|
|
}).collect::<Vec<(Move, i32)>>();
|
|
}).collect::<Vec<(Move, i32)>>();
|
|
//info!("movvalues: {:?}", valued_moves.iter().map(|mv| mv.0.to_string() + " - " + &mv.1.to_string()).collect::<Vec<String>>());
|
|
//info!("movvalues: {:?}", valued_moves.iter().map(|mv| mv.0.to_string() + " - " + &mv.1.to_string()).collect::<Vec<String>>());
|
|
@@ -89,7 +90,7 @@ pub fn search(game: &Game, depth: i32) -> (Move, SearchInfo) {
|
|
|
|
|
|
fn negamax(game: &Game, si: &mut SearchInfo, mut alpha: i32, beta: i32, depth: i32) -> i32 {
|
|
fn negamax(game: &Game, si: &mut SearchInfo, mut alpha: i32, beta: i32, depth: i32) -> i32 {
|
|
if depth == 0 {
|
|
if depth == 0 {
|
|
- return quiescence_search(game, si, alpha, beta, 15);
|
|
|
|
|
|
+ return quiescence_search(game, si, alpha, beta, 7);
|
|
let eval = evaluate(game);
|
|
let eval = evaluate(game);
|
|
if eval != 0 {
|
|
if eval != 0 {
|
|
//info!("eval: {}", eval);
|
|
//info!("eval: {}", eval);
|
|
@@ -107,7 +108,7 @@ fn negamax(game: &Game, si: &mut SearchInfo, mut alpha: i32, beta: i32, depth: i
|
|
|
|
|
|
if game.get_piece(KING, game.turn) == 0 { return MIN_VALUE; }
|
|
if game.get_piece(KING, game.turn) == 0 { return MIN_VALUE; }
|
|
|
|
|
|
- let moves = generate_moves(game, game.turn);
|
|
|
|
|
|
+ let moves = generate_legal_moves(game, game.turn);
|
|
|
|
|
|
if moves.len() == 0 {
|
|
if moves.len() == 0 {
|
|
if is_check(game, game.turn) {
|
|
if is_check(game, game.turn) {
|
|
@@ -172,6 +173,16 @@ fn quiescence_search(game: &Game, si: &mut SearchInfo, mut alpha: i32, beta: i32
|
|
return alpha;
|
|
return alpha;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+pub fn apply(game: &mut Game, mov: Move) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+pub fn undo(game: &mut Game, mov: Move) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
pub fn apply_move(game: &Game, mov: Move) -> Game {
|
|
pub fn apply_move(game: &Game, mov: Move) -> Game {
|
|
let mut new_game = game.clone();
|
|
let mut new_game = game.clone();
|
|
|
|
|