The puzzle model
Houses, cages, rules and candidates: the puzzle the solver works on. Generated from the comments in the headers by Doxygen and tools/gen_cpp_reference.py; public members only.
model.hpp
Constraint-agnostic puzzle model: cells, houses, relations, n-ary constraints (built from pencilmark/model.py).
Constraint kinds: AllDiff groups complete (houses: exactly D cells, every digit once) or partial (cages), optionally carrying a sum pair relations exclusion tables rel_ex[a][b][v] = digits excluded at b when a == v (non-consecutive, thermo, kropki, XV, whispers, ... all reduce to this) neq pairs anti-knight / anti-king style "different" links domains per-cell allowed-digit masks
Everything downstream works on these four primitives only; extensions (arrow sums, generic AIC link graphs, ...) add new primitives here plus strategies that consume them (see strategy.hpp).
struct Group
Fields
cellsstd::vector< int >completeboolhas_totalbooltotalintshapedoublenamestd::stringkindstd::string — graderGroup.kind('row' 'col' 'box' 'region' 'diag' 'window' 'cage' ...)
struct RelSpec
a == v excludes fwd[v] at b; b == v excludes bwd[v] at a.
Tables have D+1 entries (index 0 unused). neq relations carry no tables.
Fields
aintbintneqboolfwdstd::vector< uint32_t >bwdstd::vector< uint32_t >
struct InnieSet
Fields
hiintcellsstd::vector< int >totalintcagesstd::vector< int >outieboolhousesstd::vector< int > — the house union defining the region
struct Puzzle
| Name | What it does |
|---|---|
finalize | builds the derived tables (counts, peers, bitsets, innies, implied houses) once the groups are filled in |
rects | unique-rectangle candidates: four cells in two lines and two boxes, from the structure alone |
peers | |
neqb | |
relb | |
gbits | |
rel_ex | rel_ex[x][y] table (y must be a relation partner of x) |
Fields
uiduint64_tDintcoordsstd::vector< std::pair< int, int > >groupsstd::vector< Group >domainsstd::vector< uint32_t > — empty -> all fullrelationsstd::vector< RelSpec >nary_specsstd::vector< NSpec > — n-ary constraints (grader Puzzle.constraints)NintGintWintfulluint32_thousesstd::vector< int >groups_ofstd::vector< std::vector< int > >neqstd::vector< std::vector< int > > — CPython set iteration order of p.neq[c].relstd::vector< std::vector< int > > — CPython set iteration order of p.nonconsec[c].rel_outstd::vector< std::vector< uint32_t > > — rel_out[c][j*(D+1)+v] = rel_ex[c][rel[c][j]][v]; rel_in = rel_ex[rel[c][j]][c][v]rel_instd::vector< std::vector< uint32_t > >rel_sorted_jstd::vector< std::vector< int > > — indices j of rel[c] sorted by partnerrel_dirstd::vector< std::vector< int8_t > > — rel_dir[c][j]: +1 partner rel[c][j] is strictly greater than c, -1 strictly smaller, 0 otherpeer_liststd::vector< std::vector< int > > — sortedpeer_bitsstd::vector< uint64_t >neq_bitsstd::vector< uint64_t >rel_bitsstd::vector< uint64_t >group_bitsstd::vector< uint64_t >group_overlapstd::vector< char > — G*G, cells shared.group_linestd::vector< int > — 0 row, 1 column (same coordinate), 2 other (box/region/diagonal...)group_catstd::vector< int > — GroupCat.has_cagesboolsum_cagesstd::vector< int >inniesstd::vector< InnieSet >house_unionsstd::vector< std::vector< int > > — for inspection / testsnarystd::vector< NConstraint > — from nary_specs (same order)cage_narystd::vector< NConstraint > — sum-cage groups as sum constraints (combo-lock)big_inniesstd::vector< InnieSet > — rule-of-45 regions of 5..BIG_INNIE_MAX cellsinnie_narystd::vector< NConstraint > — ... as derived sum constraintsline_windowsstd::vector< NConstraint > — 3-cell windows of longer pairwise lines (LineScan)impliedstd::shared_ptr< Puzzle > —Puzzlecopy with implied complete houses (unions of parallel lines minus disjoint houses inside them, iterated twice: windoku hidden windows, jigsaw leftover regions) and law-of-leftovers same-multiset constraints appended; null when nothing is implied. Built byfinalize().canonicalstd::shared_ptr< Puzzle > — copy with exact (integer-moment) shapes for canonical solving; its ownimpliedis built too. null on derived copies.exact_shapesboolbase_Gint — groups [base_G, G) are implied houses (inimplied)base_naryint — nary_specs [base_nary, ...) are derived leftoversis_derivedboolBIG_INNIE_MAXconst size_t
void finalize()
builds the derived tables (counts, peers, bitsets, innies, implied houses) once the groups are filled in
const std::vector< Rect > & rects() const
unique-rectangle candidates: four cells in two lines and two boxes, from the structure alone
const uint64_t * peers(int c) const
No comment.
const uint64_t * neqb(int c) const
No comment.
const uint64_t * relb(int c) const
No comment.
const uint64_t * gbits(int g) const
No comment.
const uint32_t * rel_ex(int x, int y) const
rel_ex[x][y] table (y must be a relation partner of x)
struct Puzzle::Rect
unique-rectangle candidates (structure only), computed once on demand
Fields
cint[4] — A B / C D: A-B and C-D share groups, A-C and B-D share groups.
struct Puzzle::RectCache
Fields
oncestd::once_flagrectsstd::vector< Rect >