diff options
| author | thecharlesblake | 2018-04-05 22:16:10 +0100 |
|---|---|---|
| committer | thecharlesblake | 2018-04-06 10:06:13 +0100 |
| commit | 74764b8f8a17cb4c0379380acfe5152d60e80f2a (patch) | |
| tree | 829c6f93370e4f75c38eff98ad8a59095c512a49 /src/main/input-output | |
| parent | Merge pull request #49 from thecharlesblake/add-more-games (diff) | |
| download | metasol-74764b8f8a17cb4c0379380acfe5152d60e80f2a.tar.gz metasol-74764b8f8a17cb4c0379380acfe5152d60e80f2a.zip | |
Add benchmark cmd line option
Diffstat (limited to 'src/main/input-output')
| -rw-r--r-- | src/main/input-output/input/command_line_helper.cpp | 26 | ||||
| -rw-r--r-- | src/main/input-output/input/command_line_helper.h | 2 | ||||
| -rw-r--r-- | src/main/input-output/input/sol_preset_types.cpp | 69 |
3 files changed, 28 insertions, 69 deletions
diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp index 5518f1f..e3af0cd 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -35,15 +35,19 @@ command_line_helper::command_line_helper() "to be solved. Must supply either 'type' or 'custom-rules' option") ("random", po::value<int>(), "create and solve a random solitaire " "deal based on a seed. Must supply either 'random'," - "'solvability' or list of deals to be solved.") + "'solvability', 'benchmark' or list of deals to be solved.") + ("classify", "outputs a simple 'solvable/not solvable' " + "classification") ("shortest-sols", "for each instance returns the shortest possible " "solution. cannot be supplied alongside '--solvability'") ("solvability", "calculates the solvability " "percentage of the supplied solitaire game. Must supply " - "either 'random', 'solvability' or list of deals to be " + "either 'random', 'benchmark', 'solvability' or list of deals to be " "solved.") - ("classify", "outputs a simple 'solvable/not solvable' " - "classification"); + ("benchmark", "outputs performance statistics for the solver on the " + "supplied solitaire game. Must supply " + "either 'random', 'benchmark', 'solvability' or list of deals to be " + "solved."); po::options_description hidden_options("Hidden options"); hidden_options.add_options() @@ -102,6 +106,8 @@ bool command_line_helper::parse(int argc, const char* argv[]) { solvability = (vm.count("solvability") != 0); + benchmark = (vm.count("benchmark") != 0); + shortest_sols = (vm.count("shortest-sols") != 0); // Handle logic error scenarios @@ -117,8 +123,8 @@ bool command_line_helper::assess_errors() { if (available_game_types || !describe_game_rules.empty()) return true; // The user must either supply input files, a random seed, or ask for the - // solvability percentage - int opt_count = (random_deal != -1) + !input_files.empty() + solvability; + // solvability percentage, or benchmark + int opt_count = (random_deal != -1) + !input_files.empty() + solvability + benchmark; if (opt_count > 1) { print_too_many_opts_error(); @@ -166,7 +172,7 @@ void command_line_helper::print_help() { void command_line_helper::print_no_opts_error() { LOG_ERROR ("Error: User must supply input file(s), the '--random' " - "option, or the '--solvability' option"); + "option, the 'benchmark' option, or the '--solvability' option"); print_help(); } @@ -177,7 +183,7 @@ void command_line_helper::print_sol_type_rules_error() { } void command_line_helper::print_too_many_opts_error() { - LOG_ERROR ("Error: User must supply input file(s), the '--random' option, " + LOG_ERROR ("Error: User must supply input file(s), the '--random' option, the 'benchmark' option,, " "or the '--solvability' option, not multiple"); print_help(); } @@ -226,3 +232,7 @@ string command_line_helper::get_describe_game_rules() { bool command_line_helper::get_short_sols() { return shortest_sols; } + +bool command_line_helper::get_benchmark() { + return benchmark; +} diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h index 8773fd8..e436f13 100644 --- a/src/main/input-output/input/command_line_helper.h +++ b/src/main/input-output/input/command_line_helper.h @@ -21,6 +21,7 @@ public: bool get_solvability(); bool get_short_sols(); bool get_available_game_types(); + bool get_benchmark(); std::string get_describe_game_rules(); private: @@ -46,6 +47,7 @@ private: bool solvability; bool shortest_sols; bool available_game_types; + bool benchmark; }; #endif //SOLVITAIRE_COMMAND_LINE_HELPER_H diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 406be94..08f79e7 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -228,7 +228,8 @@ map<string, string> sol_preset_types::mp = { { "tableau piles": { "count": 4, - "build policy": "red-black" + "build policy": "red-black", + "move built group": true }, "stock size": 34, "reserve size": 14, @@ -244,7 +245,8 @@ map<string, string> sol_preset_types::mp = { { "tableau piles": { "count": 3, - "build policy": "red-black" + "build policy": "red-black", + "move built group": true }, "max rank": 3, "stock size": 1, @@ -377,26 +379,7 @@ map<string, string> sol_preset_types::mp = { }, { - "klondike", - - R"( -{ - "tableau piles": { - "count": 7, - "build policy": "red-black", - "spaces policy": "kings", - "diagonal deal": true - }, - "stock size": 24, - "stock deal count": 1, - "stock redeal": false -} -)" - - }, - - { - "klondike-built-group", + "klondike-deal-1", R"( { @@ -416,26 +399,7 @@ map<string, string> sol_preset_types::mp = { }, { - "klondike-deal-3", - - R"( -{ - "tableau piles": { - "count": 7, - "build policy": "red-black", - "spaces policy": "kings", - "diagonal deal": true - }, - "stock size": 24, - "stock deal count": 3, - "stock redeal": true -} -)" - - }, - - { - "klondike-deal-3-built-group", + "klondike", R"( { @@ -708,7 +672,7 @@ map<string, string> sol_preset_types::mp = { "move built group": true, "spaces policy": "kings" }, - "cells": 4, + "cells": 4 } )" @@ -731,7 +695,7 @@ map<string, string> sol_preset_types::mp = { }, { - "chamelion", + "chameleon", R"( { @@ -845,23 +809,6 @@ map<string, string> sol_preset_types::mp = { }, { - "king-albert-kings-in-spaces", - R"( - -{ - "tableau piles": { - "count": 9, - "build policy": "red-black", - "spaces policy": "kings", - "diagonal deal": true - }, - "foundations removable": true, - "reserve size": 7 -} -)" - - }, - { "spiderette", R"( |
