From c7743d9f217c78b453a7676a88d61b4b937955ee Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 8 Mar 2018 23:05:02 +0000 Subject: Update JSON options for new spider rules --- src/main/input-output/input/sol_preset_types.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index de0fd41..2eea9df 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -33,6 +33,7 @@ std::map sol_preset_types::mp = { "foundations": true, "foundations initial card": false, "foundations removable": false, + "ordered-tableau-sol": false, "cells": 0, "stock size": 0, "stock deal type": "waste", @@ -318,10 +319,12 @@ std::map sol_preset_types::mp = { R"( { "tableau piles": { - "count": 10 + "count": 10, + "move built group": false }, + "ordered-tableau-sol": true, "two decks": true, - "stock size": 60, + "stock size": 50, "stock deal type": "tableau piles" } )" @@ -333,8 +336,10 @@ std::map sol_preset_types::mp = { R"( { "tableau piles": { - "count": 4 + "count": 4, + "move built group": false }, + "ordered-tableau-sol": true, "two decks": true, "max rank": 3, "stock size": 12, -- cgit v1.2.1 From 2cc12c2cc24701dbe89281c3b71031649a748879 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 8 Mar 2018 23:29:30 +0000 Subject: Add solve by ordered tableau json parsing --- .../input/json-parsing/rules_parser.cpp | 21 +++++++++++++++++---- src/main/input-output/input/sol_preset_types.cpp | 6 +++--- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src/main/input-output/input') 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 395f2e7..cf01b2d 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -56,6 +56,7 @@ sol_rules rules_parser::get_default() { } void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { + int solution_types = 0; if (!d.IsObject()) { json_helper::json_parse_err("JSON doc must be object"); @@ -156,6 +157,7 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d.HasMember("hole")) { if (d["hole"].IsBool()) { sr.hole = d["hole"].GetBool(); + solution_types++; } else { json_helper::json_parse_err("[hole] must be a boolean"); } @@ -164,15 +166,12 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d.HasMember("foundations")) { if (d["foundations"].IsBool()) { sr.foundations = d["foundations"].GetBool(); + solution_types++; } else { json_helper::json_parse_err("[foundations] must be a boolean"); } } - if (!sr.hole && !sr.foundations) { - json_helper::json_parse_err("one of [hole] and [foundations] must be true"); - } - if (d.HasMember("foundations initial card")) { if (d["foundations initial card"].IsBool()) { sr.foundations_init_card = d["foundations initial card"].GetBool(); @@ -189,6 +188,15 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d.HasMember("solve by ordered tableau")) { + if (d["solve by ordered tableau"].IsBool()) { + sr.solve_ord_tab = d["solve by ordered tableau"].GetBool(); + solution_types++; + } else { + json_helper::json_parse_err("[solve by ordered tableau] must be a boolean"); + } + } + if (d.HasMember("cells")) { if (d["cells"].IsInt()) { sr.cells = static_cast(d["cells"].GetInt()); @@ -232,4 +240,9 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { json_helper::json_parse_err("[reserve stacked] must be a boolean"); } } + + if (solution_types != 1) + json_helper::json_parse_err("one and only one of [hole], [foundations] " + "and [solve by ordered tableau] must be true"); + } } diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 2eea9df..75a0b01 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -33,7 +33,7 @@ std::map sol_preset_types::mp = { "foundations": true, "foundations initial card": false, "foundations removable": false, - "ordered-tableau-sol": false, + "solve by ordered tableau": false, "cells": 0, "stock size": 0, "stock deal type": "waste", @@ -322,7 +322,7 @@ std::map sol_preset_types::mp = { "count": 10, "move built group": false }, - "ordered-tableau-sol": true, + "solve by ordered tableau": true, "two decks": true, "stock size": 50, "stock deal type": "tableau piles" @@ -339,7 +339,7 @@ std::map sol_preset_types::mp = { "count": 4, "move built group": false }, - "ordered-tableau-sol": true, + "solve by ordered tableau": true, "two decks": true, "max rank": 3, "stock size": 12, -- cgit v1.2.1 From 00953c5edb79ed7c2551e6dcf9fb9e3040a3b42d Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 21 Mar 2018 10:57:59 +0000 Subject: Update spider with correct rules --- src/main/input-output/input/sol_preset_types.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main/input-output/input') diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 75a0b01..1fa6009 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -25,7 +25,8 @@ std::map sol_preset_types::mp = { "build policy": "any-suit", "spaces policy": "any", "diagonal deal": false, - "move built group": false + "move built group": false, + "move built group policy": "same-as-build" }, "max rank": 13, "two decks": false, @@ -33,7 +34,7 @@ std::map sol_preset_types::mp = { "foundations": true, "foundations initial card": false, "foundations removable": false, - "solve by ordered tableau": false, + "foundations complete piles": false, "cells": 0, "stock size": 0, "stock deal type": "waste", @@ -320,9 +321,11 @@ std::map sol_preset_types::mp = { { "tableau piles": { "count": 10, - "move built group": false + "build policy": "any-suit", + "move built group": true, + "move built group policy": "same-suit" }, - "solve by ordered tableau": true, + "foundations complete piles": true, "two decks": true, "stock size": 50, "stock deal type": "tableau piles" @@ -337,9 +340,11 @@ std::map sol_preset_types::mp = { { "tableau piles": { "count": 4, - "move built group": false + "build policy": "any-suit", + "move built group": true, + "move built group policy": "same-suit" }, - "solve by ordered tableau": true, + "foundations complete piles": true, "two decks": true, "max rank": 3, "stock size": 12, -- cgit v1.2.1 From 57cb29f245ebe7802014841d70f6f0289ce11113 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Wed, 21 Mar 2018 10:58:17 +0000 Subject: Update rules parse with built group pol --- .../input/json-parsing/rules_parser.cpp | 46 ++++++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'src/main/input-output/input') 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 cf01b2d..6fa89bc 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -56,8 +56,6 @@ sol_rules rules_parser::get_default() { } void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { - int solution_types = 0; - if (!d.IsObject()) { json_helper::json_parse_err("JSON doc must be object"); } @@ -110,7 +108,7 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } else { - json_helper::json_parse_err("[tableau piles][spaces policy] must be an string"); + json_helper::json_parse_err("[tableau piles][spaces policy] must be a string"); } } @@ -122,6 +120,28 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } + if (d["tableau piles"].HasMember("move built group policy")) { + if (d["tableau piles"]["move built group policy"].IsString()) { + string mbgp_str = d["tableau piles"]["move built group policy"].GetString(); + + if (mbgp_str == "same-as-build") { + sr.built_group_pol = sr.build_pol; + } else if (mbgp_str == "any-suit") { + sr.built_group_pol = pol::ANY_SUIT; + } else if (mbgp_str == "red-black") { + sr.built_group_pol = pol::RED_BLACK; + } else if (mbgp_str == "same-suit") { + sr.built_group_pol = pol::SAME_SUIT; + } else if (mbgp_str == "no-build") { + sr.built_group_pol = pol::NO_BUILD; + } else { + json_helper::json_parse_err("[tableau piles][move built group policy] is invalid"); + } + } else { + json_helper::json_parse_err("[tableau piles][move built group policy] must be a string"); + } + } + if (d["tableau piles"].HasMember("diagonal deal")) { if (d["tableau piles"]["diagonal deal"].IsBool()) { sr.diagonal_deal = d["tableau piles"]["diagonal deal"].GetBool(); @@ -157,7 +177,6 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d.HasMember("hole")) { if (d["hole"].IsBool()) { sr.hole = d["hole"].GetBool(); - solution_types++; } else { json_helper::json_parse_err("[hole] must be a boolean"); } @@ -166,7 +185,6 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { if (d.HasMember("foundations")) { if (d["foundations"].IsBool()) { sr.foundations = d["foundations"].GetBool(); - solution_types++; } else { json_helper::json_parse_err("[foundations] must be a boolean"); } @@ -188,12 +206,11 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } - if (d.HasMember("solve by ordered tableau")) { - if (d["solve by ordered tableau"].IsBool()) { - sr.solve_ord_tab = d["solve by ordered tableau"].GetBool(); - solution_types++; + if (d.HasMember("foundations complete piles")) { + if (d["foundations complete piles"].IsBool()) { + sr.foundations_comp_piles = d["foundations complete piles"].GetBool(); } else { - json_helper::json_parse_err("[solve by ordered tableau] must be a boolean"); + json_helper::json_parse_err("[foundations complete piles] must be a boolean"); } } @@ -241,8 +258,11 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { } } - if (solution_types != 1) - json_helper::json_parse_err("one and only one of [hole], [foundations] " - "and [solve by ordered tableau] must be true"); + int solution_types = 0; + if (sr.hole) solution_types++; + if (sr.foundations) solution_types++; + if (solution_types != 1) { + json_helper::json_parse_err("one and only one of [hole] and [foundations] " + "must be true"); } } -- cgit v1.2.1