Clean up boolean logic

This commit is contained in:
timotree3 2022-05-11 15:27:43 -04:00
parent 91fc4c279d
commit ae4f671740
2 changed files with 6 additions and 24 deletions

View file

@ -338,25 +338,14 @@ impl BoardState {
// is never going to play, based on discard + fireworks
pub fn is_dead(&self, card: &Card) -> bool {
let firework = self.fireworks.get(&card.color).unwrap();
if firework.complete() {
true
} else {
let needed = firework.needed_value().unwrap();
if card.value < needed {
true
} else {
card.value > self.highest_attainable(card.color)
}
}
firework.complete()
|| card.value < firework.needed_value().unwrap()
|| card.value > self.highest_attainable(card.color)
}
// can be discarded without necessarily sacrificing score, based on discard + fireworks
pub fn is_dispensable(&self, card: &Card) -> bool {
let firework = self.fireworks.get(&card.color).unwrap();
firework.complete()
|| card.value < firework.needed_value().unwrap()
|| card.value > self.highest_attainable(card.color)
|| self.discard.remaining(card) != 1
self.is_dead(card) || self.discard.remaining(card) != 1
}
pub fn get_players(&self) -> Range<Player> {

View file

@ -577,13 +577,7 @@ impl PublicInformation for MyPublicInformation {
// We don't need to find out anything about cards that are determined or dead.
let augmented_hand_info = augmented_hand_info_raw
.into_iter()
.filter(|&(i, _, p_dead)| {
if p_dead == 1.0 {
false
} else {
!hand_info[i].is_determined()
}
})
.filter(|&(i, _, p_dead)| p_dead != 1.0 && !hand_info[i].is_determined())
.collect::<Vec<_>>();
if !know_playable_card {
@ -902,10 +896,9 @@ impl InformationPlayerStrategy {
true
} else if view.board.discard_size() <= discard_threshold && !useless_indices.is_empty() {
false
}
// hinting is better than discarding dead cards
// (probably because it stalls the deck-drawing).
else if view.board.hints_remaining > 0 && view.someone_else_can_play() {
} else if view.board.hints_remaining > 0 && view.someone_else_can_play() {
true
} else {
// this being false is the only case in which we discard a potentially useful card.