From e8c09d96339f44e8db5ace117afc41340c03a432 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sat, 24 Feb 2018 11:57:27 +0000 Subject: Add command line option to calculate solvability --- src/main/main.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/main/main.cpp') diff --git a/src/main/main.cpp b/src/main/main.cpp index be03e02..690a20b 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -21,6 +21,7 @@ const optional gen_rules(command_line_helper&); void solve_random_game(int, const sol_rules&, bool); void solve_input_files(vector, const sol_rules&, bool); void solve_game(const game_state&, bool); +void calculate_solvability_percentage(const sol_rules&); int main(int argc, const char* argv[]) { @@ -34,16 +35,21 @@ int main(int argc, const char* argv[]) { const optional rules = gen_rules(clh); if (!rules) return EXIT_FAILURE; - // Retrieves the input files to be solved - const vector input_files = clh.get_input_files(); - - // If there are no input files, solve a random deal based on the - // supplied seed - if (input_files.empty()) { + // If the user has asked for a solvability percentage, calculates it + if (clh.get_solvability()) { + calculate_solvability_percentage(*rules); + } + // If a random deal seed has been supplied, solves it + else if (clh.get_random_deal() != -1) { solve_random_game(clh.get_random_deal(), *rules, clh.get_classify()); } - // Otherwise, solve the input files + // Otherwise there are supplied input files which should be solved else { + const vector input_files = clh.get_input_files(); + + // If there are no input files, solve a random deal based on the + // supplied seed + assert (!input_files.empty()); solve_input_files(input_files, *rules, clh.get_classify()); } @@ -113,3 +119,8 @@ void solve_game(const game_state& gs, bool classify) { } } } + +void calculate_solvability_percentage(const sol_rules& rules) { + cout << "TODO: calculate solvability percentage"; + cout << rules.hole; +} -- cgit v1.2.1