Disallow discarding at 8 clues
This commit is contained in:
parent
da6dffca0c
commit
bbc03bebf3
4 changed files with 33 additions and 25 deletions
|
@ -654,6 +654,11 @@ impl GameState {
|
|||
TurnResult::Hint(results)
|
||||
}
|
||||
TurnChoice::Discard(index) => {
|
||||
assert!(
|
||||
self.board.hints_remaining < self.board.hints_total,
|
||||
"Tried to discard while at max clue count"
|
||||
);
|
||||
|
||||
let card = self.take_from_hand(index);
|
||||
debug!("Discard card in position {}, which is {}", index, card);
|
||||
self.board.discard.place(card.clone());
|
||||
|
|
|
@ -163,6 +163,11 @@ impl PlayerStrategy for CheatingPlayerStrategy {
|
|||
return TurnChoice::Play(index);
|
||||
}
|
||||
|
||||
// cannot discard while at max clue count
|
||||
if view.board.hints_remaining == view.board.hints_total {
|
||||
return self.throwaway_hint(view);
|
||||
}
|
||||
|
||||
// discard threshold is how many cards we're willing to discard
|
||||
// such that if we only played,
|
||||
// we would not reach the final countdown round
|
||||
|
|
|
@ -41,8 +41,11 @@ pub struct RandomStrategyPlayer {
|
|||
impl PlayerStrategy for RandomStrategyPlayer {
|
||||
fn decide(&mut self, view: &BorrowedGameView) -> TurnChoice {
|
||||
let p = rand::random::<f64>();
|
||||
if p < self.hint_probability {
|
||||
if view.board.hints_remaining > 0 {
|
||||
if p < self.play_probability {
|
||||
TurnChoice::Play(0)
|
||||
} else if view.board.hints_remaining == view.board.hints_total
|
||||
|| (view.board.hints_remaining > 0 && p < self.play_probability + self.hint_probability)
|
||||
{
|
||||
let hint_player = view.board.player_to_left(&self.me);
|
||||
let hint_card = rand::thread_rng()
|
||||
.choose(view.get_hand(&hint_player))
|
||||
|
@ -62,11 +65,6 @@ impl PlayerStrategy for RandomStrategyPlayer {
|
|||
} else {
|
||||
TurnChoice::Discard(0)
|
||||
}
|
||||
} else if p < self.hint_probability + self.play_probability {
|
||||
TurnChoice::Play(0)
|
||||
} else {
|
||||
TurnChoice::Discard(0)
|
||||
}
|
||||
}
|
||||
fn update(&mut self, _: &TurnRecord, _: &BorrowedGameView) {}
|
||||
}
|
||||
|
|
|
@ -889,9 +889,9 @@ impl InformationPlayerStrategy {
|
|||
self.find_useless_cards(&view.board, &public_info.get_player_info(me));
|
||||
let useless_indices = self.find_useless_cards(&view.board, &private_info);
|
||||
|
||||
// NOTE When changing this, make sure to keep the "discard" branch of update() up to date!
|
||||
let will_hint = if view.board.hints_remaining > 0
|
||||
&& public_info.someone_else_needs_hint(view)
|
||||
// NOTE When changing this, make sure to keep the "discard" branch of update_wrapped() up to date!
|
||||
let will_hint = if view.board.hints_remaining == view.board.hints_total
|
||||
|| (view.board.hints_remaining > 0 && public_info.someone_else_needs_hint(view))
|
||||
{
|
||||
true
|
||||
} else if view.board.discard_size() <= discard_threshold && !useless_indices.is_empty() {
|
||||
|
|
Loading…
Reference in a new issue