1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +00:00

Hearts: Pick better non-matching cards

When we don't have a matching card for the lead card rather than
always preferring to play hearts we should try to get rid of our
high value cards first if no other player has hearts cards higher
than what we have.
This commit is contained in:
Gunnar Beutner 2021-06-01 00:40:37 +02:00 committed by Andreas Kling
parent 4a8d8da46c
commit 8b9da08d5a
3 changed files with 18 additions and 8 deletions

View file

@ -356,8 +356,12 @@ size_t Game::pick_card(Player& player)
RETURN_CARD_IF_VALID(player.pick_low_points_high_value_card(m_trick[0].type()));
if (is_first_trick)
return player.pick_low_points_high_value_card().value();
else
return player.pick_max_points_card();
else {
auto ignore_card = [this, &player](Card& card) {
return !other_player_has_higher_value_card(player, card);
};
return player.pick_max_points_card(move(ignore_card));
}
}
RETURN_CARD_IF_VALID(player.pick_lower_value_card(*high_card));
bool is_third_player = m_trick.size() == 2;
@ -382,8 +386,10 @@ size_t Game::pick_card(Player& player)
RETURN_CARD_IF_VALID(player.pick_slightly_higher_value_card(*high_card));
if (is_first_trick)
return player.pick_low_points_high_value_card().value();
else
return player.pick_max_points_card();
auto ignore_card = [this, &player](Card& card) {
return !other_player_has_higher_value_card(player, card);
};
return player.pick_max_points_card(move(ignore_card));
}
void Game::let_player_play_card()