From 74764b8f8a17cb4c0379380acfe5152d60e80f2a Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 5 Apr 2018 22:16:10 +0100 Subject: Add benchmark cmd line option --- .../input-output/input/command_line_helper.cpp | 26 +++++--- src/main/input-output/input/command_line_helper.h | 2 + src/main/input-output/input/sol_preset_types.cpp | 69 +++------------------- 3 files changed, 28 insertions(+), 69 deletions(-) (limited to 'src/main/input-output') 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(), "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 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 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 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 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 sol_preset_types::mp = { "move built group": true, "spaces policy": "kings" }, - "cells": 4, + "cells": 4 } )" @@ -731,7 +695,7 @@ map sol_preset_types::mp = { }, { - "chamelion", + "chameleon", R"( { @@ -841,23 +805,6 @@ map sol_preset_types::mp = { "foundations removable": true, "reserve size": 7 } -)" - - }, - { - "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 -} )" }, -- cgit v1.2.1