fix assertions and when to consider stalling

This commit is contained in:
Maximilian Keßler 2024-01-09 04:13:13 +01:00
parent 486e459c68
commit c6a7eec903
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -91,7 +91,7 @@ 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>
void HanabiState<num_suits, num_players, hand_size>::give_clue() void HanabiState<num_suits, num_players, hand_size>::give_clue()
{ {
ASSERT(_num_clues > 0); ASSERT(_num_clues >= clue_t(1));
--_num_clues; --_num_clues;
_actions_log.emplace(ActionType::clue, Cards::unknown, 0); _actions_log.emplace(ActionType::clue, Cards::unknown, 0);
@ -591,9 +591,10 @@ namespace Hanabi
ASSERT(last_action.action_type == ActionType::discard); ASSERT(last_action.action_type == ActionType::discard);
decr_turn(); decr_turn();
ASSERT(_num_clues > 0);
_num_clues -= _clues_gained_on_discard_or_stack_finished; _num_clues -= _clues_gained_on_discard_or_stack_finished;
ASSERT(_num_clues >= clue_t(0));
_pace++; _pace++;
revert_draw(last_action.index, last_action.discarded, cycle, false); revert_draw(last_action.index, last_action.discarded, cycle, false);
@ -806,7 +807,7 @@ namespace Hanabi
} }
} }
if (_num_clues > 0) if (_num_clues >= clue_t(1))
{ {
give_clue(); give_clue();
const std::optional<probability_t> prob = lookup(); const std::optional<probability_t> prob = lookup();
@ -945,7 +946,7 @@ namespace Hanabi
} }
// Last option is to stall // Last option is to stall
if (_num_clues > 0) if (_num_clues >= clue_t(1))
{ {
give_clue(); give_clue();
const probability_t probability_stall = evaluate_state(); const probability_t probability_stall = evaluate_state();