/** 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; }
/** Saves games from last search to a SGF. */ void MoHexEngine::SaveGames(HtpCommand& cmd) { MoHexSearch& search = m_player.Search(); cmd.CheckNuArg(1); std::string filename = cmd.Arg(0); search.SaveGames(filename); }
void MoHexEngine::MoHexPolicyParam(HtpCommand& cmd) { MoHexPlayoutPolicyConfig& config = m_player.SharedPolicy().Config(); if (cmd.NuArg() == 0) { cmd << '\n' << "pattern_check_percent " << config.patternCheckPercent << '\n' << "pattern_heuristic " << config.patternHeuristic << '\n' << "response_heuristic " << config.responseHeuristic << '\n' << "response_threshold " << config.responseThreshold << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "pattern_check_percent") config.patternCheckPercent = cmd.ArgMinMax<int>(1, 0, 100); else if (name == "pattern_heuristic") config.patternHeuristic = cmd.Arg<bool>(1); else if (name == "response_heuristic") config.responseHeuristic = cmd.Arg<bool>(1); else if (name == "response_threshold") config.responseThreshold = cmd.ArgMin<std::size_t>(1, 0); else throw HtpFailure("Unknown option!"); } else throw HtpFailure("Expected 0 or 2 arguments!"); }
void DfpnCommands::CmdParamSolverDB(HtpCommand& cmd) { SolverDBParameters& param = m_positions.Parameters(); if (cmd.NuArg() == 0) { cmd << '\n' << "[bool] use_flipped_states " << param.m_useFlippedStates << '\n' << "[bool] use_proof_transpositions " << param.m_useProofTranspositions << '\n' << "[string] max_stones " << param.m_maxStones << '\n' << "[string] trans_stones " << param.m_transStones << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "use_flipped_states") param.m_useFlippedStates = cmd.Arg<bool>(1); else if (name == "use_proof_transpositions") param.m_useProofTranspositions = cmd.Arg<bool>(1); else if (name == "max_stones") param.m_maxStones = cmd.ArgMin<int>(1, 0); else if (name == "trans_stones") param.m_transStones = cmd.ArgMin<int>(1, 0); else throw HtpFailure() << "unknown parameter: " << name; } else throw HtpFailure("Expected 0 or 2 arguments"); }
void BookBuilderCommands<PLAYER>::CmdBookExpand(HtpCommand& cmd) { if (m_book.get() == 0) throw HtpFailure() << "No open book."; cmd.CheckNuArg(1); int iterations = cmd.IntArg(0, 1); HexState state(m_game.Board(), m_game.Board().WhoseTurn()); HexBoard& brd = m_env.SyncBoard(m_game.Board()); m_bookBuilder.SetState(*m_book, state); m_bookBuilder.SetWorkBoard(brd); m_bookBuilder.Expand(iterations); }
/** 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"; } }
/** Saves the search tree from the previous search to the specified file. The optional second parameter sets the max depth to output. If not given, entire tree is saved. */ void MoHexEngine::SaveTree(HtpCommand& cmd) { MoHexSearch& search = m_player.Search(); cmd.CheckNuArg(1); std::string filename = cmd.Arg(0); int maxDepth = -1; std::ofstream file(filename.c_str()); if (!file) throw HtpFailure() << "Could not open '" << filename << "'"; if (cmd.NuArg() == 2) maxDepth = cmd.ArgMin<int>(1, 0); search.SaveTree(file, maxDepth); }
/** Finds all winning moves in the current state with dfpn, using the current hashtable. */ void DfpnCommands::CmdFindWinning(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor colorToMove = HtpUtil::ColorArg(cmd, 0); HexBoard& brd = m_env.SyncBoard(m_game.Board()); brd.ComputeAll(colorToMove); bitset_t consider = (EndgameUtil::IsDeterminedState(brd, colorToMove) ? brd.GetPosition().GetEmpty() : EndgameUtil::MovesToConsider(brd, colorToMove)); bitset_t winning; SgTimer timer; HexState state(m_game.Board(), colorToMove); for (BitsetIterator p(consider); p; ++p) { state.PlayMove(*p); HexBoard& brd = m_env.SyncBoard(state.Position()); LogInfo() << "****** Trying " << *p << " ******\n" << brd << '\n'; PointSequence pv; HexColor winner = m_solver.StartSearch(state, brd, m_positions, pv); if (winner == colorToMove) winning.set(*p); LogInfo() << "****** " << winner << " wins ******\n"; state.UndoMove(*p); } LogInfo() << "Total Elapsed Time: " << timer.GetTime() << '\n'; cmd << HexPointUtil::ToString(winning); }
/** Closes an open database. */ void DfpnCommands::CmdCloseDB(HtpCommand& cmd) { cmd.CheckNuArg(0); if (m_db.get() == 0) throw HtpFailure("No open database!\n"); m_db.reset(0); }
/** Prints database statistics. */ void DfpnCommands::CmdDBStat(HtpCommand& cmd) { cmd.CheckNuArg(0); if (m_db.get() == 0) throw HtpFailure("No open database!\n"); cmd << m_db->BDBStatistics(); }
void DfsCommands::CmdParamSolver(HtpCommand& cmd) { if (cmd.NuArg() == 0) { cmd << '\n' << "[bool] backup_ice_info " << m_solver.BackupIceInfo() << '\n' << "[bool] shrink_proofs " << m_solver.ShrinkProofs() << '\n' << "[bool] use_decompositions " << m_solver.UseDecompositions() << '\n' << "[bool] use_guifx " << m_solver.UseGuiFx() << '\n' << "[string] move_ordering " << m_solver.MoveOrdering() << '\n' // FIXME: PRINT NICELY!! << "[string] tt_bits " << ((m_tt.get() == 0) ? 0 : log2(m_tt->MaxHash())) << '\n' << "[string] update_depth " << m_solver.UpdateDepth() << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "backup_ice_info") m_solver.SetBackupIceInfo(cmd.Arg<bool>(1)); else if (name == "shrink_proofs") m_solver.SetShrinkProofs(cmd.Arg<bool>(1)); else if (name == "use_decompositions") m_solver.SetUseDecompositions(cmd.Arg<bool>(1)); else if (name == "use_guifx") m_solver.SetUseGuiFx(cmd.Arg<bool>(1)); else if (name == "move_ordering") m_solver.SetMoveOrdering(cmd.ArgMinMax<int>(1, 0, 7)); else if (name == "tt_bits") { int bits = cmd.ArgMin<int>(1, 0); if (bits == 0) m_tt.reset(0); else m_tt.reset(new DfsHashTable(1 << bits)); } else if (name == "update_depth") m_solver.SetUpdateDepth(cmd.Arg<std::size_t>(1)); else throw HtpFailure() << "unknown parameter: " << name; } }
void DfpnCommands::CmdParam(HtpCommand& cmd) { if (cmd.NuArg() == 0) { cmd << '\n' << "[bool] use_guifx " << m_solver.UseGuiFx() << '\n' << "[string] timelimit " << m_solver.Timelimit() << '\n' << "[string] tt_bits " << ((m_tt.get() == 0) ? 0 : log2(m_tt->MaxHash())) << '\n' << "[string] widening_base " << m_solver.WideningBase() << '\n' << "[string] widening_factor " << m_solver.WideningFactor() << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "use_guifx") m_solver.SetUseGuiFx(cmd.Arg<bool>(1)); else if (name == "timelimit") m_solver.SetTimelimit(cmd.ArgMin<float>(1, 0.0)); else if (name == "tt_bits") { int bits = cmd.ArgMin<int>(1, 0); if (bits == 0) m_tt.reset(0); else m_tt.reset(new DfpnHashTable(1 << bits)); } else if (name == "widening_base") m_solver.SetWideningBase(cmd.ArgMin<int>(1, 1)); else if (name == "widening_factor") { float value = cmd.Arg<float>(1); if (0.0f < value && value <= 1.0f) m_solver.SetWideningFactor(value); else throw GtpFailure() << "widening_factor must be in (0, 1]"; } else throw GtpFailure() << "Unknown parameter: " << name; } else throw GtpFailure() << "Expected 0 or 2 arguments"; }
/** Displays information about the current state from the hashtable. */ void DfpnCommands::CmdGetState(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor colorToMove = HtpUtil::ColorArg(cmd, 0); HexState state(m_game.Board(), colorToMove); DfpnData data; if (m_positions.Get(state, data)) cmd << data << '\n'; }
/** Displays PV from current position. */ void DfpnCommands::CmdGetPV(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor colorToMove = HtpUtil::ColorArg(cmd, 0); PointSequence pv; SolverDBUtil::GetVariation(HexState(m_game.Board(), colorToMove), m_positions, pv); cmd << HexPointUtil::ToString(pv); }
/** Dumps info from on current state. */ void DfsCommands::CmdGetState(HtpCommand& cmd) { cmd.CheckNuArg(0); HexColor toPlay = m_game.Board().WhoseTurn(); HexState state(m_game.Board(), toPlay); DfsData data; if (!m_positions.Get(state, data)) { cmd << "State not available."; return; } cmd << (data.m_win ? toPlay : !toPlay); cmd << ' ' << data.m_numMoves; std::vector<int> nummoves(BITSETSIZE); std::vector<int> flags(BITSETSIZE); std::vector<HexPoint> winning, losing; for (BitsetIterator p(state.Position().GetEmpty()); p; ++p) { state.PlayMove(*p); if (m_positions.Get(state, data)) { if (data.m_win) losing.push_back(*p); else winning.push_back(*p); nummoves[*p] = data.m_numMoves; flags[*p] = data.m_flags; } state.UndoMove(*p); } cmd << " Winning"; for (unsigned i = 0; i < winning.size(); ++i) { cmd << " " << winning[i]; cmd << " " << nummoves[winning[i]]; if (flags[winning[i]] & SolverDataFlags::MIRROR_TRANSPOSITION) cmd << "m"; else if (flags[winning[i]] & SolverDataFlags::TRANSPOSITION) cmd << "t"; } cmd << " Losing"; for (unsigned i = 0; i < losing.size(); ++i) { cmd << " " << losing[i]; cmd << " " << nummoves[losing[i]]; if (flags[losing[i]] & SolverDataFlags::MIRROR_TRANSPOSITION) cmd << "m"; else if (flags[losing[i]] & SolverDataFlags::TRANSPOSITION) cmd << "t"; } }
/** Displays work of every empty cell in current state. Bounds are obtained from the current hashtable. */ void DfpnCommands::CmdGetWork(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor colorToMove = HtpUtil::ColorArg(cmd, 0); HexState state(m_game.Board(), colorToMove); for (BitsetIterator it(state.Position().GetEmpty()); it; ++it) { state.PlayMove(*it); DfpnData data; if (m_positions.Get(state, data)) cmd << ' ' << *it << ' ' << data.m_work; state.UndoMove(*it); } }
void BookBuilderCommands<PLAYER>::CmdParamBookBuilder(HtpCommand& cmd) { if (cmd.NuArg() == 0) { cmd << '\n' << "[bool] use_widening " << m_bookBuilder.UseWidening() << '\n' << "[bool] use_ice " << m_bookBuilder.UseICE() << '\n' << "[string] alpha " << m_bookBuilder.Alpha() << '\n' << "[string] expand_width " << m_bookBuilder.ExpandWidth() << '\n' << "[string] expand_threshold " << m_bookBuilder.ExpandThreshold() << '\n' << "[string] num_threads " << m_bookBuilder.NumThreads() << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "alpha") m_bookBuilder.SetAlpha(cmd.FloatArg(1)); else if (name == "expand_width") m_bookBuilder.SetExpandWidth(cmd.SizeTypeArg(1, 1)); else if (name == "expand_threshold") m_bookBuilder.SetExpandThreshold(cmd.SizeTypeArg(1, 1)); else if (name == "num_threads") m_bookBuilder.SetNumThreads(cmd.SizeTypeArg(1)); else if (name == "use_ice") m_bookBuilder.SetUseICE(cmd.BoolArg(1)); else if (name == "use_widening") m_bookBuilder.SetUseWidening(cmd.BoolArg(1)); else throw HtpFailure() << "unknown parameter: " << name; } else throw HtpFailure("Expected 0 or 2 arguments."); }
/** Solves the given state. Usage: "solve-state [color to play] */ void DfsCommands::CmdSolveState(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor color = HtpUtil::ColorArg(cmd, 0); HexBoard& brd = m_env.SyncBoard(m_game.Board()); if (brd.ICE().FindPermanentlyInferior()) throw HtpFailure("Permanently inferior not supported in DfsSolver."); HexState state(m_game.Board(), color); DfsSolutionSet solution; HexColor winner = m_solver.Solve(state, brd, solution, m_positions); m_solver.DumpStats(solution); if (winner != EMPTY) LogInfo() << winner << " wins!\n" << brd.Write(solution.proof) << '\n'; else LogInfo() << "Search aborted!\n"; cmd << winner; }
/** Finds all winning moves in this state by calling 'solve-state' on each child move. Usage: same as 'solve-state'. */ void DfsCommands::CmdSolverFindWinning(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor color = HtpUtil::ColorArg(cmd, 0); HexBoard& brd = m_env.SyncBoard(m_game.Board()); if (brd.ICE().FindPermanentlyInferior()) throw HtpFailure("Permanently inferior not supported in DfsSolver"); brd.ComputeAll(color); bitset_t consider = (EndgameUtil::IsDeterminedState(brd, color) ? brd.GetPosition().GetEmpty() : EndgameUtil::MovesToConsider(brd, color)); bitset_t winning; SgTimer timer; HexState state(m_game.Board(), color); for (BitsetIterator p(consider); p; ++p) { if (!consider.test(*p)) continue; state.PlayMove(*p); HexBoard& brd = m_env.SyncBoard(state.Position()); LogInfo() << "****** Trying " << *p << " ******\n" << brd << '\n'; DfsSolutionSet solution; HexColor winner = m_solver.Solve(state, brd, solution, m_positions); m_solver.DumpStats(solution); LogInfo() << "Proof:" << brd.Write(solution.proof) << '\n'; state.UndoMove(*p); if (winner != EMPTY) LogInfo() << "****** " << winner << " wins ******\n"; else LogInfo() << "****** unknown ******\n"; if (winner == color) winning.set(*p); else consider &= solution.proof; } LogInfo() << "****** Winning Moves ******\n" << m_game.Board().Write(winning) << '\n'; LogInfo() << "Total Elapsed Time: " << timer.GetTime() << '\n'; cmd << HexPointUtil::ToString(winning); }
void MoHexEngine::FindTopMoves(HtpCommand& cmd) { HexColor color = HtpUtil::ColorArg(cmd, 0); int num = 5; if (cmd.NuArg() >= 2) num = cmd.ArgMin<int>(1, 1); HexState state(m_game.Board(), color); HexBoard& brd = m_pe.SyncBoard(m_game.Board()); if (EndgameUtil::IsDeterminedState(brd, color)) throw HtpFailure() << "State is determined.\n"; bitset_t consider = EndgameUtil::MovesToConsider(brd, color); std::vector<HexPoint> moves; std::vector<double> scores; m_player.FindTopMoves(num, state, m_game, brd, consider, m_player.MaxTime(), moves, scores); for (std::size_t i = 0; i < moves.size(); ++i) cmd << ' ' << static_cast<HexPoint>(moves[i]) << ' ' << (i + 1) << '@' << std::fixed << std::setprecision(3) << scores[i]; }
/** Displays bounds of every empty cell in current state. Bounds are obtained from the current hashtable. */ void DfpnCommands::CmdGetBounds(HtpCommand& cmd) { cmd.CheckNuArg(1); HexColor colorToMove = HtpUtil::ColorArg(cmd, 0); HexState state(m_game.Board(), colorToMove); for (BitsetIterator it(state.Position().GetEmpty()); it; ++it) { state.PlayMove(*it); DfpnData data; if (m_positions.Get(state, data)) { cmd << ' ' << *it << ' '; if (data.m_bounds.IsWinning()) cmd << 'L'; else if (data.m_bounds.IsLosing()) cmd << 'W'; else cmd << data.m_bounds.phi << ':' << data.m_bounds.delta; } state.UndoMove(*it); } }
void MoHexEngine::MoHexParam(HtpCommand& cmd) { HexUctSearch& search = m_player.Search(); if (cmd.NuArg() == 0) { cmd << '\n' << "[bool] backup_ice_info " << m_player.BackupIceInfo() << '\n' << "[bool] lock_free " << search.LockFree() << '\n' << "[bool] keep_games " << search.KeepGames() << '\n' << "[bool] perform_pre_search " << m_player.PerformPreSearch() << '\n' << "[bool] ponder " << m_player.Ponder() << '\n' << "[bool] reuse_subtree " << m_player.ReuseSubtree() << '\n' << "[bool] search_singleton " << m_player.SearchSingleton() << '\n' << "[bool] use_livegfx " << search.LiveGfx() << '\n' << "[bool] use_parallel_solver " << m_useParallelSolver << '\n' << "[bool] use_rave " << search.Rave() << '\n' << "[bool] use_time_management " << m_player.UseTimeManagement() << '\n' << "[bool] weight_rave_updates " << search.WeightRaveUpdates() << '\n' << "[string] bias_term " << search.BiasTermConstant() << '\n' << "[string] expand_threshold " << search.ExpandThreshold() << '\n' << "[string] knowledge_threshold " << KnowledgeThresholdToString(search.KnowledgeThreshold()) << '\n' << "[string] livegfx_interval " << search.LiveGfxInterval() << '\n' << "[string] max_games " << m_player.MaxGames() << '\n' << "[string] max_memory " << search.MaxNodes() * 2 * sizeof(SgUctNode) << '\n' << "[string] max_nodes " << search.MaxNodes() << '\n' << "[string] max_time " << m_player.MaxTime() << '\n' << "[string] num_threads " << search.NumberThreads() << '\n' << "[string] playout_update_radius " << search.PlayoutUpdateRadius() << '\n' << "[string] randomize_rave_frequency " << search.RandomizeRaveFrequency() << '\n' << "[string] rave_weight_final " << search.RaveWeightFinal() << '\n' << "[string] rave_weight_initial " << search.RaveWeightInitial() << '\n' << "[string] tree_update_radius " << search.TreeUpdateRadius() << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "backup_ice_info") m_player.SetBackupIceInfo(cmd.BoolArg(1)); else if (name == "lock_free") search.SetLockFree(cmd.BoolArg(1)); else if (name == "keep_games") search.SetKeepGames(cmd.BoolArg(1)); else if (name == "perform_pre_search") m_player.SetPerformPreSearch(cmd.BoolArg(1)); else if (name == "ponder") m_player.SetPonder(cmd.BoolArg(1)); else if (name == "use_livegfx") search.SetLiveGfx(cmd.BoolArg(1)); else if (name == "use_rave") search.SetRave(cmd.BoolArg(1)); else if (name == "randomize_rave_frequency") search.SetRandomizeRaveFrequency(cmd.IntArg(1, 0)); else if (name == "reuse_subtree") m_player.SetReuseSubtree(cmd.BoolArg(1)); else if (name == "bias_term") search.SetBiasTermConstant(cmd.FloatArg(1)); else if (name == "expand_threshold") search.SetExpandThreshold(cmd.IntArg(1, 0)); else if (name == "knowledge_threshold") search.SetKnowledgeThreshold (KnowledgeThresholdFromString(cmd.Arg(1))); else if (name == "livegfx_interval") search.SetLiveGfxInterval(cmd.IntArg(1, 0)); else if (name == "max_games") m_player.SetMaxGames(cmd.IntArg(1, 0)); else if (name == "max_memory") search.SetMaxNodes(cmd.SizeTypeArg(1, 1) / sizeof(SgUctNode) / 2); else if (name == "max_time") m_player.SetMaxTime(cmd.FloatArg(1)); else if (name == "max_nodes") search.SetMaxNodes(cmd.SizeTypeArg(1, 1)); else if (name == "num_threads") search.SetNumberThreads(cmd.IntArg(1, 0)); else if (name == "playout_update_radius") search.SetPlayoutUpdateRadius(cmd.IntArg(1, 0)); else if (name == "rave_weight_final") search.SetRaveWeightFinal(cmd.IntArg(1, 0)); else if (name == "rave_weight_initial") search.SetRaveWeightInitial(cmd.IntArg(1, 0)); else if (name == "weight_rave_updates") search.SetWeightRaveUpdates(cmd.BoolArg(1)); else if (name == "tree_update_radius") search.SetTreeUpdateRadius(cmd.IntArg(1, 0)); else if (name == "search_singleton") m_player.SetSearchSingleton(cmd.BoolArg(1)); else if (name == "use_parallel_solver") m_useParallelSolver = cmd.BoolArg(1); else if (name == "use_time_management") m_player.SetUseTimeManagement(cmd.BoolArg(1)); else throw HtpFailure() << "Unknown parameter: " << name; } else throw HtpFailure("Expected 0 or 2 arguments"); }
void MoHexEngine::MoHexParam(HtpCommand& cmd) { MoHexSearch& search = m_player.Search(); if (cmd.NuArg() == 0) { cmd << '\n' << "[bool] backup_ice_info " << m_player.BackupIceInfo() << '\n' #if HAVE_GCC_ATOMIC_BUILTINS << "[bool] lock_free " << search.LockFree() << '\n' #endif << "[bool] keep_games " << search.KeepGames() << '\n' << "[bool] perform_pre_search " << m_player.PerformPreSearch() << '\n' << "[bool] ponder " << m_player.Ponder() << '\n' << "[bool] reuse_subtree " << m_player.ReuseSubtree() << '\n' << "[bool] search_singleton " << m_player.SearchSingleton() << '\n' << "[bool] use_livegfx " << search.LiveGfx() << '\n' << "[bool] use_parallel_solver " << m_useParallelSolver << '\n' << "[bool] use_rave " << search.Rave() << '\n' << "[bool] use_time_management " << m_player.UseTimeManagement() << '\n' << "[bool] weight_rave_updates " << search.WeightRaveUpdates() << '\n' << "[bool] virtual_loss " << search.VirtualLoss() << '\n' << "[string] bias_term " << search.BiasTermConstant() << '\n' << "[string] expand_threshold " << search.ExpandThreshold() << '\n' << "[string] fillin_map_bits " << search.FillinMapBits() << '\n' << "[string] knowledge_threshold " << KnowledgeThresholdToString(search.KnowledgeThreshold()) << '\n' << "[string] number_playouts_per_visit " << search.NumberPlayouts() << '\n' << "[string] max_games " << m_player.MaxGames() << '\n' << "[string] max_memory " << search.MaxNodes() * 2 * sizeof(SgUctNode) << '\n' << "[string] max_nodes " << search.MaxNodes() << '\n' << "[string] max_time " << m_player.MaxTime() << '\n' << "[string] move_select " << MoveSelectToString(search.MoveSelect()) << '\n' #if HAVE_GCC_ATOMIC_BUILTINS << "[string] num_threads " << search.NumberThreads() << '\n' #endif << "[string] playout_update_radius " << search.PlayoutUpdateRadius() << '\n' << "[string] randomize_rave_frequency " << search.RandomizeRaveFrequency() << '\n' << "[string] rave_weight_final " << search.RaveWeightFinal() << '\n' << "[string] rave_weight_initial " << search.RaveWeightInitial() << '\n' << "[string] tree_update_radius " << search.TreeUpdateRadius() << '\n'; } else if (cmd.NuArg() == 2) { std::string name = cmd.Arg(0); if (name == "backup_ice_info") m_player.SetBackupIceInfo(cmd.Arg<bool>(1)); #if HAVE_GCC_ATOMIC_BUILTINS else if (name == "lock_free") search.SetLockFree(cmd.Arg<bool>(1)); #endif else if (name == "keep_games") search.SetKeepGames(cmd.Arg<bool>(1)); else if (name == "perform_pre_search") m_player.SetPerformPreSearch(cmd.Arg<bool>(1)); else if (name == "ponder") m_player.SetPonder(cmd.Arg<bool>(1)); else if (name == "use_livegfx") search.SetLiveGfx(cmd.Arg<bool>(1)); else if (name == "use_rave") search.SetRave(cmd.Arg<bool>(1)); else if (name == "randomize_rave_frequency") search.SetRandomizeRaveFrequency(cmd.ArgMin<int>(1, 0)); else if (name == "reuse_subtree") m_player.SetReuseSubtree(cmd.Arg<bool>(1)); else if (name == "bias_term") search.SetBiasTermConstant(cmd.Arg<float>(1)); else if (name == "expand_threshold") search.SetExpandThreshold(cmd.ArgMin<int>(1, 0)); else if (name == "knowledge_threshold") search.SetKnowledgeThreshold (KnowledgeThresholdFromString(cmd.Arg(1))); else if (name == "fillin_map_bits") search.SetFillinMapBits(cmd.ArgMin<int>(1, 1)); else if (name == "max_games") m_player.SetMaxGames(cmd.ArgMin<int>(1, 1)); else if (name == "max_memory") search.SetMaxNodes(cmd.ArgMin<std::size_t>(1, 1) / sizeof(SgUctNode) / 2); else if (name == "max_time") m_player.SetMaxTime(cmd.Arg<float>(1)); else if (name == "max_nodes") search.SetMaxNodes(cmd.ArgMin<std::size_t>(1, 1)); else if (name == "move_select") search.SetMoveSelect(MoveSelectArg(cmd, 1)); #if HAVE_GCC_ATOMIC_BUILTINS else if (name == "num_threads") search.SetNumberThreads(cmd.ArgMin<int>(1, 1)); #endif else if (name == "number_playouts_per_visit") search.SetNumberPlayouts(cmd.ArgMin<int>(1, 1)); else if (name == "playout_update_radius") search.SetPlayoutUpdateRadius(cmd.ArgMin<int>(1, 0)); else if (name == "rave_weight_final") search.SetRaveWeightFinal(cmd.ArgMin<float>(1, 0)); else if (name == "rave_weight_initial") search.SetRaveWeightInitial(cmd.ArgMin<float>(1, 0)); else if (name == "weight_rave_updates") search.SetWeightRaveUpdates(cmd.Arg<bool>(1)); else if (name == "tree_update_radius") search.SetTreeUpdateRadius(cmd.ArgMin<int>(1, 0)); else if (name == "search_singleton") m_player.SetSearchSingleton(cmd.Arg<bool>(1)); else if (name == "use_parallel_solver") m_useParallelSolver = cmd.Arg<bool>(1); else if (name == "use_time_management") m_player.SetUseTimeManagement(cmd.Arg<bool>(1)); else if (name == "virtual_loss") search.SetVirtualLoss(cmd.Arg<bool>(1)); else throw HtpFailure() << "Unknown parameter: " << name; } else throw HtpFailure("Expected 0 or 2 arguments"); }
void DfpnCommands::CmdEvaluationInfo(HtpCommand& cmd) { cmd.CheckNuArg(0); cmd << m_solver.EvaluationInfo(); }
/** Prints histogram of last search. */ void DfsCommands::CmdHistogram(HtpCommand& cmd) { cmd.CheckNuArg(0); cmd << m_solver.Histogram().Write(); }