mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
Hearts: Prefer to play Queen of Spades when we're the trailing player
Previously in a trick like 2S, KS, 5S we'd rather follow up with AS instead of QS. We should prefer to play QS in this case.
This commit is contained in:
parent
0dd22c4e23
commit
c2a4b581fe
1 changed files with 6 additions and 6 deletions
|
@ -180,6 +180,12 @@ size_t Game::pick_card(Player& player)
|
|||
} else
|
||||
return player.pick_low_points_low_value_card();
|
||||
}
|
||||
auto* high_card = &m_trick[0];
|
||||
for (auto& card : m_trick)
|
||||
if (high_card->type() == card.type() && hearts_card_value(card) > hearts_card_value(*high_card))
|
||||
high_card = &card;
|
||||
if (high_card->type() == Card::Type::Spades && hearts_card_value(*high_card) > CardValue::Queen)
|
||||
RETURN_CARD_IF_VALID(player.pick_specific_card(Card::Type::Spades, CardValue::Queen));
|
||||
auto card_has_points = [](Card& card) { return hearts_card_points(card) > 0; };
|
||||
auto trick_has_points = m_trick.first_matching(card_has_points).has_value();
|
||||
bool is_trailing_player = m_trick.size() == 3;
|
||||
|
@ -190,12 +196,6 @@ size_t Game::pick_card(Player& player)
|
|||
else
|
||||
return player.pick_max_points_card();
|
||||
}
|
||||
auto* high_card = &m_trick[0];
|
||||
for (auto& card : m_trick)
|
||||
if (high_card->type() == card.type() && hearts_card_value(card) > hearts_card_value(*high_card))
|
||||
high_card = &card;
|
||||
if (!is_first_trick && high_card->type() == Card::Type::Spades && hearts_card_value(*high_card) > CardValue::Queen)
|
||||
RETURN_CARD_IF_VALID(player.pick_specific_card(Card::Type::Spades, CardValue::Queen));
|
||||
RETURN_CARD_IF_VALID(player.pick_lower_value_card(*high_card));
|
||||
if (!is_trailing_player)
|
||||
RETURN_CARD_IF_VALID(player.pick_slightly_higher_value_card(*high_card));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue