diff --git a/src/state_explorer.cpp b/src/state_explorer.cpp index 07b92c6..d8ffcab 100644 --- a/src/state_explorer.cpp +++ b/src/state_explorer.cpp @@ -30,9 +30,9 @@ namespace Hanabi return ret; } - const static std::array cli_commands = { + const static std::array cli_commands = { "play", "clue", "discard", "opt", "state", "id", "revert", "actions", "evaluate", "help", "quit", "set-initials" - , "dump-id-parts", "toggle-auto-evaluation" + , "dump-id-parts", "toggle-auto-evaluation", "toggle-reasonable-actions" }; char *cli_commands_generator(const char *text, int state) @@ -193,6 +193,7 @@ namespace Hanabi // Tracks the depth of the replay the user explores. We have to ensure that we don't revert too much. unsigned depth = 0; bool evaluate_actions_on_query = false; + bool show_only_reasonable_actions = true; while (true) { @@ -212,8 +213,10 @@ namespace Hanabi << std::endl; std::cout << "evaluate: evaluate current game state recursively. Potentially runtime-expensive." << std::endl; - std::cout << "toggle-auto-evaluation: If set to true, all available game actions will be evaluated upon listing them." - << "Currently set to " << std::boolalpha << evaluate_actions_on_query << "."<< std::endl; + std::cout << "toggle-auto-evaluation: If set to true, all available game actions will be evaluated upon listing them. " + << "Currently set to " << std::boolalpha << evaluate_actions_on_query << "." << std::endl; + std::cout << "toggle-reasonable-actions: If set to true, only reasonable actions will be suggested. " + << "Currently set to " << std::boolalpha << show_only_reasonable_actions << "." << std::endl; std::cout << "set-initials : Set initials for the suits." << std::endl; std::cout << "(q)uit: Quit this interactive shell." << std::endl; std::cout << "id: display id of state. Has no inherent meaning, useful for debugging." @@ -292,6 +295,13 @@ namespace Hanabi continue; } + if (prompt.find("toggle-reasonable-actions") == 0) + { + show_only_reasonable_actions = !show_only_reasonable_actions; + std::cout << "Toggled showing only reasonable actions, now set to " << std::boolalpha << show_only_reasonable_actions << "." << std::endl; + continue; + } + if (prompt.find("revert") == 0) { if (depth == 0) @@ -405,7 +415,7 @@ namespace Hanabi if (prompt.find("actions") == 0) { - std::vector>> reasonable_actions = game.state->get_reasonable_actions(evaluate_actions_on_query); + std::vector>> reasonable_actions = game.state->get_reasonable_actions(evaluate_actions_on_query, show_only_reasonable_actions); std::sort(reasonable_actions.begin(), reasonable_actions.end(), [](std::pair> const & left, std::pair> const & right){