Clean up boolean logic
This commit is contained in:
parent
91fc4c279d
commit
ae4f671740
2 changed files with 6 additions and 24 deletions
19
src/game.rs
19
src/game.rs
|
@ -338,25 +338,14 @@ impl BoardState {
|
||||||
// is never going to play, based on discard + fireworks
|
// is never going to play, based on discard + fireworks
|
||||||
pub fn is_dead(&self, card: &Card) -> bool {
|
pub fn is_dead(&self, card: &Card) -> bool {
|
||||||
let firework = self.fireworks.get(&card.color).unwrap();
|
let firework = self.fireworks.get(&card.color).unwrap();
|
||||||
if firework.complete() {
|
firework.complete()
|
||||||
true
|
|| card.value < firework.needed_value().unwrap()
|
||||||
} else {
|
|| card.value > self.highest_attainable(card.color)
|
||||||
let needed = firework.needed_value().unwrap();
|
|
||||||
if card.value < needed {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
card.value > self.highest_attainable(card.color)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// can be discarded without necessarily sacrificing score, based on discard + fireworks
|
// can be discarded without necessarily sacrificing score, based on discard + fireworks
|
||||||
pub fn is_dispensable(&self, card: &Card) -> bool {
|
pub fn is_dispensable(&self, card: &Card) -> bool {
|
||||||
let firework = self.fireworks.get(&card.color).unwrap();
|
self.is_dead(card) || self.discard.remaining(card) != 1
|
||||||
firework.complete()
|
|
||||||
|| card.value < firework.needed_value().unwrap()
|
|
||||||
|| card.value > self.highest_attainable(card.color)
|
|
||||||
|| self.discard.remaining(card) != 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_players(&self) -> Range<Player> {
|
pub fn get_players(&self) -> Range<Player> {
|
||||||
|
|
|
@ -577,13 +577,7 @@ impl PublicInformation for MyPublicInformation {
|
||||||
// We don't need to find out anything about cards that are determined or dead.
|
// We don't need to find out anything about cards that are determined or dead.
|
||||||
let augmented_hand_info = augmented_hand_info_raw
|
let augmented_hand_info = augmented_hand_info_raw
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|&(i, _, p_dead)| {
|
.filter(|&(i, _, p_dead)| p_dead != 1.0 && !hand_info[i].is_determined())
|
||||||
if p_dead == 1.0 {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
!hand_info[i].is_determined()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if !know_playable_card {
|
if !know_playable_card {
|
||||||
|
@ -902,10 +896,9 @@ impl InformationPlayerStrategy {
|
||||||
true
|
true
|
||||||
} else if view.board.discard_size() <= discard_threshold && !useless_indices.is_empty() {
|
} else if view.board.discard_size() <= discard_threshold && !useless_indices.is_empty() {
|
||||||
false
|
false
|
||||||
}
|
|
||||||
// hinting is better than discarding dead cards
|
// hinting is better than discarding dead cards
|
||||||
// (probably because it stalls the deck-drawing).
|
// (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
|
true
|
||||||
} else {
|
} else {
|
||||||
// this being false is the only case in which we discard a potentially useful card.
|
// this being false is the only case in which we discard a potentially useful card.
|
||||||
|
|
Loading…
Reference in a new issue