1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 02:37:35 +00:00

Hearts: Let the AI prefer lead cards for which other cards are in play

When picking a lead card the AI should avoid playing cards where it
knows that no other player has a lower value card of the same type.
This commit is contained in:
Gunnar Beutner 2021-05-23 14:49:58 +02:00 committed by Andreas Kling
parent 647d0f9f8a
commit 2dfced2501
3 changed files with 19 additions and 5 deletions

View file

@ -210,7 +210,10 @@ size_t Game::pick_card(Player& player)
auto prefer_card = [this, &player](Card& card) {
return !other_player_has_lower_value_card(player, card) && other_player_has_higher_value_card(player, card);
};
return player.pick_lead_card(move(valid_card), move(prefer_card));
auto lower_value_card_in_play = [this, &player](Card& card) {
return other_player_has_lower_value_card(player, card);
};
return player.pick_lead_card(move(valid_card), move(prefer_card), move(lower_value_card_in_play));
}
}
auto* high_card = &m_trick[0];