From 571011d7b5ddaf6746dd46d50d6dbbe3da16b3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 11 Nov 2023 13:32:18 +0100 Subject: [PATCH] Revert "add more checks: same draw pile after reverting single moves (bug detected)" This reverts commit a3972fe637894b4a1df46d3796261ce5899b047f. --- include/game_state.h | 5 +---- include/game_state.hpp | 18 ++++-------------- include/myassert.h | 2 +- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/include/game_state.h b/include/game_state.h index 28cafb4..7fb77cd 100644 --- a/include/game_state.h +++ b/include/game_state.h @@ -326,8 +326,7 @@ private: ActionType action_type, Card discarded_or_played = Cards::unknown, hand_index_t index = 0, - bool was_on_8_clues = false, - std::list draw_pile = {} + bool was_on_8_clues = false ); ActionType action_type{}; @@ -339,8 +338,6 @@ private: // Indicates whether before the action was taken, we had 8 clues. // This is important so that we know if we go back to 7 or 8 clues when we revert playing a 5 bool was_on_8_clues {false}; - - std::list draw_pile; }; // This keeps track of the representation of the gamestate relative to some starting state diff --git a/include/game_state.hpp b/include/game_state.hpp index e1bc4fa..e1cbcf5 100644 --- a/include/game_state.hpp +++ b/include/game_state.hpp @@ -103,12 +103,12 @@ namespace Hanabi { template HanabiState::BacktrackAction::BacktrackAction( Hanabi::ActionType action_type, Hanabi::Card discarded_or_played, Hanabi::hand_index_t index, - bool was_on_8_clues, std::list draw_pile + bool was_on_8_clues ): action_type(action_type), discarded(discarded_or_played), index(index), - was_on_8_clues(was_on_8_clues), draw_pile(std::move(draw_pile)) { + was_on_8_clues(was_on_8_clues) { } template @@ -208,7 +208,6 @@ namespace Hanabi { template unsigned long HanabiState::play_and_potentially_update(hand_index_t index, bool cycle) { check_draw_pile_integrity(); - auto copy = _draw_pile; ASSERT(index < _hands[_turn].size()); const Card played_card = _hands[_turn][index]; if (!is_playable(played_card)) { @@ -218,7 +217,7 @@ namespace Hanabi { } ASSERT(is_playable(played_card)); - _actions_log.emplace(ActionType::play, played_card, index, _num_clues == 8, copy); + _actions_log.emplace(ActionType::play, played_card, index, _num_clues == 8); --_stacks[played_card.suit]; _score++; @@ -243,7 +242,6 @@ namespace Hanabi { template unsigned long HanabiState::discard_and_potentially_update(hand_index_t index, bool cycle) { check_draw_pile_integrity(); - auto copy = _draw_pile; ASSERT(index < _hands[_turn].size()); ASSERT(_num_clues != max_num_clues); @@ -252,7 +250,7 @@ namespace Hanabi { _pace--; unsigned long multiplicity = draw(index, cycle); - _actions_log.emplace(ActionType::discard, discarded_card, index, false, copy); + _actions_log.emplace(ActionType::discard, discarded_card, index); incr_turn(); check_draw_pile_integrity(); @@ -515,10 +513,6 @@ namespace Hanabi { _stacks[last_action.discarded.suit]++; } _score--; - if (not cycle) - { - ASSERT(last_action.draw_pile.size() == _draw_pile.size()); - } check_draw_pile_integrity(); } @@ -537,10 +531,6 @@ namespace Hanabi { _pace++; revert_draw(last_action.index, last_action.discarded, cycle); - if (not cycle) - { - ASSERT(last_action.draw_pile.size() == _draw_pile.size()); - } check_draw_pile_integrity(); } diff --git a/include/myassert.h b/include/myassert.h index d854d0e..174f12f 100644 --- a/include/myassert.h +++ b/include/myassert.h @@ -1,6 +1,6 @@ #ifndef DYNAMIC_PROGRAM_MYASSERT_H #define DYNAMIC_PROGRAM_MYASSERT_H -#undef NDEBUG + #ifdef NDEBUG #define ASSERT(x) do { (void)sizeof(x);} while (0) #else