add option to select game state by draw pile size
This commit is contained in:
parent
c40aae3c4b
commit
89bab62032
1 changed files with 14 additions and 6 deletions
20
src/main.cpp
20
src/main.cpp
|
@ -11,9 +11,9 @@
|
|||
|
||||
|
||||
namespace Hanabi {
|
||||
void analyze_game_and_start_cli(std::variant<int, const char*> game_id, int turn, std::optional<uint8_t> score_goal,
|
||||
void analyze_game_and_start_cli(std::variant<int, const char*> game_id, int turn, int draw_pile_size, std::optional<uint8_t> score_goal,
|
||||
bool start_cli) {
|
||||
auto game = Download::get_game(game_id, turn, 0, score_goal);
|
||||
auto game = Download::get_game(game_id, turn, draw_pile_size, score_goal);
|
||||
if (game == nullptr) {
|
||||
if(game_id.index() == 0) {
|
||||
std::cout << "Failed to download game " << std::get<int>(game_id) << " from hanab.live." << std::endl;
|
||||
|
@ -49,7 +49,8 @@ namespace Hanabi {
|
|||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int turn;
|
||||
int turn = 100;
|
||||
int draw_pile_size = 0;
|
||||
std::optional<int> score;
|
||||
bool interactive_shell;
|
||||
|
||||
|
@ -58,7 +59,8 @@ int main(int argc, char *argv[]) {
|
|||
("help", "print this help message")
|
||||
("id,g", boost::program_options::value<int>(), "Game ID from hanab.live")
|
||||
("file,f", boost::program_options::value<std::string>(), "Input file containing game in hanab.live json format")
|
||||
("turn,t", boost::program_options::value<int>(&turn)->default_value(1), "Turn number of state to analyze. Turn 1 means no actions have been taken.")
|
||||
("turn,t", boost::program_options::value<int>(&turn), "Turn number of state to analyze. Turn 1 means no actions have been taken.")
|
||||
("draw,d", boost::program_options::value<int>(&draw_pile_size), "Draw pile size of state to analyze.")
|
||||
("score,s", boost::program_options::value<int>(), "Score that counts as a win, i.e. is optimized for achieving.")
|
||||
("interactive,i", boost::program_options::value<bool>(&interactive_shell)->default_value(true), "Drop into interactive shell to explore game")
|
||||
;
|
||||
|
@ -77,14 +79,20 @@ int main(int argc, char *argv[]) {
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (vm.count("draw") + vm.count("turn") != 1) {
|
||||
std::cout << "Exactly one option of 'draw' and 'turn' has to be given." << std::endl;
|
||||
std::cout << "Use '--help' to print a help message." << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (vm.count("score")) {
|
||||
score = vm["score"].as<int>();
|
||||
}
|
||||
|
||||
if (vm.count("file")) {
|
||||
Hanabi::analyze_game_and_start_cli(vm["file"].as<std::string>().c_str(), turn, score, interactive_shell);
|
||||
Hanabi::analyze_game_and_start_cli(vm["file"].as<std::string>().c_str(), turn, draw_pile_size, score, interactive_shell);
|
||||
} else {
|
||||
Hanabi::analyze_game_and_start_cli(vm["id"].as<int>(), turn, score, interactive_shell);
|
||||
Hanabi::analyze_game_and_start_cli(vm["id"].as<int>(), turn, draw_pile_size, score, interactive_shell);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue