Commit graph

71 commits

Author SHA1 Message Date
Felix Bauckholt
9364a06862 Improve ask_question strategy
I also replaced the callback architecture behind
`PublicInformation.ask_questions()` with a simpler method
`PublicInformation.ask_question()` that gets called repeatedly.

To make all float-based sorts easier, I used the `float-ord` package.
I also used it to clean up some of the sorting in `decide_wrapped()`.
2019-03-15 13:45:17 +01:00
Felix Bauckholt
051ac7a097 Modulus magic!
Suppose we have `total_information` choices, and we first use them to
encode the answer `x` to a question with `m` answers. That answer is encoded
by the choice we take modulo `m`.

How much "information" do we have left? That depends on the number of
numbers less than `total_information` that are equal to `x` modulo `m`.
Depending on the value of `x`, this is either
`floor(total_information/m)` or `floor(total_information/m) + 1`.

We now use all of this information as opposed to just
`floor(total_information/m)`, at the cost of making our math not a lot
more complicated but pretty confusing.
2019-03-07 22:48:14 +01:00
Felix Bauckholt
8ed01d47ca Slight changes to be more information-efficient
- If a player discards because nobody else needed a hint, that
  information is "transmitted" before they transmit other info through
  hat stuff.
- The "card possibility partition" questions now take into account info
  learned through earlier questions.
2019-03-07 22:29:20 +01:00
Felix Bauckholt
493631dad0 Refactor out a "public information object"
One important change is that now, when deciding which questions to ask, they can see the answer to the last question before asking the next one.

Some design choices:
- Questions now take a BoardState instead of an OwnedGameView.
- When deciding which questions to ask (in ask_questions), we get an immutable public information object
  (representing the public information before any questions were asked), and a mutable HandInfo<CardPossibilityTable>
  that gets updated as we ask questions. That HandInfo<CardPossibilityTable> was copied instead of taken.
- In ask_questions, we also get some &mut u32 representing "info_remaining" that gets updated for us.
  This will later allow for cases where "info_remaining" depends on the answers to previous questions.
- Both get_hint_sum and update_from_hint_sum change the public information object. If you want to compute the
  hint sum but aren't sure if you actually want to give the hint, you'll have to clone the public information
  object!
- Over time, in the code to decide on a move, we'll be able to build an increasingly complicated tree of
  "public information object operations" that will have to be matched exactly in the code to update on a move.
  In order to make this less scary, I moved most of the code into
  "decide_wrapped" and "update_wrapped". If the call to update_wrapped
  (for the player who just made the move) changes the public information
  object in different ways than the previous call to decide_wrapped, we
  detect this and panic.

This commit should be purely refactoring; all changes to win-rates are
due to bugs.
2019-03-07 22:04:06 +01:00
Felix Bauckholt
e510f7cc5e Switch around ordering of question combining
This has the advantage that for some ModulusInformation object m and
some modulus,

```
a = m.split(modulus);
m.cast_down(x);
```

is equivalent to

```
m.cast_down(x*modulus);
a = m.split(modulus);
```

This means that when using a ModulusInformation object to answer
questions, we can answer the first question without needing to know how
many questions there are.
2019-03-07 21:52:33 +01:00
Felix Bauckholt
96da95dbba Oops I had accidentally left bogus numbers in the last commit
Sorry :(
2019-03-07 21:38:55 +01:00
Felix Bauckholt
92aa0e703a
Merge pull request #9 from felixbauckholt/determinism
Determinism
2019-03-07 20:56:05 +01:00
Felix Bauckholt
8337c61ea2 Auto-update README.md with cargo run --release -- --write-results-table 2019-03-07 19:12:31 +01:00
Felix Bauckholt
ef860fa73b Make runs reproducible by replacing HashMaps with FnvHashMaps 2019-03-07 13:54:30 +01:00
Felix Bauckholt
e04d242a71 Bug fixes 2019-03-06 12:23:21 +01:00
Felix Bauckholt
5540d1c4c6 Add helper method knows_playable_card 2019-02-27 13:20:59 +01:00
Felix Bauckholt
35502541a2 If a player discards because nobody needed a hint, make that common knowledge
"Needing a hint" is defined as having a playable card, but not knowing
any specific card is playable. Thus, if a player doesn't know any
playable cards and someone else discards, the player (publicly)
concludes that all their cards are unplayable.
2019-02-26 22:51:04 -08:00
Felix Bauckholt
7ace892f40 Make better decisions between hinting and discarding
I think most of the gains of this change come from the fact
that now we don't discard any potentially useful cards if we have more
than 4 hints remaining.
2019-02-26 22:51:04 -08:00
Felix Bauckholt
b3a8209b74 Slight refactoring
- Remove some duplication in InformationPlayerStrategy::decide()
- Add method GameView::get_other_players()
2019-02-26 22:51:04 -08:00
Felix Bauckholt
385feeb6ba Slight tweaks that increase 3-player win rate to 75%
- When there are less than 5 players, and we're near the discard threshold, prefer
  hinting over discarding, even if there are known useless cards.

- We now ask questions like "what's the first playable card in this list?"

  This means that if a playable card is in the asking player's list,
  the player will learn that it's playable, and that every card before
  it is not playable.

  Additionally, if a player doesn't know of any dead cards in their hand
  and there is enough information available, we use this mechanism so that
  if the player doesn't have a playable card, they will learn about one
  dead card in their hand.

(These were two commits that got joined in a rebase accident, sorry.)
2019-02-21 10:19:54 -08:00
Jeff Wu
737085948e compiled with new rustc 2018-03-24 09:36:25 -07:00
Jeff Wu
bd3824dc7d
Fix broken table 2018-03-23 19:29:59 -07:00
Jeff Wu
9214006ccb Merge pull request #2 from tjhance/use-4-hints-per-player
in some situations, allow 4 possible hints for some players
2016-06-22 08:17:52 -07:00
Travis Hance
0e5f34275e in some situations, allow 4 possible hints for some players rather than just 3
In particular, do this when for a player when it is public knowledge
that they have at least 2 distinct numbers and 2 distinct colos
2016-06-22 01:03:17 -07:00
Jeff Wu
cab576f883 minor cleanups 2016-04-04 00:49:10 -07:00
Jeff Wu
f2de390e0e moving stuff around
- add hand info
- don't manage info in game views
- prevent deck size cheat
- rearrange stuff
2016-04-04 00:07:11 -07:00
Jeff Wu
d86136889d only ask about playability when needed 2016-04-03 20:57:31 -07:00
Jeff Wu
678a8f26a7 seed deck in simulator, use iterators more 2016-04-02 17:51:25 -07:00
Jeff Wu
b19e6ff615 update readme 2016-04-02 14:56:40 -07:00
Jeff Wu
81427e2dd5 smart hinting, silencing/configuring of progress output 2016-04-02 13:51:18 -07:00
Jeff Wu
7f5e32699e various cleanups, fixes 2016-04-02 12:35:53 -07:00
Jeff Wu
ec1fd2eb07 make color = char 2016-03-31 10:36:13 -07:00
Jeff Wu
58c881130a fix sorting wrong order bug... some cleanup, update results 2016-03-31 09:37:50 -07:00
Jeff Wu
38bb323d91 more improve 2016-03-30 23:18:55 -07:00
Jeff Wu
0aad4dfa1c choose index dynamically, use OwnedGameView where possible 2016-03-30 10:28:15 -07:00
Jeff Wu
21e2d05e93 better partitioning, fix card table bug with extra 0 entries 2016-03-30 02:52:03 -07:00
Jeff Wu
79051b51fc tweaks 2016-03-30 02:20:34 -07:00
Jeff Wu
ea2857a9cd make use of dead card discard info 2016-03-30 01:11:41 -07:00
Jeff Wu
9494d549ae make risky plays 2016-03-30 00:38:02 -07:00
Jeff Wu
3d318340eb improve to 24.78 (for 5 players) 2016-03-29 22:59:14 -07:00
Jeff Wu
e0239dead0 bug fixes, added card partitioning. already at average score: 23.91! 2016-03-29 10:45:10 -07:00
Jeff Wu
adf98e0e4a information strategy, working! 2016-03-29 00:33:57 -07:00
Jeff Wu
efba24d6e8 beginnings of information strategy 2016-03-27 10:47:58 -07:00
Jeff Wu
f09dd58cda use iterator, return Vec<bool> on hints 2016-03-23 23:17:31 -07:00
Jeff Wu
4fa72e030f allow for probabilities in cardinfo
- helper functions for using probabilistic card info
- move firework to cards, re-export everything in game.rs
2016-03-23 22:22:19 -07:00
Jeff Wu
9c580ecb88 new cardinfo trait, separate cards stuff to different file 2016-03-22 21:45:24 -07:00
Jeff Wu
e49cb29592 configurable strategy 2016-03-20 12:40:27 -07:00
Jeff Wu
931a7d73ad percentage perfect 2016-03-19 15:29:26 -07:00
Jeff Wu
107d585b19 improvements, cleanup, readme 2016-03-19 14:24:22 -07:00
Jeff Wu
e36700d93f no empty hints, by default 2016-03-19 00:39:34 -07:00
Jeff Wu
964602d03d firework cloneable (and more compact) 2016-03-18 02:01:47 -07:00
Jeff Wu
c9602d1948 cheating strategy score up to 24.9435 (on seeds 0 - 10,000) 2016-03-18 01:40:29 -07:00
Jeff Wu
e01d93a055 turn result, turn history 2016-03-17 23:58:10 -07:00
Jeff Wu
e371e2f112 add nthreads option, histogram 2016-03-17 23:10:38 -07:00
Jeff Wu
706f5b52b6 another layer of indirection, prep for threading 2016-03-16 23:07:21 -07:00