aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
authorCharlie Blake2018-06-10 00:30:55 +0100
committerGitHub2018-06-10 00:30:55 +0100
commitd82642305dbcf53262ff41705a41c6e7c1591161 (patch)
treeb2bbe8c0aadaec16280f020e55eb55955be43d3f /src/main/input-output
parentMerge pull request #58 from thecharlesblake/fin (diff)
parentFinish refactoring game state class (diff)
downloadmetasol-d82642305dbcf53262ff41705a41c6e7c1591161.tar.gz
metasol-d82642305dbcf53262ff41705a41c6e7c1591161.zip

Merge pull request #59 from thecharlesblake/paper-tidy-up

Paper tidy up

Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/input/command_line_helper.cpp22
-rw-r--r--src/main/input-output/input/command_line_helper.h4
-rw-r--r--src/main/input-output/input/json-parsing/deal_parser.cpp6
-rw-r--r--src/main/input-output/input/sol_preset_types.cpp2
-rw-r--r--src/main/input-output/output/state_printer.cpp14
-rw-r--r--src/main/input-output/output/state_printer.h8
6 files changed, 15 insertions, 41 deletions
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<string> 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;
};
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/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<string, string> sol_preset_types::mp = {
"build policy": "same-suit",
"move built group": true
},
- "max rank": 5,
+ "max rank": 6,
"foundations initial card": true
}
)"
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<game_state::pile_ref>& pile_rs,
+ const vector<pile::ref>& 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<game_state::pile_ref>& vp,
+ const vector<pile::ref>& vp,
const game_state& gs) {
- vector<game_state::pile_ref> top(vp);
+ vector<pile::ref> 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 <ostream>
-#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<game_state::pile_ref>&,
+ const std::vector<pile::ref>&,
const game_state&);
static void print_top_of_piles(std::ostream&,
- const std::vector<game_state::pile_ref>&,
+ const std::vector<pile::ref>&,
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);
};