From 5ab753850621032148c9a816db80aa02133bb1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 6 Aug 2023 15:04:31 +0200 Subject: [PATCH] code cleanup --- game_state.hpp | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/game_state.hpp b/game_state.hpp index 82e5a46..d8bf18b 100644 --- a/game_state.hpp +++ b/game_state.hpp @@ -337,7 +337,6 @@ namespace Hanabi { template double HanabiState::backtrack(size_t depth) { -// std::cout << *this << std::endl; if (_score == 5 * num_suits) { return 1; } @@ -354,32 +353,20 @@ namespace Hanabi { // First, check for playables for(std::uint8_t index = 0; index < hand_size; index++) { if(is_playable(hand[index])) { -// std::cout << std::string("---------------------", depth) << "playing " << hand[index] << std::endl; if (_draw_pile.empty()) { auto copy = *this; BacktrackAction action = play(index); const double probability_for_this_play = backtrack(depth + 1); revert(action); - if (!same_up_to_discard_permutation(*this, copy)) { - std::cout << "detected faulty backtrack" << std::endl; - std::cout << *this << std::endl; - std::cout << copy << std::endl; - ASSERT(this->_hands == copy._hands); - ASSERT(this->_draw_pile == copy._draw_pile); - ASSERT(this->_endgame_turns_left == copy._endgame_turns_left); - ASSERT(false); - } UPDATE_PROBABILITY(probability_for_this_play); } else { double sum_of_probabilities = 0; uint8_t sum_of_mults = 0; for (size_t i = 0; i < _draw_pile.size(); i++) { - auto copy = *this; BacktrackAction action = play(index); sum_of_probabilities += backtrack(depth + 1) * action.multiplicity; sum_of_mults += action.multiplicity; revert(action); - ASSERT(same_up_to_discard_permutation(*this, copy)); ASSERT(sum_of_mults <= _weighted_draw_pile_size); } ASSERT(sum_of_mults == _weighted_draw_pile_size); @@ -393,40 +380,19 @@ namespace Hanabi { if(_pace > 0) { for(std::uint8_t index = 0; index < hand_size; index++) { if (is_trash(hand[index])) { -// std::cout << std::string("---------------------------", depth) << "discarding " << hand[index] << std::endl; double sum_of_probabilities = 0; if (_draw_pile.empty()) { - auto copy = *this; BacktrackAction action = discard(index); const double probability_for_this_discard = backtrack(depth + 1); revert(action); - if (!same_up_to_discard_permutation(*this, copy)) { - std::cout << "detected faulty backtrack" << std::endl; - std::cout << *this << std::endl; - std::cout << copy << std::endl; - ASSERT(this->_hands == copy._hands); - ASSERT(this->_draw_pile == copy._draw_pile); - ASSERT(this->_endgame_turns_left == copy._endgame_turns_left); - ASSERT(false); - } UPDATE_PROBABILITY(probability_for_this_discard); } else { uint8_t sum_of_mults = 0; for (size_t i = 0; i < _draw_pile.size(); i++) { - auto copy = *this; BacktrackAction action = discard(index); sum_of_probabilities += backtrack(depth + 1) * action.multiplicity; sum_of_mults += action.multiplicity; revert(action); - if (!same_up_to_discard_permutation(*this, copy)) { - std::cout << "detected faulty backtrack" << std::endl; - std::cout << *this << std::endl; - std::cout << copy << std::endl; - ASSERT(this->_hands == copy._hands); - ASSERT(this->_draw_pile == copy._draw_pile); - ASSERT(this->_endgame_turns_left == copy._endgame_turns_left); - ASSERT(false); - } } ASSERT(sum_of_mults == _weighted_draw_pile_size); const double probability_discard = sum_of_probabilities / _weighted_draw_pile_size; @@ -441,12 +407,9 @@ namespace Hanabi { // Last option is to stall if(_num_clues > 0) { -// std::cout << std::string("--------------------", depth) << "stalling " << std::endl; - auto copy = *this; BacktrackAction action = clue(); const double probability_stall = backtrack(depth + 1); revert(action); - ASSERT(same_up_to_discard_permutation(*this, copy)); UPDATE_PROBABILITY(probability_stall); }