+ int ply;
+ Position p(pos);
+ StateInfo st[100];
+
+ for (ply = 0; pv[ply] != MOVE_NONE; ply++)
+ p.do_move(pv[ply], st[ply]);
+
+ bool stop;
+ const TTEntry* tte;
+ for (stop = false, tte = retrieve(p.get_key());
+ tte && tte->move() != MOVE_NONE && !stop;
+ tte = retrieve(p.get_key()), ply++)
+ {
+ if (!move_is_legal(p, tte->move()))
+ break;
+ pv[ply] = tte->move();
+ p.do_move(pv[ply], st[ply]);
+ for (int j = 0; j < ply; j++)
+ if (st[j].key == p.get_key()) stop = true;
+ }
+ pv[ply] = MOVE_NONE;