Merge pull request #15 from timotree3/8-clue-discards

Disallow 8 clue discards
This commit is contained in:
Jeff Wu 2023-01-19 20:01:11 -08:00 committed by GitHub
commit 01b60c6019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 29 deletions

View File

@ -67,10 +67,10 @@ On the first 20000 seeds, we have these scores and win rates (average ± standar
| | 2p | 3p | 4p | 5p | | | 2p | 3p | 4p | 5p |
|---------|------------------|------------------|------------------|------------------| |---------|------------------|------------------|------------------|------------------|
| cheat | 24.8594 ± 0.0036 | 24.9785 ± 0.0012 | 24.9720 ± 0.0014 | 24.9557 ± 0.0018 | | cheat | 24.8209 ± 0.0041 | 24.9781 ± 0.0012 | 24.9734 ± 0.0014 | 24.9618 ± 0.0017 |
| | 90.59 ± 0.21 % | 98.17 ± 0.09 % | 97.76 ± 0.10 % | 96.42 ± 0.13 % | | | 88.40 ± 0.23 % | 98.14 ± 0.10 % | 97.83 ± 0.10 % | 97.03 ± 0.12 % |
| info | 22.5194 ± 0.0125 | 24.7942 ± 0.0039 | 24.9354 ± 0.0022 | 24.9220 ± 0.0024 | | info | 22.5217 ± 0.0125 | 24.7946 ± 0.0039 | 24.9356 ± 0.0022 | 24.9223 ± 0.0024 |
| | 12.58 ± 0.23 % | 84.46 ± 0.26 % | 95.03 ± 0.15 % | 94.01 ± 0.17 % | | | 12.55 ± 0.23 % | 84.48 ± 0.26 % | 95.05 ± 0.15 % | 94.04 ± 0.17 % |
## Other work ## Other work

View File

@ -654,6 +654,11 @@ impl GameState {
TurnResult::Hint(results) TurnResult::Hint(results)
} }
TurnChoice::Discard(index) => { TurnChoice::Discard(index) => {
assert!(
self.board.hints_remaining < self.board.hints_total,
"Tried to discard while at max hint count"
);
let card = self.take_from_hand(index); let card = self.take_from_hand(index);
debug!("Discard card in position {}, which is {}", index, card); debug!("Discard card in position {}, which is {}", index, card);
self.board.discard.place(card.clone()); self.board.discard.place(card.clone());

View File

@ -163,6 +163,11 @@ impl PlayerStrategy for CheatingPlayerStrategy {
return TurnChoice::Play(index); return TurnChoice::Play(index);
} }
// cannot discard while at max hint 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 // discard threshold is how many cards we're willing to discard
// such that if we only played, // such that if we only played,
// we would not reach the final countdown round // we would not reach the final countdown round

View File

@ -41,8 +41,11 @@ pub struct RandomStrategyPlayer {
impl PlayerStrategy for RandomStrategyPlayer { impl PlayerStrategy for RandomStrategyPlayer {
fn decide(&mut self, view: &BorrowedGameView) -> TurnChoice { fn decide(&mut self, view: &BorrowedGameView) -> TurnChoice {
let p = rand::random::<f64>(); let p = rand::random::<f64>();
if p < self.hint_probability { if p < self.play_probability {
if view.board.hints_remaining > 0 { 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_player = view.board.player_to_left(&self.me);
let hint_card = rand::thread_rng() let hint_card = rand::thread_rng()
.choose(view.get_hand(&hint_player)) .choose(view.get_hand(&hint_player))
@ -62,11 +65,6 @@ impl PlayerStrategy for RandomStrategyPlayer {
} else { } else {
TurnChoice::Discard(0) 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) {} fn update(&mut self, _: &TurnRecord, _: &BorrowedGameView) {}
} }

View File

@ -889,9 +889,9 @@ impl InformationPlayerStrategy {
self.find_useless_cards(&view.board, &public_info.get_player_info(me)); self.find_useless_cards(&view.board, &public_info.get_player_info(me));
let useless_indices = self.find_useless_cards(&view.board, &private_info); 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! // 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 > 0 let will_hint = if view.board.hints_remaining == view.board.hints_total
&& public_info.someone_else_needs_hint(view) || (view.board.hints_remaining > 0 && public_info.someone_else_needs_hint(view))
{ {
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() {