From da6dffca0c30563f7df55574ad51d037637ff010 Mon Sep 17 00:00:00 2001 From: timotree3 Date: Thu, 19 Jan 2023 22:33:28 -0500 Subject: [PATCH 1/4] Update results table Changes are probably due to updated rand dependency --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ee7365..9d37100 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ On the first 20000 seeds, we have these scores and win rates (average ± standar |---------|------------------|------------------|------------------|------------------| | cheat | 24.8594 ± 0.0036 | 24.9785 ± 0.0012 | 24.9720 ± 0.0014 | 24.9557 ± 0.0018 | | | 90.59 ± 0.21 % | 98.17 ± 0.09 % | 97.76 ± 0.10 % | 96.42 ± 0.13 % | -| info | 22.5194 ± 0.0125 | 24.7942 ± 0.0039 | 24.9354 ± 0.0022 | 24.9220 ± 0.0024 | -| | 12.58 ± 0.23 % | 84.46 ± 0.26 % | 95.03 ± 0.15 % | 94.01 ± 0.17 % | +| info | 22.5218 ± 0.0125 | 24.7942 ± 0.0039 | 24.9352 ± 0.0022 | 24.9224 ± 0.0024 | +| | 12.55 ± 0.23 % | 84.44 ± 0.26 % | 94.99 ± 0.15 % | 94.04 ± 0.17 % | ## Other work From bbc03bebf34b574a711c20210b0fbba8aeeae5e0 Mon Sep 17 00:00:00 2001 From: timotree3 Date: Thu, 19 Jan 2023 22:33:56 -0500 Subject: [PATCH 2/4] Disallow discarding at 8 clues --- src/game.rs | 5 +++++ src/strategies/cheating.rs | 5 +++++ src/strategies/examples.rs | 42 +++++++++++++++++------------------ src/strategies/information.rs | 6 ++--- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/game.rs b/src/game.rs index a037f0b..449c521 100644 --- a/src/game.rs +++ b/src/game.rs @@ -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()); diff --git a/src/strategies/cheating.rs b/src/strategies/cheating.rs index fe24cd2..fa42c9b 100644 --- a/src/strategies/cheating.rs +++ b/src/strategies/cheating.rs @@ -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 diff --git a/src/strategies/examples.rs b/src/strategies/examples.rs index a944a50..6f3f3eb 100644 --- a/src/strategies/examples.rs +++ b/src/strategies/examples.rs @@ -41,29 +41,27 @@ pub struct RandomStrategyPlayer { impl PlayerStrategy for RandomStrategyPlayer { fn decide(&mut self, view: &BorrowedGameView) -> TurnChoice { let p = rand::random::(); - if p < self.hint_probability { - if view.board.hints_remaining > 0 { - let hint_player = view.board.player_to_left(&self.me); - let hint_card = rand::thread_rng() - .choose(view.get_hand(&hint_player)) - .unwrap(); - let hinted = { - if rand::random() { - // hint a color - Hinted::Color(hint_card.color) - } else { - Hinted::Value(hint_card.value) - } - }; - TurnChoice::Hint(Hint { - player: hint_player, - hinted, - }) - } else { - TurnChoice::Discard(0) - } - } else if p < self.hint_probability + self.play_probability { + 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)) + .unwrap(); + let hinted = { + if rand::random() { + // hint a color + Hinted::Color(hint_card.color) + } else { + Hinted::Value(hint_card.value) + } + }; + TurnChoice::Hint(Hint { + player: hint_player, + hinted, + }) } else { TurnChoice::Discard(0) } diff --git a/src/strategies/information.rs b/src/strategies/information.rs index c56652f..8a98b33 100644 --- a/src/strategies/information.rs +++ b/src/strategies/information.rs @@ -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() { From 5585ca54cb30e1a40b4cb3b0f9cff4ed573a8b0a Mon Sep 17 00:00:00 2001 From: timotree3 Date: Thu, 19 Jan 2023 22:42:52 -0500 Subject: [PATCH 3/4] Update results table after disallowing 8 clues discards --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9d37100..dd7c936 100644 --- a/README.md +++ b/README.md @@ -67,10 +67,10 @@ On the first 20000 seeds, we have these scores and win rates (average ± standar | | 2p | 3p | 4p | 5p | |---------|------------------|------------------|------------------|------------------| -| cheat | 24.8594 ± 0.0036 | 24.9785 ± 0.0012 | 24.9720 ± 0.0014 | 24.9557 ± 0.0018 | -| | 90.59 ± 0.21 % | 98.17 ± 0.09 % | 97.76 ± 0.10 % | 96.42 ± 0.13 % | -| info | 22.5218 ± 0.0125 | 24.7942 ± 0.0039 | 24.9352 ± 0.0022 | 24.9224 ± 0.0024 | -| | 12.55 ± 0.23 % | 84.44 ± 0.26 % | 94.99 ± 0.15 % | 94.04 ± 0.17 % | +| cheat | 24.8209 ± 0.0041 | 24.9781 ± 0.0012 | 24.9734 ± 0.0014 | 24.9618 ± 0.0017 | +| | 88.40 ± 0.23 % | 98.14 ± 0.10 % | 97.83 ± 0.10 % | 97.03 ± 0.12 % | +| info | 22.5217 ± 0.0125 | 24.7946 ± 0.0039 | 24.9356 ± 0.0022 | 24.9223 ± 0.0024 | +| | 12.55 ± 0.23 % | 84.48 ± 0.26 % | 95.05 ± 0.15 % | 94.04 ± 0.17 % | ## Other work From c08aa2a8888013c844952a98cc925acf074ef6f1 Mon Sep 17 00:00:00 2001 From: timotree3 Date: Thu, 19 Jan 2023 22:45:07 -0500 Subject: [PATCH 4/4] Rename clue -> hint --- src/game.rs | 2 +- src/strategies/cheating.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game.rs b/src/game.rs index 449c521..4e92989 100644 --- a/src/game.rs +++ b/src/game.rs @@ -656,7 +656,7 @@ impl GameState { TurnChoice::Discard(index) => { assert!( self.board.hints_remaining < self.board.hints_total, - "Tried to discard while at max clue count" + "Tried to discard while at max hint count" ); let card = self.take_from_hand(index); diff --git a/src/strategies/cheating.rs b/src/strategies/cheating.rs index fa42c9b..fd9bc94 100644 --- a/src/strategies/cheating.rs +++ b/src/strategies/cheating.rs @@ -163,7 +163,7 @@ impl PlayerStrategy for CheatingPlayerStrategy { return TurnChoice::Play(index); } - // cannot discard while at max clue count + // cannot discard while at max hint count if view.board.hints_remaining == view.board.hints_total { return self.throwaway_hint(view); }