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;
|
let mut _guess: Word;
|
||||||
loop {
|
loop {
|
||||||
response = solver.play(&mut game)?;
|
response = solver.play(&mut game)?;
|
||||||
println!("{response}");
|
println!("{}. guess: {response}", game.step() - 1);
|
||||||
|
|
||||||
if response.finished() {
|
if response.finished() {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,7 +3,10 @@ use std::{fmt::Display, str::FromStr};
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{Error, WResult},
|
error::{Error, WResult},
|
||||||
game::{response::*, summary::Summary, Game},
|
game::{response::*, summary::Summary, Game},
|
||||||
wlist::{word::WordData, WordList},
|
wlist::{
|
||||||
|
word::{Word, WordData},
|
||||||
|
WordList,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod naive;
|
pub mod naive;
|
||||||
|
@ -11,7 +14,10 @@ pub mod stupid;
|
||||||
|
|
||||||
pub trait Solver<'wl, WL: WordList>: Clone + std::fmt::Debug {
|
pub trait Solver<'wl, WL: WordList>: Clone + std::fmt::Debug {
|
||||||
fn build(wordlist: &'wl WL) -> WResult<Self>;
|
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>> {
|
fn solve(&self, game: &mut Game<'wl, WL>) -> WResult<Option<WordData>> {
|
||||||
let mut resp: GuessResponse;
|
let mut resp: GuessResponse;
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::wlist::word::Word;
|
||||||
use crate::wlist::WordList;
|
use crate::wlist::WordList;
|
||||||
|
|
||||||
use super::Solver;
|
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> {
|
fn build(wordlist: &'wl WL) -> crate::error::WResult<Self> {
|
||||||
Ok(Self { wl: wordlist })
|
Ok(Self { wl: wordlist })
|
||||||
}
|
}
|
||||||
fn play(
|
fn guess_for(&self, game: &crate::game::Game<'wl, WL>) -> Word {
|
||||||
&self,
|
Word::from("hello")
|
||||||
game: &mut crate::game::Game<'wl, WL>,
|
|
||||||
) -> crate::error::WResult<super::GuessResponse> {
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue