clean up main
This commit is contained in:
parent
7e2fa309cd
commit
76ff849a8c
1 changed files with 1 additions and 10 deletions
11
src/main.rs
11
src/main.rs
|
@ -1,5 +1,4 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use rand::seq::SliceRandom;
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! word {
|
macro_rules! word {
|
||||||
|
@ -24,8 +23,6 @@ mod evaluator;
|
||||||
|
|
||||||
|
|
||||||
fn play<const N: usize>(dictionary: &Dictionary<N>) {
|
fn play<const N: usize>(dictionary: &Dictionary<N>) {
|
||||||
let secret = *dictionary.choose(&mut rand::thread_rng()).unwrap();
|
|
||||||
println!("The secret is {:?}", secret);
|
|
||||||
let mut constraints = constraints::Total::new();
|
let mut constraints = constraints::Total::new();
|
||||||
let mut game = game::Game {
|
let mut game = game::Game {
|
||||||
evaluator: &mut evaluator::AdversarialEvaluator::new(dictionary),
|
evaluator: &mut evaluator::AdversarialEvaluator::new(dictionary),
|
||||||
|
@ -43,13 +40,7 @@ fn play<const N: usize>(dictionary: &Dictionary<N>) {
|
||||||
fn load_words<const N: usize>(contents: &'static str) -> Vec<Word<N>> {
|
fn load_words<const N: usize>(contents: &'static str) -> Vec<Word<N>> {
|
||||||
contents
|
contents
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map(|line|
|
.map(|line| word!(line))
|
||||||
line.chars()
|
|
||||||
.collect::<Vec<char>>()
|
|
||||||
.as_slice()
|
|
||||||
.try_into()
|
|
||||||
.unwrap()
|
|
||||||
)
|
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue