generated from PlexSheep/rs-base
Compare commits
No commits in common. "530f51c9cca00b85bc222f8a81ae8669e4174541" and "38d484fb5e832b8c2a1e214413664a39235bc056" have entirely different histories.
530f51c9cc
...
38d484fb5e
3 changed files with 5 additions and 33 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "wordle-analyzer"
|
name = "wordle-analyzer"
|
||||||
version = "0.1.0-alpha.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
authors = ["Christoph J. Scherr <software@cscherr.de>"]
|
authors = ["Christoph J. Scherr <software@cscherr.de>"]
|
||||||
|
@ -60,7 +60,4 @@ path = "src/bin/bench/cli.rs"
|
||||||
required-features = ["solve", "cli", "bench", "builtin"]
|
required-features = ["solve", "cli", "bench", "builtin"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
test-log = { version = "0.2.16", default-features = false, features = [
|
test-log = { version = "0.2.16", default-features = false, features = ["color", "trace"] }
|
||||||
"color",
|
|
||||||
"trace",
|
|
||||||
] }
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for NaiveSolver<'wl, WL> {
|
||||||
.entry(p.0)
|
.entry(p.0)
|
||||||
.or_insert(CharInfo::new(game.length()));
|
.or_insert(CharInfo::new(game.length()));
|
||||||
cinfo.tried_but_failed(idx);
|
cinfo.tried_but_failed(idx);
|
||||||
abs_freq.entry(p.0).or_default();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trace!("absolute frequencies: {abs_freq:?}");
|
trace!("absolute frequencies: {abs_freq:?}");
|
||||||
|
@ -92,9 +91,6 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for NaiveSolver<'wl, WL> {
|
||||||
.filter(|solution_candidate| {
|
.filter(|solution_candidate| {
|
||||||
if !game.responses().is_empty()
|
if !game.responses().is_empty()
|
||||||
&& !state.has_all_known_contained(&solution_candidate.0)
|
&& !state.has_all_known_contained(&solution_candidate.0)
|
||||||
// we need these sometimes,
|
|
||||||
// because we can't just input gibberish
|
|
||||||
//&& !state.has_wrong_chars(&solution_candidate.0)
|
|
||||||
{
|
{
|
||||||
trace!("known cont:{:#?}", state.get_all_known_contained());
|
trace!("known cont:{:#?}", state.get_all_known_contained());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -34,17 +34,10 @@ impl SolverState {
|
||||||
&mut self.char_map
|
&mut self.char_map
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_all_known_bad(&self) -> Vec<(&char, &CharInfo)> {
|
|
||||||
self.char_map
|
|
||||||
.iter()
|
|
||||||
.filter(|(_key, value)| value.not_in_solution())
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn get_all_known_contained(&self) -> Vec<(&char, &CharInfo)> {
|
pub(crate) fn get_all_known_contained(&self) -> Vec<(&char, &CharInfo)> {
|
||||||
self.char_map
|
self.char_map
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_key, value)| value.known_part_of_solution())
|
.filter(|(_key, value)| value.part_of_solution())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,15 +71,6 @@ impl SolverState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_wrong_chars(&self, guess: &Word) -> bool {
|
|
||||||
for needed_char in self.get_all_known_bad() {
|
|
||||||
if guess.contains(*needed_char.0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharInfo {
|
impl CharInfo {
|
||||||
|
@ -116,12 +100,7 @@ impl CharInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn not_in_solution(&self) -> bool {
|
pub fn part_of_solution(&self) -> bool {
|
||||||
self.occurences_amount.end == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
pub fn known_part_of_solution(&self) -> bool {
|
|
||||||
self.occurences_amount.start > 0 && self.occurences_amount.end > 0
|
self.occurences_amount.start > 0 && self.occurences_amount.end > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +152,7 @@ impl CharInfo {
|
||||||
|
|
||||||
impl Debug for CharInfo {
|
impl Debug for CharInfo {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
if !self.not_in_solution() {
|
if self.part_of_solution() {
|
||||||
f.debug_struct("CharInfo")
|
f.debug_struct("CharInfo")
|
||||||
.field("correct_idxs", &self.confirmed_indexes)
|
.field("correct_idxs", &self.confirmed_indexes)
|
||||||
.field("amnt_occ", &self.occurences_amount)
|
.field("amnt_occ", &self.occurences_amount)
|
||||||
|
|
Loading…
Add table
Reference in a new issue