-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cyclic and puzzle solvers #18
base: dev
Are you sure you want to change the base?
Conversation
src/game/mod.rs
Outdated
|
||
impl<G> SimpleSum<2> for G | ||
where | ||
G: ClassicGame + Extensive<2>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change ClassicGame
to require Extensive<2>
so that this line only reads G: ClassicGame
.
} | ||
|
||
#[cfg(test)] | ||
mod tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're using a bespoke GameGraph
here -- please replace this with the existing game::mock::Session
implementation (see game::mock::builder
for how to make one).
This is probably from back when we had not finished it, so apologies for the delays on that.
Coordinate with @BnjmnZmmrmn if you would like him to make bigger test cases for you.
@@ -29,6 +29,7 @@ pub mod record { | |||
pub mod mur; | |||
pub mod sur; | |||
pub mod rem; | |||
pub mod surcc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job doing this.
The record implementations are getting out of hand in terms of repeated code, but this is a good solution for now.
Let's start thinking about how we can refactor the record
module in the future.
Ok(()) | ||
} | ||
|
||
fn basic_loopy_solver<G, D>(game: &G, db: &mut D) -> Result<()> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please refactor this if you get the chance, it is super long.
…stream implementation of Extensive trait for ClassicPuzzle
src/game/mod.rs
Outdated
pub trait ClassicGame { | ||
pub trait ClassicGame | ||
where | ||
Self: SimpleSum<2>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be where Self: Extensive<2>
src/game/mod.rs
Outdated
pub trait ClassicPuzzle { | ||
pub trait ClassicPuzzle | ||
where | ||
Self: SimpleSum<1>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be Self: Extensive<1>
use crate::model::SimpleUtility; | ||
use crate::model::{State, Turn}; | ||
use anyhow::Result; | ||
use std::collections::{HashMap, VecDeque}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test imports should also follow ordering (external imports, stdlib, local imports)
/// its way up the game tree in reverse. Assigns a remoteness and simple | ||
/// utiliity to every winning and losing position. Draws (positions where | ||
/// winning is impossible, but it is possible to play forever without losing) | ||
/// not assigned a remoteness. This implementation uses the SURCC record to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
draws are* not
SimpleUtility::TIE => Err(SolverViolation { | ||
name: "PuzzleSolver".to_string(), | ||
hint: format!( | ||
"Primitive end position cannot have utility TIE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you make multi-line strings, use a backslash after a space \
to truncate them (without exceeding the 80-column limit) and ensure they are grammatically correct:
hint: format!(
"Primitive end position cannot have utility TIE \
for a puzzle."
),
Ok(()) | ||
} | ||
|
||
/// Set up the initial frontiers and primitive position database entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing period, grammatically off -- it is standard to write docstrings with the function as the object of the sentence (grammatically speaking):
/// [the function] Sets up ... database entries.
The words in brackets are there to show how it works out grammatically; it's not that they should also be there.
Some(SimpleUtility::WIN) => winning_frontier.push_back(curr_state), | ||
Some(SimpleUtility::TIE) => tying_frontier.push_back(curr_state), | ||
Some(SimpleUtility::LOSE) => losing_frontier.push_back(curr_state), | ||
_ => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using _
in match
statements, opt instead to be exhaustive (for the same reason as I previously explained).
Some(SimpleUtility::TIE) => tying_frontier.push_back(curr_state), | ||
Some(SimpleUtility::LOSE) => losing_frontier.push_back(curr_state), | ||
_ => { | ||
panic!["Utility for primitive ending position found to be draw"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use parentheses for non-collection macro invocations
} | ||
|
||
fn discover_end_states<G, D>(db: &mut D, game: &G) -> Vec<State> | ||
/// Updates the database record for a puzzle with given simple utility, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing period
@@ -80,4 +82,7 @@ pub enum RecordType { | |||
SUR(PlayerCount), | |||
/// Remoteness record (no utilities). | |||
REM, | |||
/// Simple Utility Remoteness with Child Counts records for a specific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing period
No description provided.