game state: fix taking actions: rotate draw correctly
This commit is contained in:
parent
9af6ef3368
commit
6dd2b07c09
3 changed files with 5 additions and 4 deletions
|
@ -262,6 +262,7 @@ struct Game {
|
||||||
|
|
||||||
std::unique_ptr<HanabiStateIF> state;
|
std::unique_ptr<HanabiStateIF> state;
|
||||||
std::vector<Action> actions;
|
std::vector<Action> actions;
|
||||||
|
std::vector<Card> deck;
|
||||||
unsigned next_action;
|
unsigned next_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -651,8 +651,8 @@ 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>::rotate_next_draw(const Card& card) {
|
void HanabiState<num_suits, num_players, hand_size>::rotate_next_draw(const Card& card) {
|
||||||
auto card_it = std::find_if(_draw_pile.begin(), _draw_pile.end(), [&card](const CardMultiplicity& card_multiplicity){
|
auto card_it = std::find_if(_draw_pile.begin(), _draw_pile.end(), [&card, this](const CardMultiplicity& card_multiplicity){
|
||||||
return card_multiplicity.card.rank == card.rank and card_multiplicity.card.suit == card.suit;
|
return (is_trash(card) and is_trash(card_multiplicity.card)) or (card_multiplicity.card.rank == card.rank and card_multiplicity.card.suit == card.suit);
|
||||||
});
|
});
|
||||||
ASSERT(card_it != _draw_pile.end());
|
ASSERT(card_it != _draw_pile.end());
|
||||||
std::swap(*card_it, _draw_pile.front());
|
std::swap(*card_it, _draw_pile.front());
|
||||||
|
|
|
@ -182,7 +182,7 @@ namespace Download {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (!game_json_opt.has_value() or game_json_opt.value().empty()) {
|
if (!game_json_opt.has_value() or game_json_opt.value().empty()) {
|
||||||
return {nullptr, {}, 0};
|
return {nullptr, {}, {}, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
const boost::json::object& game_json = game_json_opt.value();
|
const boost::json::object& game_json = game_json_opt.value();
|
||||||
|
@ -202,7 +202,7 @@ namespace Download {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return {get_base_state(num_suits, num_players, deck, score_goal), actions, 0};
|
return {get_base_state(num_suits, num_players, deck, score_goal), actions, deck, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Download
|
} // namespace Download
|
||||||
|
|
Loading…
Reference in a new issue