Skip to content

Commit

Permalink
rename reducible to get_option_and_score; derive Clone for PointingIn…
Browse files Browse the repository at this point in the history
…fo & ClaimingInfo
  • Loading branch information
Nervonment committed Jun 9, 2024
1 parent c2447e1 commit afb3e88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/solver/advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ where
}

let reducing_techniques = [
Pointing::reducible,
Claiming::reducible,
NakedPairRow::reducible,
NakedPairColumn::reducible,
NakedPairBlock::reducible,
HiddenPairRow::reducible,
HiddenPairColumn::reducible,
HiddenPairBlock::reducible,
Pointing::get_option_and_score,
Claiming::get_option_and_score,
NakedPairRow::get_option_and_score,
NakedPairColumn::get_option_and_score,
NakedPairBlock::get_option_and_score,
HiddenPairRow::get_option_and_score,
HiddenPairColumn::get_option_and_score,
HiddenPairBlock::get_option_and_score,
];
// TODO: Triplet, Fish

Expand Down
8 changes: 1 addition & 7 deletions src/techniques.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ pub trait Direct<T>: Technique<T> + Into<Option<DirectOption>>
where
T: State,
{
fn to_option(self) -> Option<DirectOption> {
self.into()
}
fn get_option_and_score(state: &T) -> Option<(DirectOption, f32)> {
let res = Self::check(state);
let score = res.score();
Expand All @@ -30,14 +27,11 @@ pub trait ReducingCandidates<T>: Technique<T> + Into<Option<ReducingCandidatesOp
where
T: State,
{
fn to_option(self) -> Option<ReducingCandidatesOption> {
self.into()
}
// 如果返回值为 Some(ReducingCandidatesOption(removes), score),
// 对于 removes 中的任意元素 (cells, nums),
// cells 与 nums 中元素的笛卡尔积为所有的移除对,
// 即:可以从 cells 中的任意格的候选数中移除 nums 中的任意数
fn reducible(state: &T) -> Option<(ReducingCandidatesOption, f32)> {
fn get_option_and_score(state: &T) -> Option<(ReducingCandidatesOption, f32)> {
let res = Self::check(state);
let score = res.score();
res.into().map(|v| (v, score))
Expand Down
4 changes: 2 additions & 2 deletions src/techniques/locked_candidates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{

use super::{House, ReducingCandidates, ReducingCandidatesOption, Technique};

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct PointingInfo {
pub block: usize,
pub rem_house: House,
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<T> ReducingCandidates<T> for Pointing where
{
}

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct ClaimingInfo {
pub house: House,
pub rem_block: usize,
Expand Down

0 comments on commit afb3e88

Please sign in to comment.