Revert "add more checks: same draw pile after reverting single moves (bug detected)"

This reverts commit a3972fe637.
This commit is contained in:
Maximilian Keßler 2023-11-11 13:32:18 +01:00
parent 6190040c25
commit 571011d7b5
Signed by: max
GPG key ID: BCC5A619923C0BA5
3 changed files with 6 additions and 19 deletions

View file

@ -326,8 +326,7 @@ private:
ActionType action_type, ActionType action_type,
Card discarded_or_played = Cards::unknown, Card discarded_or_played = Cards::unknown,
hand_index_t index = 0, hand_index_t index = 0,
bool was_on_8_clues = false, bool was_on_8_clues = false
std::list<CardMultiplicity> draw_pile = {}
); );
ActionType action_type{}; ActionType action_type{};
@ -339,8 +338,6 @@ private:
// Indicates whether before the action was taken, we had 8 clues. // 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 // 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}; bool was_on_8_clues {false};
std::list<CardMultiplicity> draw_pile;
}; };
// This keeps track of the representation of the gamestate relative to some starting state // This keeps track of the representation of the gamestate relative to some starting state

View file

@ -103,12 +103,12 @@ namespace Hanabi {
template<suit_t num_suits, player_t num_players, hand_index_t hand_size> template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
HanabiState<num_suits, num_players, hand_size>::BacktrackAction::BacktrackAction( HanabiState<num_suits, num_players, hand_size>::BacktrackAction::BacktrackAction(
Hanabi::ActionType action_type, Hanabi::Card discarded_or_played, Hanabi::hand_index_t index, Hanabi::ActionType action_type, Hanabi::Card discarded_or_played, Hanabi::hand_index_t index,
bool was_on_8_clues, std::list<CardMultiplicity> draw_pile bool was_on_8_clues
): ):
action_type(action_type), action_type(action_type),
discarded(discarded_or_played), discarded(discarded_or_played),
index(index), 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<suit_t num_suits, player_t num_players, hand_index_t hand_size> template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
@ -208,7 +208,6 @@ namespace Hanabi {
template<suit_t num_suits, player_t num_players, hand_index_t hand_size> template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
unsigned long HanabiState<num_suits, num_players, hand_size>::play_and_potentially_update(hand_index_t index, bool cycle) { unsigned long HanabiState<num_suits, num_players, hand_size>::play_and_potentially_update(hand_index_t index, bool cycle) {
check_draw_pile_integrity(); check_draw_pile_integrity();
auto copy = _draw_pile;
ASSERT(index < _hands[_turn].size()); ASSERT(index < _hands[_turn].size());
const Card played_card = _hands[_turn][index]; const Card played_card = _hands[_turn][index];
if (!is_playable(played_card)) { if (!is_playable(played_card)) {
@ -218,7 +217,7 @@ namespace Hanabi {
} }
ASSERT(is_playable(played_card)); 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]; --_stacks[played_card.suit];
_score++; _score++;
@ -243,7 +242,6 @@ namespace Hanabi {
template<suit_t num_suits, player_t num_players, hand_index_t hand_size> template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
unsigned long HanabiState<num_suits, num_players, hand_size>::discard_and_potentially_update(hand_index_t index, bool cycle) { unsigned long HanabiState<num_suits, num_players, hand_size>::discard_and_potentially_update(hand_index_t index, bool cycle) {
check_draw_pile_integrity(); check_draw_pile_integrity();
auto copy = _draw_pile;
ASSERT(index < _hands[_turn].size()); ASSERT(index < _hands[_turn].size());
ASSERT(_num_clues != max_num_clues); ASSERT(_num_clues != max_num_clues);
@ -252,7 +250,7 @@ namespace Hanabi {
_pace--; _pace--;
unsigned long multiplicity = draw(index, cycle); 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(); incr_turn();
check_draw_pile_integrity(); check_draw_pile_integrity();
@ -515,10 +513,6 @@ namespace Hanabi {
_stacks[last_action.discarded.suit]++; _stacks[last_action.discarded.suit]++;
} }
_score--; _score--;
if (not cycle)
{
ASSERT(last_action.draw_pile.size() == _draw_pile.size());
}
check_draw_pile_integrity(); check_draw_pile_integrity();
} }
@ -537,10 +531,6 @@ namespace Hanabi {
_pace++; _pace++;
revert_draw(last_action.index, last_action.discarded, cycle); 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(); check_draw_pile_integrity();
} }

View file

@ -1,6 +1,6 @@
#ifndef DYNAMIC_PROGRAM_MYASSERT_H #ifndef DYNAMIC_PROGRAM_MYASSERT_H
#define DYNAMIC_PROGRAM_MYASSERT_H #define DYNAMIC_PROGRAM_MYASSERT_H
#undef NDEBUG
#ifdef NDEBUG #ifdef NDEBUG
#define ASSERT(x) do { (void)sizeof(x);} while (0) #define ASSERT(x) do { (void)sizeof(x);} while (0)
#else #else