From df67cafb5e9ce2ebd1c38ed59b2c71a95d33f05c Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Thu, 7 Jun 2018 15:40:49 +0100 Subject: Tidy up main --- .../input-output/input/command_line_helper.cpp | 22 ---------------------- src/main/input-output/input/command_line_helper.h | 4 ---- 2 files changed, 26 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 92fef21..4b0942a 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -38,8 +38,6 @@ command_line_helper::command_line_helper() "'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', 'benchmark', 'solvability' or list of deals to be " @@ -108,8 +106,6 @@ bool command_line_helper::parse(int argc, const char* argv[]) { benchmark = (vm.count("benchmark") != 0); - shortest_sols = (vm.count("shortest-sols") != 0); - // Handle logic error scenarios return assess_errors(); } @@ -141,11 +137,6 @@ bool command_line_helper::assess_errors() { return false; } - if (shortest_sols && solvability) { - print_shortest_sols_error(); - return false; - } - if (!solitaire_type.empty()) { return assess_sol_type(); } else { @@ -188,11 +179,6 @@ void command_line_helper::print_too_many_opts_error() { print_help(); } -void command_line_helper::print_shortest_sols_error() { - LOG_ERROR ("Error: User cannot supply '--shortest-sols' and '--solvability'"); - print_help(); -} - const vector command_line_helper::get_input_files() { return input_files; } @@ -209,10 +195,6 @@ int command_line_helper::get_random_deal() { return random_deal; } -bool command_line_helper::get_help() { - return help; -} - bool command_line_helper::get_classify() { return classify; } @@ -229,10 +211,6 @@ string command_line_helper::get_describe_game_rules() { return 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 e436f13..911cd5a 100644 --- a/src/main/input-output/input/command_line_helper.h +++ b/src/main/input-output/input/command_line_helper.h @@ -16,10 +16,8 @@ public: const std::string get_solitaire_type(); const std::string get_rules_file(); int get_random_deal(); - bool get_help(); bool get_classify(); bool get_solvability(); - bool get_short_sols(); bool get_available_game_types(); bool get_benchmark(); std::string get_describe_game_rules(); @@ -31,7 +29,6 @@ private: void print_sol_type_rules_error(); void print_no_opts_error(); void print_too_many_opts_error(); - void print_shortest_sols_error(); boost::program_options::options_description cmdline_options; boost::program_options::options_description main_options; @@ -45,7 +42,6 @@ private: bool help; bool classify; bool solvability; - bool shortest_sols; bool available_game_types; bool benchmark; }; -- cgit v1.2.1 From 819a1064c5142a9b2f04ff8149d34fc915c18322 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Fri, 8 Jun 2018 10:31:22 +0100 Subject: Refactor legal moves gen and moves logic --- src/main/input-output/input/json-parsing/deal_parser.cpp | 6 +++--- src/main/input-output/output/state_printer.cpp | 14 +++++++------- src/main/input-output/output/state_printer.h | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) (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 f841c8d..29ac3b1 100644 --- a/src/main/input-output/input/json-parsing/deal_parser.cpp +++ b/src/main/input-output/input/json-parsing/deal_parser.cpp @@ -3,7 +3,7 @@ // #include "deal_parser.h" -#include "../../../game/game_state.h" +#include "../../../game/search-state/game_state.h" #include "json_helper.h" using namespace std; @@ -166,9 +166,9 @@ void deal_parser::parse_reserve(game_state &gs, const Document& doc) { json_helper::json_parse_err("Incorrect reserve size"); } - for (game_state::pile_ref i = 0; i < json_card_arr.Size(); i++) { + for (pile::ref i = 0; i < json_card_arr.Size(); i++) { assert(json_card_arr[i].IsString()); - game_state::pile_ref pr = gs.original_reserve[0]; + pile::ref pr = gs.original_reserve[0]; if (!gs.rules.reserve_stacked) pr += i; gs.place_card(pr, card(json_card_arr[i].GetString())); } diff --git a/src/main/input-output/output/state_printer.cpp b/src/main/input-output/output/state_printer.cpp index 0fdacae..9d13129 100644 --- a/src/main/input-output/output/state_printer.cpp +++ b/src/main/input-output/output/state_printer.cpp @@ -55,7 +55,7 @@ void state_printer::print_header(ostream& stream, const char* header) { } void state_printer::print_piles(ostream& stream, - const vector& pile_rs, + const vector& pile_rs, const game_state& gs) { bool empty_row = false; pile::size_type row_idx = 0; @@ -65,7 +65,7 @@ void state_printer::print_piles(ostream& stream, while (!empty_row) { // Loops through the current row to determine if it is empty empty_row = true; - for (const game_state::pile_ref pile_r : pile_rs) { + for (const pile::ref pile_r : pile_rs) { if (gs.piles[pile_r].size() > row_idx) { empty_row = false; break; @@ -73,7 +73,7 @@ void state_printer::print_piles(ostream& stream, } if (!empty_row || row_idx == 0) { // Loops through the current (non-empty) row, and outputs the values - for (const game_state::pile_ref pile_r : pile_rs) { + for (const pile::ref pile_r : pile_rs) { const pile& p = gs.piles[pile_r]; if (p.size() > row_idx) { print_card(stream, p[p.size() - 1 - row_idx]); @@ -90,11 +90,11 @@ void state_printer::print_piles(ostream& stream, } void state_printer::print_top_of_piles(ostream& stream, - const vector& vp, + const vector& vp, const game_state& gs) { - vector top(vp); + vector top(vp); - for (game_state::pile_ref p : top) { + for (pile::ref p : top) { if (gs.piles[p].empty()) { stream << "[]"; } else { @@ -106,7 +106,7 @@ void state_printer::print_top_of_piles(ostream& stream, } void state_printer::print_top_of_pile(ostream& stream, - const game_state::pile_ref pile_r, + const pile::ref pile_r, const game_state& gs) { print_top_of_piles(stream, {pile_r}, gs); } diff --git a/src/main/input-output/output/state_printer.h b/src/main/input-output/output/state_printer.h index ae63182..2b2090b 100644 --- a/src/main/input-output/output/state_printer.h +++ b/src/main/input-output/output/state_printer.h @@ -7,7 +7,7 @@ #include -#include "../../game/game_state.h" +#include "../../game/search-state/game_state.h" class state_printer { public: @@ -16,12 +16,12 @@ public: private: static void print_header(std::ostream&, const char*); static void print_piles(std::ostream&, - const std::vector&, + const std::vector&, const game_state&); static void print_top_of_piles(std::ostream&, - const std::vector&, + const std::vector&, const game_state&); - static void print_top_of_pile(std::ostream&, game_state::pile_ref, + static void print_top_of_pile(std::ostream&, pile::ref, const game_state&); static void print_card(std::ostream&, card); }; -- cgit v1.2.1 From 04cbac28b7d62828dfa43cd77ed8dc790f24237c Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Fri, 8 Jun 2018 14:21:53 +0100 Subject: Fix built move bug and add unit tests --- src/main/input-output/input/sol_preset_types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 07c824b..53141a8 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -312,7 +312,7 @@ map sol_preset_types::mp = { "build policy": "same-suit", "move built group": true }, - "max rank": 5, + "max rank": 6, "foundations initial card": true } )" -- cgit v1.2.1