diff --git a/src/main.cpp b/src/main.cpp index 365eb00..97f5a4d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ namespace Hanabi { void analyze_game_and_start_cli(std::variant game_id, int turn, int draw_pile_size, std::optional score_goal, - bool start_cli) { + bool start_cli, bool print_remaining_states, bool quiet) { auto game = Download::get_game(game_id, score_goal); if (game.state == nullptr) { if(game_id.index() == 0) { @@ -25,19 +25,35 @@ namespace Hanabi { game.forward_until(turn, draw_pile_size); - std::cout << "Analysing state: " << std::endl << std::endl << *game.state << std::endl; + if (not quiet) { + std::cout << "Analysing state: " << std::endl << std::endl << *game.state << std::endl; + std::cout << std::endl; + } game.state->init_backtracking_information(); auto start = std::chrono::high_resolution_clock::now(); auto res = game.state->evaluate_state(); auto end = std::chrono::high_resolution_clock::now(); std::cout.precision(10); - std::cout << std::endl; - std::cout << "Probability with optimal play: "; + if (not (quiet and print_remaining_states)) { + std::cout << "Probability with optimal play: "; + } print_probability(std::cout, res) << std::endl; - std::cout << "Took " << std::chrono::duration_cast(end - start) << "." << std::endl; - std::cout << "Visited " << game.state->enumerated_states() << " states." << std::endl; - std::cout << "Enumerated " << game.state->position_tablebase().size() << " unique game states. " << std::endl; + if (not quiet) { + std::cout << "Took " << std::chrono::duration_cast(end - start) << "." << std::endl; + std::cout << "Visited " << game.state->enumerated_states() << " states." << std::endl; + std::cout << "Enumerated " << game.state->position_tablebase().size() << " unique game states. " << std::endl; + } + + if (print_remaining_states) + { + for(size_t remaining_cards = game.state->draw_pile_size(); remaining_cards > 0; remaining_cards--) { + game.forward_until(100, remaining_cards); + res = game.state->evaluate_state(); + std::cout << "Probability with " << remaining_cards << " cards left in deck: "; + print_probability(std::cout, res) << std::endl; + } + } if (start_cli) { std::cout << std::endl; @@ -66,6 +82,8 @@ int main(int argc, char *argv[]) { ("draw,d", boost::program_options::value(&draw_pile_size), "Draw pile size of state to analyze.") ("score,s", boost::program_options::value(), "Score that counts as a win, i.e. is optimized for achieving.") ("interactive,i", boost::program_options::value(&interactive_shell)->default_value(true), "Drop into interactive shell to explore game") + ("remaining-states,r", "Print probabilities for all further sizes of draw pile.") + ("quiet,q", "Deactivate all non-essential prints") ; boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); @@ -93,9 +111,9 @@ int main(int argc, char *argv[]) { } if (vm.count("file")) { - Hanabi::analyze_game_and_start_cli(vm["file"].as().c_str(), turn, draw_pile_size, score, interactive_shell); + Hanabi::analyze_game_and_start_cli(vm["file"].as().c_str(), turn, draw_pile_size, score, interactive_shell, vm.count("remaining-states"), vm.count("quiet")); } else { - Hanabi::analyze_game_and_start_cli(vm["id"].as(), turn, draw_pile_size, score, interactive_shell); + Hanabi::analyze_game_and_start_cli(vm["id"].as(), turn, draw_pile_size, score, interactive_shell, vm.count("remaining-states"), vm.count("quiet")); } return EXIT_SUCCESS; }