Commit Graph

36 Commits

Author SHA1 Message Date
timotree3
4bab09ba2b Run cargo fmt 2023-01-19 20:31:32 -05:00
phimuemue
c9b21fa047
Compile on rust 1.61, resolve warnings, fix some lints (#12)
* Fix getopts version

The pinned version does not compile anymore because of mutable aliasing:
* https://github.com/rust-lang/getopts/pull/61
* https://github.com/rust-lang/getopts/issues/110

This was achieved by temporarily setting the getopts version to "0.2.21"
in Cargo.toml, and running `cargo check`.

Note that this also converts the Cargo.lock to a new format.

* Fix warning: Instead of deprecated macro try!, use question mark operator

* Fix warning: Avoid anonymous parameters

* Fix warning: Use dyn on trait objects

* Fix warning: Avoid unneeded mutability

* Fix warning: Avoid redundant format in panic or assert

* Fix lint: Avoid redundant field names in initializers

* Fix lint: Avoid redundant clone

* Fix lint: Avoid literal cast

* Fix lint: Collapse if/else where applicable

I left some if/else branches in place, if there was a certain symmetry between the branches.

* Fix lint: Avoid needless borrow

I left some if/else branches in place, if there was a certain symmetry between the branches.

* Fix lint: Use cloned instead of custom closure

* Fix lint: Avoid unneeded trait bound

* Fix lint: Avoid unneeded trait bound (2) avoid redundant clone

* Fix lint: Use &[T] instead of &Vec<T>

* Fix lint: Avoid & on each pattern

* Fix lint: Avoid manual assign

* Fix lint: Use implicit return

* Fix lint: Merge if/else branches with same value

I left one complicated branch in place.

* Fix lint: Use is_empty instead of comparing len against 0

* Fix lint: Use sum instead of fold

* Fix lint: Avoid clone on Copy types
2022-07-05 11:05:13 -07:00
Felix Bauckholt
1c229227ab Merge branch 'master' into information-efficiency 2019-03-15 14:23:09 +01:00
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
Jeff Wu
c791adcb5a make readme slightly nicer 2019-03-10 22:31:20 -07:00
Felix Bauckholt
8fd230da1c Report standard errors in README.md 2019-03-10 22:20:25 -07: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
96da95dbba Oops I had accidentally left bogus numbers in the last commit
Sorry :(
2019-03-07 21:38:55 +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
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
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
58c881130a fix sorting wrong order bug... some cleanup, update results 2016-03-31 09:37:50 -07:00
Jeff Wu
0aad4dfa1c choose index dynamically, use OwnedGameView where possible 2016-03-30 10:28:15 -07:00
Jeff Wu
efba24d6e8 beginnings of information strategy 2016-03-27 10:47:58 -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
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
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
Jeff Wu
0b9734c20b replicated 24.88 from paper 2016-03-13 22:28:34 -07:00
Jeff Wu
7f5feacbc7 command line parsing 2016-03-13 18:11:20 -07:00
Jeff Wu
adaa513ff8 cheating strategy improvements 2016-03-13 17:26:12 -07:00
Jeff Wu
6184fcd914 make rng seedable 2016-03-13 11:28:26 -07:00
Jeff Wu
2f6dc571c2 strategy that cheats, first pass 2016-03-13 01:07:34 -08:00
Jeff Wu
1ad4f9b825 improvements to strategies API
make strategies its own module
use trait objects so you can mix and match strategies
stop using internal state associated type..
2016-03-10 22:26:32 -08:00
Jeff Wu
b4d949ff2f move stuff to boardstate 2016-03-06 21:44:17 -08:00
Jeff Wu
49627b91b6 hints and better logging 2016-03-06 16:50:09 -08:00
Jeff Wu
a44b017eae add types for information 2016-03-06 03:33:14 -08:00
Jeff Wu
55e9dc2fe3 add some logging, fix some bugs 2016-03-06 01:35:19 -08:00
Jeff Wu
e2eebcbe07 sorta working, probably very buggy 2016-03-06 01:09:24 -08:00
Jeff Wu
9508a20082 flushed out game initialization 2016-03-05 19:36:02 -08:00
Jeff Wu
4168800875 Initial commit 2016-03-05 16:54:46 -08:00