diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/evaluation/benchmark.cpp | 14 | ||||
| -rw-r--r-- | src/main/game/global_cache.cpp | 27 | ||||
| -rw-r--r-- | src/main/input-output/input/sol_preset_types.cpp | 88 |
3 files changed, 113 insertions, 16 deletions
diff --git a/src/main/evaluation/benchmark.cpp b/src/main/evaluation/benchmark.cpp index 79e2edc..74d34a3 100644 --- a/src/main/evaluation/benchmark.cpp +++ b/src/main/evaluation/benchmark.cpp @@ -10,14 +10,14 @@ #include "../solver/solver.h" using namespace std; -typedef chrono::milliseconds millisec; +typedef chrono::microseconds microsec; void benchmark::run(const sol_rules &rules) { cout << "Seed " - "| Median Solution Time(ms) " + "| Median Solution Time(μs) " "| Median States Searched " - "| Median (Non-Zero) Solution Depth " "| Median Backtracks " + "| Median (Non-Zero) Solution Depth " "| Solvable/Unsolvable "; multiset<int> sol_times; @@ -34,10 +34,10 @@ void benchmark::run(const sol_rules &rules) { auto start = chrono::steady_clock::now(); solver::sol_state result = sol.run(); auto end = chrono::steady_clock::now(); - millisec elapsed_millis = - chrono::duration_cast<chrono::milliseconds>(end - start); + microsec elapsed_micros = + chrono::duration_cast<chrono::microseconds>(end - start); - sol_times.insert(static_cast<int>(elapsed_millis.count())); + sol_times.insert(static_cast<int>(elapsed_micros.count())); states_searched.insert(sol.get_states_searched()); if (sol.get_final_depth() != 0) sol_depths.insert(sol.get_final_depth()); backtracks.insert(sol.get_backtrack_count()); @@ -56,8 +56,8 @@ void benchmark::run(const sol_rules &rules) { cout << "\n" << seed << " | " << *next(begin(sol_times), (sol_times.size())/2) << " | " << *next(begin(states_searched), (states_searched.size())/2) - << " | " << *next(begin(sol_depths), (sol_depths.size())/2) << " | " << *next(begin(backtracks), (backtracks.size())/2) + << " | " << *next(begin(sol_depths), (sol_depths.size())/2) << " | " << total_solvable << "/" << total_unsolvable; } diff --git a/src/main/game/global_cache.cpp b/src/main/game/global_cache.cpp index 29e8d25..44d4bb7 100644 --- a/src/main/game/global_cache.cpp +++ b/src/main/game/global_cache.cpp @@ -87,9 +87,16 @@ void cached_game_state::add_card(card c, const game_state& gs) { // If the game is a 'hole-based' game, or suit-reduction is on, reduces // the cached suit of the card where possible -#ifndef SUIT_REDUCTION_STREAMLINER - if (gs.rules.hole) { + + bool is_suit_symmetry = gs.rules.hole; +#ifdef SUIT_REDUCTION_STREAMLINER + is_suit_symmetry = true; +#endif +#ifdef NO_SUIT_SYMMETRY + is_suit_symmetry = false; #endif + + if (is_suit_symmetry) { switch (gs.rules.build_pol) { case pol::SAME_SUIT: target.emplace_back(c); @@ -101,11 +108,9 @@ void cached_game_state::add_card(card c, const game_state& gs) { target.emplace_back(0, c.get_rank()); break; } -#ifndef SUIT_REDUCTION_STREAMLINER } else { target.emplace_back(c); } -#endif } void cached_game_state::add_card_divider() { @@ -160,10 +165,16 @@ size_t hasher::hash_value(card const& c) const { // If the game is a 'hole-based' game, or suit-reduction is enabled, hash // the reduced suit - uint8_t suit_val; -#ifndef SUIT_REDUCTION_STREAMLINER - if (init_gs.rules.hole) { + bool is_suit_symmetry = init_gs.rules.hole; +#ifdef SUIT_REDUCTION_STREAMLINER + is_suit_symmetry = true; +#endif +#ifdef NO_SUIT_SYMMETRY + is_suit_symmetry = false; #endif + + uint8_t suit_val; + if (is_suit_symmetry) { switch (init_gs.rules.build_pol) { case pol::SAME_SUIT: suit_val = c.get_suit(); @@ -174,11 +185,9 @@ size_t hasher::hash_value(card const& c) const { default: suit_val = 0; } -#ifndef SUIT_REDUCTION_STREAMLINER } else { suit_val = c.get_suit(); } -#endif auto raw_val = static_cast<uint8_t>(suit_val * 13 + c.get_rank()); return boost_hasher(raw_val); diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index e4d06a3..4afc86f 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -858,6 +858,94 @@ map<string, string> sol_preset_types::mp = { } )" + }, + { + "test-game-black-hole", + + R"( + +{ + "tableau piles": { + "count": 7, + "build policy": "no-build" + }, + "max rank": 8, + "hole": true, + "foundations": false +} +)" + }, + { + "test-game-any-suit", + + R"( + +{ + "tableau piles": { + "count": 5, + "build policy": "any-suit" + }, + "max rank": 6 +} +)" + }, + { + "test-game-red-black", + + R"( + +{ + "tableau piles": { + "count": 7, + "build policy": "red-black" + }, + "max rank": 8 +} +)" + }, + { + "test-game-same-suit", + + R"( + +{ + "tableau piles": { + "count": 10, + "build policy": "same-suit" + }, + "max rank": 9 +} +)" + }, + { + "test-game-founds-removable", + + R"( + +{ + "tableau piles": { + "count": 7, + "build policy": "red-black" + }, + "max rank": 8, + "foundations removable": true +} +)" + }, + { + "test-game-diagonal-deal", + + R"( + +{ + "tableau piles": { + "count": 7, + "build policy": "red-black", + "diagonal deal": true + }, + "max rank": 8 +} +)" } }; |
