|
@@ -3,7 +3,6 @@ use bitboard::Square;
|
|
|
use bitboard::*;
|
|
|
use game::Game;
|
|
|
use hash::Cache;
|
|
|
-use log::info;
|
|
|
|
|
|
pub type Side = bool;
|
|
|
|
|
@@ -199,24 +198,19 @@ pub fn generate_attacking_moves(game: &Game, side: Side) -> Vec<Move> {
|
|
|
}
|
|
|
|
|
|
|
|
|
-pub fn sort_moves(game: &Game, hash: &mut Cache, move_list: &mut Vec<Move>) {
|
|
|
- let all_pieces = game.get_all_side(WHITE) | game.get_all_side(BLACK);
|
|
|
+pub fn sort_moves(game: &mut Game, hash: &mut Cache, move_list: &mut Vec<Move>) {
|
|
|
|
|
|
move_list.sort_by_cached_key(|mov| {
|
|
|
- let new_game = crate::search::apply_move(game, *mov);
|
|
|
- if let Some(e) = hash.lookup(&new_game) {
|
|
|
+
|
|
|
+ let undo = game.apply(*mov);
|
|
|
+ if let Some(e) = hash.lookup(game) {
|
|
|
+ game.undo_move(undo);
|
|
|
return e.value;
|
|
|
}
|
|
|
else {
|
|
|
- return crate::evaluate::evaluate(&new_game);
|
|
|
- }
|
|
|
-
|
|
|
- match mov {
|
|
|
- Move::Default { mov, piece_type: _, captured } => if let None = captured { 0 } else { -10 }, //if (from_square(mov.to) & all_pieces) != 0 { -10 } else { 0 },
|
|
|
- Move::Castling { side: _, left: _ } => 0,
|
|
|
- Move::Promotion { mov: _, promote_to: _, captured: _ } => -15,
|
|
|
- Move::EnPassant { mov: _, beaten: _ } => -10,
|
|
|
- Move::Nullmove => 0,
|
|
|
+ let eval = crate::evaluate::evaluate(game);
|
|
|
+ game.undo_move(undo);
|
|
|
+ return eval;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -328,7 +322,7 @@ fn generate_promotions(game: &Game, side: Side, move_list: &mut Vec<Move>) {
|
|
|
|
|
|
fn generate_en_passant(game: &Game, side: Side, move_list: &mut Vec<Move>) {
|
|
|
if let Some(ep) = game.en_passant {
|
|
|
- let pawncolumn = A_FILE >> ep;
|
|
|
+ let pawncolumn = FILE_A >> ep;
|
|
|
|
|
|
let pawnrow: Bitboard = match side {
|
|
|
WHITE => ROW_5,
|