From ae4f67174016cf825ade55d80a8d92d541c73bbe Mon Sep 17 00:00:00 2001 From: timotree3 Date: Wed, 11 May 2022 15:27:43 -0400 Subject: [PATCH] Clean up boolean logic --- src/game.rs | 19 ++++--------------- src/strategies/information.rs | 11 ++--------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/game.rs b/src/game.rs index 49dca76..ed80aa1 100644 --- a/src/game.rs +++ b/src/game.rs @@ -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 { diff --git a/src/strategies/information.rs b/src/strategies/information.rs index 8ab6c24..c56652f 100644 --- a/src/strategies/information.rs +++ b/src/strategies/information.rs @@ -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::>(); 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.