/** Solves the current state with dfpn using the current hashtable. */ void DfpnCommands::CmdSolveState(HtpCommand& cmd) { cmd.CheckNuArgLessEqual(3); HexColor colorToMove = m_game.Board().WhoseTurn(); if (cmd.NuArg() >= 1) colorToMove = HtpUtil::ColorArg(cmd, 0); // DfpnBounds::MAX_WORK cannot be used as an argument to ArgMinMax() // directly, because it is an integral constant class member that is not // defined anywhere and arguments to ArgMinMax() are passed by reference. // Older versions of GCC (including the current Cygwin GCC 4.3.4) generate // and error ("undefined reference to DfpnBounds::MAX_WORK"), probably in // accordance to the C++ standard. The best solution would be to change // GtpCommand::ArgMinMax() in Fuego to pass arguments by value. const DfpnBoundType maxWork = DfpnBounds::MAX_WORK; DfpnBoundType maxPhi = maxWork; DfpnBoundType maxDelta = maxWork; if (cmd.NuArg() >= 2) maxPhi = cmd.ArgMinMax<DfpnBoundType>(1, 0, maxWork); if (cmd.NuArg() >= 3) maxDelta = cmd.ArgMinMax<DfpnBoundType>(2, 0, maxWork); DfpnBounds maxBounds(maxPhi, maxDelta); PointSequence pv; HexBoard& brd = m_env.SyncBoard(m_game.Board()); HexColor winner = m_solver.StartSearch(HexState(m_game.Board(), colorToMove), brd, m_positions, pv, maxBounds); cmd << winner; }
/** Opens a database. Usage: "db-open [filename]" */ void DfpnCommands::CmdOpenDB(HtpCommand& cmd) { cmd.CheckNuArgLessEqual(3); std::string filename = cmd.Arg(0); try { m_db.reset(new DfpnDB(filename)); } catch (BenzeneException& e) { m_db.reset(0); throw HtpFailure() << "Error opening db: '" << e.what() << "'\n"; } }