|  | @@ -57,21 +57,8 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, depth:
 | 
											
												
													
														|  |      let mut valued_moves: Vec<(Move, PosValue)> = Vec::with_capacity(moves.len());
 |  |      let mut valued_moves: Vec<(Move, PosValue)> = Vec::with_capacity(moves.len());
 | 
											
												
													
														|  |      let mut cancelled = false;
 |  |      let mut cancelled = false;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    let game_before = game.clone();
 |  | 
 | 
											
												
													
														|  |      for mov in moves {
 |  |      for mov in moves {
 | 
											
												
													
														|  | -        let mut new_game = apply_move(game, mov);
 |  | 
 | 
											
												
													
														|  |          let undo = game.apply(mov);
 |  |          let undo = game.apply(mov);
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        if *game != new_game {
 |  | 
 | 
											
												
													
														|  | -            info!("move not correct?");
 |  | 
 | 
											
												
													
														|  | -            info!("move is {}", mov.to_string());
 |  | 
 | 
											
												
													
														|  | -            info!("game:\n{}", game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            info!("new_game:\n{}", new_game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            info!("CR game: {:?}", game.castling_rights);
 |  | 
 | 
											
												
													
														|  | -            info!("CR new_game: {:?}", new_game.castling_rights);
 |  | 
 | 
											
												
													
														|  | -            info!("CR new_game: {:?}", game.castling_rights == new_game.castling_rights);
 |  | 
 | 
											
												
													
														|  | -            panic!("unequal games");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |          //assert_eq!(new_game, *game, );
 |  |          //assert_eq!(new_game, *game, );
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          let hash_entry: Option<CacheEntry> = None;//hash.lookup(&new_game);
 |  |          let hash_entry: Option<CacheEntry> = None;//hash.lookup(&new_game);
 | 
											
										
											
												
													
														|  | @@ -94,7 +81,7 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, depth:
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          //info!("searching {}", mov.to_string());
 |  |          //info!("searching {}", mov.to_string());
 | 
											
												
													
														|  | -        let (mut val, ret) = negamax(&mut new_game, sc, hash, -beta, -alpha, depth - 1);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        let (mut val, ret) = negamax(game, sc, hash, -beta, -alpha, depth - 1);
 | 
											
												
													
														|  |          val = -val;
 |  |          val = -val;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          if ret {
 |  |          if ret {
 | 
											
										
											
												
													
														|  | @@ -121,13 +108,6 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, depth:
 | 
											
												
													
														|  |          valued_moves.push((mov, -val));
 |  |          valued_moves.push((mov, -val));
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          game.undo_move(undo);
 |  |          game.undo_move(undo);
 | 
											
												
													
														|  | -        if *game != game_before {
 |  | 
 | 
											
												
													
														|  | -            info!("inequal in search");
 |  | 
 | 
											
												
													
														|  | -            info!("mov was: {}", mov.to_string());
 |  | 
 | 
											
												
													
														|  | -            info!("game:\n{}", game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            info!("new_game:\n{}", game_before.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            panic!("unequal games");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -193,7 +173,6 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    let game_before = game.clone();
 |  | 
 | 
											
												
													
														|  |      for mov in moves {
 |  |      for mov in moves {
 | 
											
												
													
														|  |          let undo = game.apply(mov);
 |  |          let undo = game.apply(mov);
 | 
											
												
													
														|  |          let (mut val, ret) = negamax(game, sc, hash, -beta, -alpha, depth - 1);
 |  |          let (mut val, ret) = negamax(game, sc, hash, -beta, -alpha, depth - 1);
 | 
											
										
											
												
													
														|  | @@ -206,13 +185,6 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          if val >= beta {
 |  |          if val >= beta {
 | 
											
												
													
														|  |              game.undo_move(undo);
 |  |              game.undo_move(undo);
 | 
											
												
													
														|  | -            if *game != game_before {
 |  | 
 | 
											
												
													
														|  | -                info!("move was:\n{}", mov.to_string());
 |  | 
 | 
											
												
													
														|  | -                info!("unequal in negamax");
 |  | 
 | 
											
												
													
														|  | -                info!("game:\n{}", game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -                info!("new_game:\n{}", game_before.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -                panic!("unequal games");
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  |              return (beta, false);
 |  |              return (beta, false);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          if val > alpha {
 |  |          if val > alpha {
 | 
											
										
											
												
													
														|  | @@ -225,13 +197,6 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
 | 
											
												
													
														|  |              //best_move = mov;
 |  |              //best_move = mov;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          game.undo_move(undo);
 |  |          game.undo_move(undo);
 | 
											
												
													
														|  | -        if *game != game_before {
 |  | 
 | 
											
												
													
														|  | -            info!("move was:\n{}", mov.to_string());
 |  | 
 | 
											
												
													
														|  | -            info!("unequal in negamax");
 |  | 
 | 
											
												
													
														|  | -            info!("game:\n{}", game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            info!("new_game:\n{}", game_before.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            panic!("unequal games");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -258,33 +223,18 @@ fn quiescence_search(game: &mut Game, sc: &mut SearchControl, mut alpha: PosValu
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      let moves = generate_attacking_moves(game, game.turn);
 |  |      let moves = generate_attacking_moves(game, game.turn);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    let game_before = game.clone();
 |  | 
 | 
											
												
													
														|  |      for mov in moves {
 |  |      for mov in moves {
 | 
											
												
													
														|  |          let undo = game.apply(mov);
 |  |          let undo = game.apply(mov);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          let val = -quiescence_search(game, sc, -beta, -alpha, depth - 1);
 |  |          let val = -quiescence_search(game, sc, -beta, -alpha, depth - 1);
 | 
											
												
													
														|  |          if val >= beta {
 |  |          if val >= beta {
 | 
											
												
													
														|  |              game.undo_move(undo);
 |  |              game.undo_move(undo);
 | 
											
												
													
														|  | -            if *game != game_before {
 |  | 
 | 
											
												
													
														|  | -                info!("move was:\n{}", mov.to_string());
 |  | 
 | 
											
												
													
														|  | -                info!("unequal in quiescence");
 |  | 
 | 
											
												
													
														|  | -                info!("game:\n{}", game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -                info!("new_game:\n{}", game_before.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -                panic!("unequal games");
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  |              return beta;
 |  |              return beta;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          if val > alpha {
 |  |          if val > alpha {
 | 
											
												
													
														|  |              alpha = val;
 |  |              alpha = val;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          game.undo_move(undo);
 |  |          game.undo_move(undo);
 | 
											
												
													
														|  | -        if *game != game_before {
 |  | 
 | 
											
												
													
														|  | -            info!("move was:\n{}", mov.to_string());
 |  | 
 | 
											
												
													
														|  | -            info!("unequal in quiescence");
 |  | 
 | 
											
												
													
														|  | -            info!("game:\n{}", game.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            info!("new_game:\n{}", game_before.beautiful_print());
 |  | 
 | 
											
												
													
														|  | -            panic!("unequal games");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      return alpha;
 |  |      return alpha;
 | 
											
												
													
														|  |  }
 |  |  }
 |