clean up main

This commit is contained in:
ashastral 2022-02-26 22:08:54 -08:00
parent 7e2fa309cd
commit 76ff849a8c

View file

@ -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<_>>()
} }