Add option to list all actions, even unreasonable ones
This commit is contained in:
parent
fd4f080d07
commit
60c405fa20
1 changed files with 15 additions and 5 deletions
|
@ -30,9 +30,9 @@ namespace Hanabi
|
|||
return ret;
|
||||
}
|
||||
|
||||
const static std::array<std::string, 14> cli_commands = {
|
||||
const static std::array<std::string, 15> 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 <chars>: 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<std::pair<Hanabi::Action, std::optional<Hanabi::probability_t>>> reasonable_actions = game.state->get_reasonable_actions(evaluate_actions_on_query);
|
||||
std::vector<std::pair<Hanabi::Action, std::optional<Hanabi::probability_t>>> 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<Hanabi::Action, std::optional<probability_t>> const & left,
|
||||
std::pair<Hanabi::Action, std::optional<probability_t>> const & right){
|
||||
|
|
Loading…
Reference in a new issue