generated from PlexSheep/rs-base
test: add test to check manual guessing
cargo devel CI / cargo CI (push) Failing after 1m50s
Details
cargo devel CI / cargo CI (push) Failing after 1m50s
Details
This commit is contained in:
parent
1d839e14ac
commit
d18a8f2b85
|
@ -46,6 +46,12 @@ impl From<Vec<EvaluationUnit>> for Evaluation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&str> for Evaluation {
|
||||||
|
fn from(value: &str) -> Self {
|
||||||
|
Self::from_str(value).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for Evaluation {
|
impl FromStr for Evaluation {
|
||||||
type Err = Infallible;
|
type Err = Infallible;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use wordle_analyzer::game::Game;
|
use wordle_analyzer::game::Game;
|
||||||
use wordle_analyzer::solve::{AnyBuiltinSolver, NaiveSolver, Solver, StupidSolver};
|
use wordle_analyzer::solve::{AnyBuiltinSolver, NaiveSolver, Solver, StupidSolver};
|
||||||
use wordle_analyzer::wlist::builtin::BuiltinWList;
|
use wordle_analyzer::wlist::builtin::BuiltinWList;
|
||||||
use wordle_analyzer::wlist::word::Word;
|
use wordle_analyzer::wlist::word::{Word, WordData};
|
||||||
use wordle_analyzer::wlist::WordList;
|
use wordle_analyzer::wlist::WordList;
|
||||||
|
|
||||||
fn wordlist() -> impl WordList {
|
fn wordlist() -> impl WordList {
|
||||||
|
@ -67,3 +67,49 @@ fn test_naive_play_predetermined_game() -> anyhow::Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_naive_play_predetermined_game_by_manual_guess_and_evak() -> anyhow::Result<()> {
|
||||||
|
let wl = wordlist();
|
||||||
|
let sl =
|
||||||
|
AnyBuiltinSolver::Naive(NaiveSolver::build(&wl).expect("could not build naive solver"));
|
||||||
|
// we don't insert the solution yet,
|
||||||
|
// pretend that a user inputs guesses manually
|
||||||
|
let mut game = Game::build(5, false, 6, &wl, false)?;
|
||||||
|
let _actual_solution: Option<WordData> = Some(("nines".into(), 0.002));
|
||||||
|
let mut next_guess;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
next_guess = sl.guess_for(&game)?;
|
||||||
|
assert_eq!(next_guess, Word::from("which"));
|
||||||
|
game.guess(next_guess, Some("xxfxx".into()))?;
|
||||||
|
|
||||||
|
// naive is at the moment too bad to solve "nines"
|
||||||
|
assert!(game.finished());
|
||||||
|
assert!(!game.won());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue