From 423be6c01bf3c567bde7b2ec385e098b5bf41af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 6 Aug 2023 22:15:09 +0200 Subject: [PATCH] code cleanup --- game_state.hpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/game_state.hpp b/game_state.hpp index 326a03d..bc4cecf 100644 --- a/game_state.hpp +++ b/game_state.hpp @@ -71,7 +71,6 @@ namespace Hanabi { _weighted_draw_pile_size(deck.size()), _stacks(), _hands(), -// _card_positions(draw_pile), _draw_pile(), _endgame_turns_left(no_endgame), _pace(deck.size() - 5 * num_suits - num_players * (hand_size - 1)), @@ -138,16 +137,14 @@ namespace Hanabi { --_stacks[card.suit]; _score++; - BacktrackAction ret{_hands[_turn][index], index, 0}; - if (card.rank == 0 and _num_clues < max_num_clues) { // update clues if we played the last card of a stack _num_clues++; } - ret.multiplicity = draw(index); - incr_turn(); + BacktrackAction ret{card, index, draw(index)}; + incr_turn(); return ret; } @@ -156,14 +153,13 @@ namespace Hanabi { ASSERT(index < _hands[_turn].size()); ASSERT(_num_clues != max_num_clues); + const Card discarded = _hands[_turn][index]; _num_clues++; _pace--; - BacktrackAction ret{_hands[_turn][index], index}; + BacktrackAction ret{discarded, index, draw(index)}; - ret.multiplicity = draw(index); incr_turn(); - return ret; } @@ -205,9 +201,6 @@ namespace Hanabi { ASSERT(index < _hands[_turn].size()); const Card& discarded = _hands[_turn][index]; - if (_stacks[discarded.suit] > discarded.rank) { -// _card_positions[_hands[_turn][index]] = trash_or_play_stack; - } // draw a new card if the draw pile is not empty if (!_draw_pile.empty()) { @@ -226,10 +219,6 @@ namespace Hanabi { card_in_hand = draw.card; card_in_hand.copy = draw.multiplicity - 1; - if (_stacks[draw.card.suit] > draw.card.rank) { -// _card_positions[card_in_hand] = _turn; - } - if(_draw_pile.empty()) { // Note the +1, since we will immediately decrement this when moving to the next player _endgame_turns_left = num_players + 1; @@ -245,9 +234,6 @@ namespace Hanabi { // Put the card that is currently in hand back into the draw pile ASSERT(index < _hands[_turn].size()); const Card &drawn = _hands[_turn][index]; - if (_stacks[drawn.suit] > drawn.rank) { -// _card_positions[drawn] = draw_pile; - } // put discarded_card back into draw pile (at the back) if (!_draw_pile.empty() and _draw_pile.back().card.suit == drawn.suit and @@ -260,9 +246,6 @@ namespace Hanabi { _endgame_turns_left = no_endgame; } _hands[_turn][index] = discarded_card; - if (_stacks[discarded_card.suit] > discarded_card.rank) { -// _card_positions[discarded_card] = _turn; - } } template @@ -294,7 +277,6 @@ namespace Hanabi { _draw_pile.push_back({card, nums_in_draw_pile[card]}); for (std::uint8_t copy = 0; copy < nums_in_draw_pile[card]; copy++) { card.copy = copy; -// _card_positions[card] = draw_pile; } } }