|
@@ -166,9 +166,14 @@ impl Engine {
|
|
fn reconstruct_pv(game: &Game, hash: &Cache) -> Vec<Move> {
|
|
fn reconstruct_pv(game: &Game, hash: &Cache) -> Vec<Move> {
|
|
let mut pv: Vec<Move> = Vec::new();
|
|
let mut pv: Vec<Move> = Vec::new();
|
|
let mut g = game.clone();
|
|
let mut g = game.clone();
|
|
- loop {
|
|
|
|
|
|
+
|
|
|
|
+ // max 100 to avoid infinite loops
|
|
|
|
+ for _ in 0..100 {
|
|
let mce = hash.lookup(&g);
|
|
let mce = hash.lookup(&g);
|
|
if let Some(ce) = mce {
|
|
if let Some(ce) = mce {
|
|
|
|
+ if ce.mov == Move::Nullmove {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
pv.push(ce.mov);
|
|
pv.push(ce.mov);
|
|
g.apply(ce.mov);
|
|
g.apply(ce.mov);
|
|
}
|
|
}
|