From fea5d4c3a84e3d83ed761579a7a7cc31279cc165 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 20 Jun 2018 15:43:21 +0100 Subject: Set solver seed limit --- src/main/input-output/input/command_line_helper.cpp | 15 +++++++++++++-- src/main/input-output/input/command_line_helper.h | 2 ++ 2 files changed, 15 insertions(+), 2 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 2abef54..21eec88 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -38,12 +38,13 @@ command_line_helper::command_line_helper() "'solvability', 'benchmark' or list of deals to be solved.") ("classify", "outputs a simple 'solvable/not solvable' " "classification") - ("cache-capacity", po::value(), "sets an upper bound on the number of states allowed in " + ("cache-capacity", po::value(), "sets an upper bound on the number of states allowed in " "the cache") ("solvability", po::value(), "calculates the solvability " - "percentage of the supplied solitaire game, given a timeout in milliseconds. Must supply " + "percentage of the supplied solitaire game, given a limit for the number of seeds. Must supply " "either 'random', 'benchmark', 'solvability' or list of deals to be " "solved.") + ("timeout", po::value(), "adds a per-game timeout to the solvability percentage generation") ("resume", po::value>()->multitoken(), "resumes the solvability percentage calculation from a " "previous run. Must be supplied with the solvability option. " "Syntax: [sol unsol intract in-progress-1 in-progress-2 ...]") @@ -121,6 +122,12 @@ bool command_line_helper::parse(int argc, const char* argv[]) { solvability = -1; } + if (vm.count("timeout")) { + timeout = vm["timeout"].as(); + } else { + timeout = 604800000; // 1 week in milliseconds + } + if (vm.count("cores")) { cores = vm["cores"].as(); } else { @@ -248,6 +255,10 @@ int command_line_helper::get_solvability() { return solvability; } +uint64_t command_line_helper::get_timeout() { + return timeout; +} + vector command_line_helper::get_resume() { return resume; } diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h index 3ce239d..744935f 100644 --- a/src/main/input-output/input/command_line_helper.h +++ b/src/main/input-output/input/command_line_helper.h @@ -24,6 +24,7 @@ public: std::vector get_resume(); uint64_t get_cache_capacity(); std::string get_describe_game_rules(); + uint64_t get_timeout(); private: bool assess_errors(); @@ -51,6 +52,7 @@ private: bool available_game_types; bool benchmark; uint64_t cache_capacity; + uint64_t timeout; }; #endif //SOLVITAIRE_COMMAND_LINE_HELPER_H -- cgit v1.2.1 From abae8e0529cf2e6048e9b2eb8248434e1f9551de Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 20 Jun 2018 17:37:22 +0100 Subject: Add streamliner command line option (inc for spgs) --- src/main/input-output/input/command_line_helper.cpp | 15 +++++++++++---- src/main/input-output/input/command_line_helper.h | 2 ++ 2 files changed, 13 insertions(+), 4 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 21eec88..ec9a375 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -38,18 +38,20 @@ command_line_helper::command_line_helper() "'solvability', 'benchmark' or list of deals to be solved.") ("classify", "outputs a simple 'solvable/not solvable' " "classification") - ("cache-capacity", po::value(), "sets an upper bound on the number of states allowed in " + ("cache-capacity", po::value(), "sets an upper bound on the number of states allowed in " "the cache") ("solvability", po::value(), "calculates the solvability " "percentage of the supplied solitaire game, given a limit for the number of seeds. Must supply " - "either 'random', 'benchmark', 'solvability' or list of deals to be " - "solved.") + "either 'random', 'benchmark', 'solvability' or list of deals to be solved.") ("timeout", po::value(), "adds a per-game timeout to the solvability percentage generation") ("resume", po::value>()->multitoken(), "resumes the solvability percentage calculation from a " "previous run. Must be supplied with the solvability option. " "Syntax: [sol unsol intract in-progress-1 in-progress-2 ...]") ("cores", po::value(), "the number of cores for the solvability percentages to be run across. " - "Must be supplied with the solvability option.") + "Must be supplied with the solvability option.") + ("streamliners", "applies any relevant streamliners to the search. If the --solvability option is supplied," + " runs the streamliner version of the search first and then if unsuccessful, the full" + " search for each seed.") ("benchmark", "outputs performance statistics for the solver on the " "supplied solitaire game. Must supply " "either 'random', 'benchmark', 'solvability' or list of deals to be " @@ -141,6 +143,7 @@ bool command_line_helper::parse(int argc, const char* argv[]) { for (uint i = 0; i < cores; i++) resume.push_back(i); } + streamliners = (vm.count("streamliners") != 0); benchmark = (vm.count("benchmark") != 0); @@ -278,3 +281,7 @@ string command_line_helper::get_describe_game_rules() { bool command_line_helper::get_benchmark() { return benchmark; } + +bool command_line_helper::get_streamliners() { + return streamliners; +} diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h index 744935f..c12bb69 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: uint get_cores(); bool get_available_game_types(); bool get_benchmark(); + bool get_streamliners(); std::vector get_resume(); uint64_t get_cache_capacity(); std::string get_describe_game_rules(); @@ -51,6 +52,7 @@ private: uint cores; bool available_game_types; bool benchmark; + bool streamliners; uint64_t cache_capacity; uint64_t timeout; }; -- cgit v1.2.1 From 3a781e332c2a2d0d03b1eb35f1538929851aedaa Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Fri, 22 Jun 2018 16:21:37 +0100 Subject: Add simple simon --- src/main/input-output/input/sol_preset_types.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 53141a8..5b751af 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -928,6 +928,22 @@ map sol_preset_types::mp = { "max rank": 9 } )" + }, + { + "simple-simon", + + R"( +{ + "tableau piles": { + "count": 10, + "diagonal deal": true, + "move built group": true, + "move built group policy": "same-suit" + }, + "foundations complete piles": true +} +)" + } }; -- cgit v1.2.1 From a33fce2a22243fc3d29571c88be6f3c3cef91bec Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 25 Jun 2018 10:50:50 +0100 Subject: Add face up cards json rule --- src/main/input-output/input/sol_preset_types.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 5b751af..a10df54 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -26,7 +26,8 @@ map sol_preset_types::mp = { "spaces policy": "any", "diagonal deal": false, "move built group": false, - "move built group policy": "same-as-build" + "move built group policy": "same-as-build", + "face up cards": "all" }, "max rank": 13, "two decks": false, @@ -388,7 +389,8 @@ map sol_preset_types::mp = { "build policy": "red-black", "spaces policy": "kings", "move built group": true, - "diagonal deal": true + "diagonal deal": true, + "face up cards": "top" }, "stock size": 24, "stock deal count": 1, @@ -408,7 +410,8 @@ map sol_preset_types::mp = { "build policy": "red-black", "spaces policy": "kings", "move built group": true, - "diagonal deal": true + "diagonal deal": true, + "face up cards": "top" }, "stock size": 24, "stock deal count": 3, -- cgit v1.2.1 From 92d5705cb81e4fa4d971c8965b4cae7bc93f3eca Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 25 Jun 2018 11:54:07 +0100 Subject: Update rules schema to allow face up cards option --- src/main/input-output/input/json-parsing/rules_parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/json-parsing/rules_parser.cpp b/src/main/input-output/input/json-parsing/rules_parser.cpp index d4879de..e55c313 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -318,7 +318,8 @@ string rules_parser::rules_schema_json() { "spaces policy": {"type": "string", "enum": ["any", "no-build", "kings"]}, "diagonal deal": {"type": "boolean"}, "move built group": {"type": "boolean"}, - "move built group policy": {"type": "string", "enum": ["same-as-build", "any-suit", "red-black", "same-suit", "no-build"]} + "move built group policy": {"type": "string", "enum": ["same-as-build", "any-suit", "red-black", "same-suit", "no-build"]}, + "face up cards": {"type": "string", "enum": ["all", "top"]} }, "additionalProperties": false }, "max rank": {"type": "integer", "minimum": 1, "maximum": 13}, -- cgit v1.2.1 From dbfd7469b1d62d3cd32325af6aeb01e975db0111 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 25 Jun 2018 11:57:56 +0100 Subject: Add face up card rules parser --- .../input-output/input/json-parsing/rules_parser.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/json-parsing/rules_parser.cpp b/src/main/input-output/input/json-parsing/rules_parser.cpp index e55c313..91f6549 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -9,6 +9,7 @@ #include "json_helper.h" #include "../sol_preset_types.h" #include "../../../game/card.h" +#include "../../../game/sol_rules.h" using namespace std; using namespace rapidjson; @@ -20,6 +21,7 @@ using namespace rapidjson; typedef sol_rules::build_policy pol; typedef sol_rules::spaces_policy s_pol; typedef sol_rules::stock_deal_type sdt; +typedef sol_rules::face_up_policy fu; const sol_rules rules_parser::from_file(const string rules_file) { sol_rules sr = get_default(); @@ -160,6 +162,22 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + string face_up_str; + if (d["tableau piles"].HasMember("face up cards")) { + if (d["tableau piles"]["face up cards"].IsString()) { + face_up_str = d["tableau piles"]["face up cards"].GetString(); + } else { + json_helper::json_parse_err("[tableau piles][face up cards] must be a string"); + } + } + if (face_up_str == "all") { + sr.face_up = fu::ALL; + } else if (face_up_str == "top") { + sr.face_up = fu::TOP_CARDS; + } else { + json_helper::json_parse_err("[tableau piles][face up cards] is invalid"); + } + } else { json_helper::json_parse_err("[tableau piles] must be an object"); } -- cgit v1.2.1 From 8167f678fcbfc34982458b0311346bbeb04da9af Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 25 Jun 2018 12:25:02 +0100 Subject: Add face down deal parsing --- src/main/input-output/input/json-parsing/deal_parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/json-parsing/deal_parser.cpp b/src/main/input-output/input/json-parsing/deal_parser.cpp index 29ac3b1..e776cbd 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -5,11 +5,13 @@ #include "deal_parser.h" #include "../../../game/search-state/game_state.h" #include "json_helper.h" +#include "../../../game/sol_rules.h" using namespace std; using namespace rapidjson; typedef sol_rules::build_policy pol; +typedef sol_rules::face_up_policy fu; void deal_parser::parse(game_state &gs, const rapidjson::Document& doc) { // There are two stages to reading in the supplied deal. It is both put @@ -100,7 +102,7 @@ void deal_parser::parse_tableau_piles(game_state &gs, const rapidjson::Document& for (auto& json_card : p.first->GetArray()) { assert(json_card.IsString()); - gs.place_card(*p.second, card(json_card.GetString())); + gs.place_card(*p.second, card(json_card.GetString(), gs.rules.face_up != fu::ALL)); } } } -- cgit v1.2.1 From b9822b9fe08f423a32d5218ec8ce8bbcbf4c3a98 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 25 Jun 2018 12:38:18 +0100 Subject: Correct face up rules parsing bug --- .../input-output/input/json-parsing/rules_parser.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/main/input-output') diff --git a/src/main/input-output/input/json-parsing/rules_parser.cpp b/src/main/input-output/input/json-parsing/rules_parser.cpp index 91f6549..29e755b 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -166,17 +166,20 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d["tableau piles"].HasMember("face up cards")) { if (d["tableau piles"]["face up cards"].IsString()) { face_up_str = d["tableau piles"]["face up cards"].GetString(); + + if (face_up_str == "all") { + sr.face_up = fu::ALL; + } else if (face_up_str == "top") { + sr.face_up = fu::TOP_CARDS; + } else { + string err = "[tableau piles][face up cards] is invalid: " + face_up_str; + json_helper::json_parse_err(err); + } + } else { json_helper::json_parse_err("[tableau piles][face up cards] must be a string"); } } - if (face_up_str == "all") { - sr.face_up = fu::ALL; - } else if (face_up_str == "top") { - sr.face_up = fu::TOP_CARDS; - } else { - json_helper::json_parse_err("[tableau piles][face up cards] is invalid"); - } } else { json_helper::json_parse_err("[tableau piles] must be an object"); -- cgit v1.2.1