本文整理汇总了C++中HtpCommand::NuArg方法的典型用法代码示例。如果您正苦于以下问题:C++ HtpCommand::NuArg方法的具体用法?C++ HtpCommand::NuArg怎么用?C++ HtpCommand::NuArg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtpCommand
的用法示例。
在下文中一共展示了HtpCommand::NuArg方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CmdSolveState
/** 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;
}
示例2: CmdParamSolverDB
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");
}
示例3: MoHexPolicyParam
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!");
}
示例4: CmdParam
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";
}
示例5: CmdParamSolver
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;
}
}
示例6: if
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.");
}
示例7: SaveTree
/** 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);
}
示例8: FindTopMoves
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];
}
示例9: MoHexParam
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")
//.........这里部分代码省略.........
示例10: MoHexParam
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));
//.........这里部分代码省略.........