From e4cc1d4f6166f6dcddc38c944f80053cd2d9ee88 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 16 Sep 2018 22:09:51 +0100 Subject: Add parsing logic for auto-waste-then-stock spaces --- src/main/game/sol_rules.h | 3 ++- src/main/input-output/input/json-parsing/rules_parser.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 5e2dd40..642e4a6 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -26,7 +26,8 @@ struct sol_rules { NO_BUILD, KINGS, ANY, - AUTO_RESERVE_THEN_WASTE + AUTO_RESERVE_THEN_WASTE, + AUTO_WASTE_THEN_STOCK }; enum class accordion_policy { SAME_RANK, 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 a7c4fae..2698e68 100644 --- a/src/main/input-output/input/json-parsing/rules_parser.cpp +++ b/src/main/input-output/input/json-parsing/rules_parser.cpp @@ -121,6 +121,8 @@ void rules_parser::modify_sol_rules(sol_rules& sr, Document& d) { sr.spaces_pol = s_pol::KINGS; } else if (sp_str == "auto-reserve-then-waste") { sr.spaces_pol = s_pol::AUTO_RESERVE_THEN_WASTE; + } else if (sp_str == "auto-waste-then-stock") { + sr.spaces_pol = s_pol::AUTO_WASTE_THEN_STOCK; } else { json_helper::json_parse_err("[tableau piles][spaces policy] is invalid"); } @@ -543,7 +545,8 @@ string rules_parser::rules_schema_json() { "any", "no-build", "kings", - "auto-reserve-then-waste" + "auto-reserve-then-waste", + "auto-waste-then-stock" ] }, "diagonal deal": { -- cgit v1.2.1 From fc981dd44fa25e5ea7fb22f4020d3f67fe0c861a Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 16 Sep 2018 23:03:07 +0100 Subject: Add logic for auto-waste-then-stock --- .../game/search-state/game_state.dominance_moves.cpp | 20 ++++++++++++++++++++ src/main/game/search-state/game_state.h | 1 + src/main/input-output/input/sol_preset_types.cpp | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/game/search-state/game_state.dominance_moves.cpp b/src/main/game/search-state/game_state.dominance_moves.cpp index bc20cb5..d0b4b43 100644 --- a/src/main/game/search-state/game_state.dominance_moves.cpp +++ b/src/main/game/search-state/game_state.dominance_moves.cpp @@ -71,6 +71,9 @@ optional game_state::get_dominance_move() const { if (rules.spaces_pol == s_pol::AUTO_RESERVE_THEN_WASTE) { optional arm = auto_reserve_move(); if (arm) return arm; + } else if (rules.spaces_pol == s_pol::AUTO_WASTE_THEN_STOCK) { + optional awsm = auto_waste_stock_move(); + if (awsm) return awsm; } // If there are 2 decks or no foundations, return @@ -124,6 +127,23 @@ optional game_state::auto_reserve_move() const { return boost::none; } +optional game_state::auto_waste_stock_move() const { + if (!piles[waste].empty()) { + for (auto to : tableau_piles) { + if (piles[to].empty()) { + return move(move::mtype::dominance, waste, to); + } + } + } else if (!piles[stock].empty()) { + for (auto to : tableau_piles) { + if (piles[to].empty()) { + return move(move::mtype::dominance, stock, to); + } + } + } + return boost::none; +} + bool game_state::is_ordered_pile(pile::ref pr) const { if (piles[pr].size() != rules.max_rank) return false; diff --git a/src/main/game/search-state/game_state.h b/src/main/game/search-state/game_state.h index 3df67ec..08391d6 100644 --- a/src/main/game/search-state/game_state.h +++ b/src/main/game/search-state/game_state.h @@ -132,6 +132,7 @@ private: /* Auto-foundation moves */ boost::optional auto_reserve_move() const; + boost::optional auto_waste_stock_move() const; bool is_valid_auto_foundation_move(pile::ref) const; bool is_ordered_pile(pile::ref) const; bool dominance_blocks_foundation_move(pile::ref); diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 9ddf933..1f2df69 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -200,7 +200,8 @@ map sol_preset_types::mp = { { "tableau piles": { "count": 12, - "build policy": "same-suit" + "build policy": "same-suit", + "spaces policy": "auto-waste-then-stock" }, "foundations": { "initial cards": "all" -- cgit v1.2.1 From 4d0dec6b939a29be133ce3dbca842305870ed807 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 16 Sep 2018 23:19:44 +0100 Subject: Change vbar csv to comma and add overall sol col --- src/main/main.cpp | 4 ++++ src/main/solver/solver.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/main.cpp b/src/main/main.cpp index cb63634..808ee78 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -149,9 +149,13 @@ void solve_game(const sol_rules& rules, command_line_helper& clh, optional if (smart) { if (run_again) { solver::print_result_csv(streamliner_solution->second); + cout << ", " << streamliner_solution->second.sol_type; } else { solver::print_null_seed_info(); + cout << ", " << solution.second.sol_type; } + } else { + cout << ", " << solution.second.sol_type; } cout << "\n"; } else { diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp index 1d0130c..3740a15 100644 --- a/src/main/solver/solver.cpp +++ b/src/main/solver/solver.cpp @@ -253,7 +253,7 @@ void solver::print_header(long t, command_line_helper::streamliner_opt stream_op ", Timed-out" ", Memory Limited, "; if (stream_opt == command_line_helper::streamliner_opt::SMART) { - cout << "| (Streamliner Results:) " + cout << ", (Streamliner Results:) " "Attempted Seed" ", Outcome" ", Time Taken(ms)" @@ -266,7 +266,7 @@ void solver::print_header(long t, command_line_helper::streamliner_opt stream_op ", Final Buckets In Cache" ", Maximum Search Depth" ", Final Search Depth" - "| (Non-Streamliner Results:) "; + ", (Non-Streamliner Results:) "; } cout << "Attempted Seed" ", Outcome" @@ -280,13 +280,13 @@ void solver::print_header(long t, command_line_helper::streamliner_opt stream_op ", Final Buckets In Cache" ", Maximum Search Depth" ", Final Search Depth" - ", Seeds In Progress ..." + ", Overall Result" "\n--- Timeout = " << t << " milliseconds ---\n"; cout << fixed << setprecision(3); } void solver::print_result_csv(solver::result res) { - cout << "| " << res.sol_type + cout << ", " << res.sol_type << ", " << res.time.count() << ", " << res.states_searched << ", " << res.unique_states_searched @@ -300,7 +300,7 @@ void solver::print_result_csv(solver::result res) { } void solver::print_null_seed_info() { - cout << "| , , , , , , , , , , "; + cout << ", , , , , , , , , , , , "; } const vector solver::get_frontier() const { -- cgit v1.2.1