Disable integrity checks by default
This should speed up the program drastically
This commit is contained in:
parent
835bf3421b
commit
3c1fa0d0e4
1 changed files with 19 additions and 9 deletions
|
@ -4,6 +4,16 @@
|
|||
#include "myassert.h"
|
||||
#include "game_state.h"
|
||||
|
||||
/**
|
||||
* Compiling with -DINTEGRITY_CHECK_ON will enable exhaustive integrity check while backtracking.
|
||||
* These significantly slow down performance, so they are deactivated by default.
|
||||
*/
|
||||
#ifdef INTEGRITY_CHECK_ON
|
||||
#define CHECK_DRAW_PILE_INTEGRITY check_draw_pile_integrity()
|
||||
#else
|
||||
#define CHECK_DRAW_PILE_INTEGRITY
|
||||
#endif
|
||||
|
||||
namespace Hanabi
|
||||
{
|
||||
|
||||
|
@ -186,7 +196,7 @@ namespace Hanabi
|
|||
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;
|
||||
ASSERT(index < _hands[_turn].size());
|
||||
const Card played_card = _hands[_turn][index];
|
||||
|
||||
|
@ -210,7 +220,7 @@ namespace Hanabi
|
|||
const unsigned long multiplicity = draw(index, cycle, !strike);
|
||||
|
||||
incr_turn();
|
||||
check_draw_pile_integrity();
|
||||
CHECK_DRAW_PILE_INTEGRITY;
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
|
@ -224,7 +234,7 @@ namespace Hanabi
|
|||
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;
|
||||
ASSERT(index < _hands[_turn].size());
|
||||
ASSERT(_num_clues != max_num_clues);
|
||||
|
||||
|
@ -238,7 +248,7 @@ namespace Hanabi
|
|||
_actions_log.emplace(ActionType::discard, discarded_card, index);
|
||||
|
||||
incr_turn();
|
||||
check_draw_pile_integrity();
|
||||
CHECK_DRAW_PILE_INTEGRITY;
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
|
@ -589,7 +599,7 @@ namespace Hanabi
|
|||
void
|
||||
HanabiState<num_suits, num_players, hand_size>::revert_play(bool cycle)
|
||||
{
|
||||
check_draw_pile_integrity();
|
||||
CHECK_DRAW_PILE_INTEGRITY;
|
||||
const BacktrackAction last_action = _actions_log.top();
|
||||
_actions_log.pop();
|
||||
ASSERT(last_action.action_type == ActionType::play);
|
||||
|
@ -609,13 +619,13 @@ namespace Hanabi
|
|||
// If we misplayed, then we lost the card and have to regain it now
|
||||
_num_copies_left[last_action.discarded]++;
|
||||
}
|
||||
check_draw_pile_integrity();
|
||||
CHECK_DRAW_PILE_INTEGRITY;
|
||||
}
|
||||
|
||||
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
||||
void HanabiState<num_suits, num_players, hand_size>::revert_discard(bool cycle)
|
||||
{
|
||||
check_draw_pile_integrity();
|
||||
CHECK_DRAW_PILE_INTEGRITY;
|
||||
const BacktrackAction last_action = _actions_log.top();
|
||||
_actions_log.pop();
|
||||
|
||||
|
@ -631,7 +641,7 @@ namespace Hanabi
|
|||
_num_copies_left[last_action.discarded]++;
|
||||
|
||||
revert_draw(last_action.index, last_action.discarded, cycle, false);
|
||||
check_draw_pile_integrity();
|
||||
CHECK_DRAW_PILE_INTEGRITY;
|
||||
}
|
||||
|
||||
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
|
||||
|
@ -1190,7 +1200,7 @@ namespace Hanabi
|
|||
// encode number of clues
|
||||
clue_t const scaled_clues = clue_t(2) * _num_clues;
|
||||
assert(scaled_clues.denominator() == 1);
|
||||
ret.push_back((clue_t(2) * _num_clues).numerator());
|
||||
ret.push_back(scaled_clues.numerator());
|
||||
|
||||
// we can encode draw pile size and extra turn in one metric, since we only have extra turns if draw pile is empty
|
||||
const std::uint8_t draw_pile_size_and_extra_turns = [this]() -> uint8_t {
|
||||
|
|
Loading…
Reference in a new issue