generated from PlexSheep/rs-base
stupid solver
This commit is contained in:
parent
aba6c723da
commit
344d188f07
|
@ -58,7 +58,7 @@ fn main() -> anyhow::Result<()> {
|
|||
let mut _guess: Word;
|
||||
loop {
|
||||
response = solver.play(&mut game)?;
|
||||
println!("{response}");
|
||||
println!("{}. guess: {response}", game.step() - 1);
|
||||
|
||||
if response.finished() {
|
||||
break;
|
||||
|
|
|
@ -3,7 +3,10 @@ use std::{fmt::Display, str::FromStr};
|
|||
use crate::{
|
||||
error::{Error, WResult},
|
||||
game::{response::*, summary::Summary, Game},
|
||||
wlist::{word::WordData, WordList},
|
||||
wlist::{
|
||||
word::{Word, WordData},
|
||||
WordList,
|
||||
},
|
||||
};
|
||||
|
||||
pub mod naive;
|
||||
|
@ -11,7 +14,10 @@ pub mod stupid;
|
|||
|
||||
pub trait Solver<'wl, WL: WordList>: Clone + std::fmt::Debug {
|
||||
fn build(wordlist: &'wl WL) -> WResult<Self>;
|
||||
fn play(&self, game: &mut Game<'wl, WL>) -> WResult<GuessResponse>;
|
||||
fn guess_for(&self, game: &Game<'wl, WL>) -> Word;
|
||||
fn play(&self, game: &mut Game<'wl, WL>) -> WResult<GuessResponse> {
|
||||
Ok(game.guess(self.guess_for(&game))?)
|
||||
}
|
||||
fn solve(&self, game: &mut Game<'wl, WL>) -> WResult<Option<WordData>> {
|
||||
let mut resp: GuessResponse;
|
||||
loop {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::wlist::word::Word;
|
||||
use crate::wlist::WordList;
|
||||
|
||||
use super::Solver;
|
||||
|
@ -11,10 +12,7 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for StupidSolver<'wl, WL> {
|
|||
fn build(wordlist: &'wl WL) -> crate::error::WResult<Self> {
|
||||
Ok(Self { wl: wordlist })
|
||||
}
|
||||
fn play(
|
||||
&self,
|
||||
game: &mut crate::game::Game<'wl, WL>,
|
||||
) -> crate::error::WResult<super::GuessResponse> {
|
||||
todo!()
|
||||
fn guess_for(&self, game: &crate::game::Game<'wl, WL>) -> Word {
|
||||
Word::from("hello")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue