Fix: Allow user to strikeout

This commit is contained in:
Maximilian Keßler 2024-03-15 14:57:38 +01:00
parent 60c405fa20
commit b966475045
Signed by: max
GPG key ID: BCC5A619923C0BA5
4 changed files with 18 additions and 7 deletions

8
include/deck_generator.h Normal file
View file

@ -0,0 +1,8 @@
//
// Created by maximilian on 3/12/24.
//
#ifndef ENDGAME_ANALYZER_DECK_GENERATOR_H
#define ENDGAME_ANALYZER_DECK_GENERATOR_H
#endif //ENDGAME_ANALYZER_DECK_GENERATOR_H

View file

@ -199,7 +199,7 @@ namespace Hanabi
unsigned long discard_and_potentially_update(hand_index_t index, bool cycle = false);
unsigned long play_and_potentially_update(hand_index_t index, bool cycle = false);
unsigned long play_and_potentially_update(hand_index_t index, bool cycle, bool allow_strikeout);
unsigned draw(hand_index_t index, bool cycle = false, bool played = true);

View file

@ -191,12 +191,12 @@ namespace Hanabi
template<suit_t num_suits, player_t num_players, hand_index_t hand_size>
void HanabiState<num_suits, num_players, hand_size>::play(Hanabi::hand_index_t index)
{
play_and_potentially_update(index);
play_and_potentially_update(index, false, true);
}
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)
HanabiState<num_suits, num_players, hand_size>::play_and_potentially_update(hand_index_t index, bool cycle, bool allow_strikeout)
{
CHECK_DRAW_PILE_INTEGRITY;
ASSERT(index < _hands[_turn].size());
@ -217,7 +217,7 @@ namespace Hanabi
}
} else {
_num_strikes++;
assert(_num_strikes <= max_num_strikes);
ASSERT(_num_strikes <= max_num_strikes or allow_strikeout);
_num_copies_left[played_card]--;
}
@ -806,7 +806,7 @@ namespace Hanabi
{
std::vector<std::pair<Action, std::optional<probability_t>>> actions{};
if (_score == _score_goal or _pace < 0 or _endgame_turns_left == 0)
if (_score == _score_goal or _pace < 0 or _endgame_turns_left == 0 or _num_strikes > max_num_strikes)
{
return actions;
}
@ -1029,7 +1029,7 @@ namespace Hanabi
{
return Factorial::factorial(_weighted_draw_pile_size);
}
if (_pace < 0 || _endgame_turns_left == 0)
if (_pace < 0 || _endgame_turns_left == 0 || _num_strikes > max_num_strikes)
{
return 0;
}
@ -1162,7 +1162,7 @@ namespace Hanabi
auto do_action = [this, index, play]() {
if (play)
{
return play_and_potentially_update(index, true);
return play_and_potentially_update(index, true, false);
}
else
{

3
src/seed_search.cpp Normal file
View file

@ -0,0 +1,3 @@
//
// Created by maximilian on 3/12/24.
//