Skip to content

Commit

Permalink
Comment new Action/Strategy fields for later; plan future strategy ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
dharkness committed Aug 20, 2023
1 parent 9a724c0 commit 174fad4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/puzzle/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use super::{Board, Effects, Strategy};
#[derive(Clone, Debug)]
pub struct Action {
strategy: Strategy,
set: HashMap<Cell, Known>,
erase: HashMap<Cell, KnownSet>,
set: HashMap<Cell, Known>, // [CellSet; 9], [Value; 81]
erase: HashMap<Cell, KnownSet>, // [CellSet; 9], [KnownSet; 81]
}

impl Action {
Expand Down
63 changes: 46 additions & 17 deletions src/puzzle/strategy.rs
Original file line number Diff line number Diff line change
@@ -1,56 +1,85 @@
/// Identifies the logic used to solve cells and remove candidates.
///
/// - Strategy stays a simple high-level enum with no values
/// - Rule specifies subtype or rule with knowns/cells/houses (see comments below)
/// - Strategy Intersection Removal has Line/Box Reduction and Pointing Pair/Triple
/// - Deduction combines the Strategy and Clue with Effects (sets and erases)
///
/// Add Class (groupings)?
/// - Naked Candidates
/// - Hidden Candidates
/// - Intersection Removal
/// - Fish
/// - ...kinda breaks down after that
///
/// What's the point? Want to be able to filter rules to apply (automatically),
/// and then really only peers and singles? This is a tool for creating and solving
/// puzzles automatically. The UI is just for fun and to learn Rust.
///
/// Add Difficulty? sudokuwiki.org only has four:
/// - Basic
/// - Tough
/// - Diabolical
/// - Extreme
///
/// What is the purpose of this project?
/// - learn Rust
/// - have fun
/// - exercise my brain
/// - Create a generalized solver using inference chains
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Strategy {
// these become the Clues; copy and generalize for Strategy
/// When a cell becomes solved, the value may be removed as a candidate
/// from every cell in the same row, column or box.
Peer,
Peer, // (Known, Cell)

/// A candidate that may only appear in two cells in one segment of a block
/// may be removed from the other two segments in the segment's row or column.
///
/// This is one form of intersection removals.
PointingPair,
PointingPair, // (Known, block House, House, (Cell, Cell))
/// A candidate that may only appear in three cells one segment of a block
/// may be removed from the other two segments in the segment's row or column.
///
/// This is one form of intersection removals.
PointingTriple,
PointingTriple, // (Known, block House, House, (Cell, Cell, Cell))
/// A candidate that may only appear in one segment of a block
/// may be removed from the other cells in the block.
///
/// This is one form of intersection removals.
BoxLineReduction,
BoxLineReduction, // (Known, block House, House)

/// A cell with one candidate remaining may be solved.
NakedSingle,
NakedSingle, // (Known, Cell)
/// A candidate that may only appear in one cell in a house may be solved.
HiddenSingle,
HiddenSingle, // (Known, House, Cell)

/// Two cells in a house and with the same two candidates remaining
/// may remove those candidates from all other cells in that house.
NakedPair,
NakedPair, // (KnownSet, House, CoordSet)
/// Two candidates remaining in two cells in a house
/// may remove all other candidates in those cells.
HiddenPair,
HiddenPair, // (KnownSet, House, CoordSet)

/// Three cells in a house and with the same three candidates remaining
/// may remove those candidates from all other cells in that house.
NakedTriple,
NakedTriple, // (KnownSet, House, CoordSet)
/// Three candidates remaining in three cells in a house
/// may remove all other candidates in those cells.
HiddenTriple,
HiddenTriple, // (KnownSet, House, CoordSet)

/// Four cells in a house and with the same four candidates remaining
/// may remove those candidates from all other cells in that house.
NakedQuad,
NakedQuad, // (KnownSet, House, CoordSet)
/// Four candidates remaining in four cells in a house
/// may remove all other candidates in those cells.
HiddenQuad,
HiddenQuad, // (KnownSet, House, CoordSet)

XWing,
Swordfish,
Jellyfish,
XWing, // (Known, mains HouseSet, crosses HouseSet)
Swordfish, // (Known, mains HouseSet, crosses HouseSet)
Jellyfish, // (Known, mains HouseSet, crosses HouseSet)

SinglesChain,
YWing,
SinglesChain, // (Known, Vec<Cell>)
YWing, // (Known, pivot Cell, arms (Cell, Cell))
}

0 comments on commit 174fad4

Please sign in to comment.