std::string IterativeDeepener::PV(const Move& root_move) {
  std::string pv;

  // Root move may not always be in the transposition table or the one in
  // transposition table may not be the first move of PV if move ordering
  // is determined externally.
  pv.append(SAN(*board_, root_move) + " ");
  board_->MakeMove(root_move);

  int depth = 0;
  while (depth < 10) {
    U64 zkey = board_->ZobristKey();
    TranspositionTableEntry* tentry = transpos_->Get(zkey);
    if (!tentry || !tentry->best_move.is_valid() ||
        tentry->node_type != EXACT_NODE) {
      break;
    }
    pv.append(SAN(*board_, tentry->best_move) + " ");
    ++depth;
    board_->MakeMove(tentry->best_move);
  }
  while (depth--) {
    board_->UnmakeLastMove();
  }

  board_->UnmakeLastMove(); // root move
  return pv;
}
Exemple #2
0
static void RunAnnotate(char *fname, int side)
{
    FILE *fin = fopen(fname, "r");
    struct Position *p;

    if(fin) {
        struct PGNHeader header;
        char move[16];


        while(!scanHeader(fin, &header)) {
            p = InitialPosition();
            while(!scanMove(fin, move)) {
                int themove = ParseSAN(p, move);
                if(themove != M_NONE) {
                    ShowPosition(p);
                    Print(0, "%s(%d): ", 
                            p->turn == White ? "White":"Black", (p->ply/2)+1);
                    Print(0, "%s\n", SAN(p, themove));
                    if(side == -1 || (side == p->turn)) {
                        Iterate(p);
                    }
                    DoMove(p, themove);
                }
            }
            FreePosition(p);
        }
    }
    else Print(0, "Couldn't open %s\n", fname);
}