refactor(solver): debugging interactive
cargo devel CI / cargo CI (push) Failing after 1m37s Details

This commit is contained in:
Christoph J. Scherr 2024-07-22 16:52:08 +02:00
parent e4431ca688
commit 70711ad334
2 changed files with 4 additions and 2 deletions

View File

@ -129,6 +129,7 @@ fn help_guess_interactive(cli: Cli) -> anyhow::Result<()> {
}
ReplCommand::Solve => {
let best_guess = solver.guess_for(&game)?;
debug!("game state: {game:?}");
println!("best guess: {best_guess}");
}
ReplCommand::Guess {
@ -136,12 +137,13 @@ fn help_guess_interactive(cli: Cli) -> anyhow::Result<()> {
evalutation,
} => {
let guess = game.guess(your_guess, Some(evalutation));
debug!("your guess: {guess:?}");
if guess.is_err() {
eprintln!("{}", style(guess.unwrap_err()).red().bold());
continue;
}
println!("{}", guess.unwrap());
debug!("current gamestate: {game:#?}");
debug!("game state: {game:#?}");
}
_ => todo!(),
}
@ -164,6 +166,7 @@ fn play_native_non_interactive(cli: Cli) -> anyhow::Result<()> {
let mut _guess: Word;
loop {
response = solver.make_a_move(&mut game)?;
debug!("game state: {game:#?}");
println!("{}. guess: {response}", game.step() - 1);
if response.finished() {

View File

@ -148,7 +148,6 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for AnyBuiltinSolver<'wl, WL> {
Ok(Self::Naive(NaiveSolver::build(wordlist)?))
}
fn guess_for(&self, game: &Game<'wl, WL>) -> WResult<Word> {
debug!("solver: {self:?}");
Ok(match self {
Self::Naive(solver) => solver.guess_for(game)?,
Self::Stupid(solver) => solver.guess_for(game)?,