Add a bounded puzzle thinking-depth analysis tool

This commit is contained in:
Hadrian Burkhardt
2026-11-02 10:06:32 +01:00
parent 010b90bef5
commit c6168f46ac
8 changed files with 1617 additions and 2 deletions
+17 -1
View File
@@ -31,6 +31,7 @@ lib/
├── main.dart LumenApp, Notebook, all screen builders, dialogs, routing
├── domain/
│ ├── puzzle.dart Puzzle, JavaRandom, LogicSolver, Difficulty, Region, Hint
│ ├── thinking.dart ThinkingAnalyzer, ThinkingReport — snapshot deduction waves and bounded hypothetical proofs
│ ├── book.dart Book, CampaignLevel, StoryPage/StoryPageType — loads authored content
│ └── game.dart Game (ChangeNotifier), Screen/Mode, puzzle session, awards
├── services/
@@ -40,7 +41,8 @@ lib/
│ └── ads.dart Ads — UMP consent, rewarded hints, interstitials
└── ui/
├── paper.dart Paper, Leaf, Cover, Sketch, InkButton, PageSwipeBlocker
└── board.dart Board, PencilMark painter, PixelPicture
├── board.dart Board, PencilMark painter, PixelPicture, PatternStamp
└── discovery.dart Discovery — pattern-to-art transition and replay
assets/
├── campaign.json premise + 12 authored levels (chapter/title/object/before/after/picture/clues/areas; optional illustrationAsset)
@@ -72,6 +74,8 @@ flowchart TD
main["main.dart<br/>LumenApp · Notebook<br/>six screen builders · dialogs"]
game["domain/game.dart<br/>Game (ChangeNotifier)<br/>Screen/Mode · session · awards"]
puzzle["domain/puzzle.dart<br/>Puzzle · LogicSolver · JavaRandom · Difficulty"]
thinking["domain/thinking.dart<br/>ThinkingAnalyzer · ThinkingReport"]
cli["tool/analyze_puzzles.dart<br/>Authoring report CLI"]
book["domain/book.dart<br/>Book · CampaignLevel · StoryPage"]
progress["services/progress.dart<br/>Progress — local key/value store"]
narrator["services/narrator.dart<br/>Narrator — just_audio"]
@@ -90,6 +94,9 @@ flowchart TD
board --> puzzle
board --> paper
game --> puzzle
cli --> thinking
cli --> puzzle
thinking --> puzzle
game --> book
game --> progress
book --> puzzle
@@ -229,6 +236,14 @@ Content pipelines:
- **Daily:** fixed board per local calendar day (`Puzzle.seeded(epochDay * 7919)`), progress keyed by date.
- **Classic:** deterministic practice board per difficulty and level (`1000000 + level` seed), generated on an isolate.
## Thinking-depth authoring tool
- `lib/domain/thinking.dart` is pure Dart and is not wired into gameplay, hint pricing, generation or saved progress. `ThinkingAnalyzer(cellCount, constraints).analyze(initial)` receives visible constraints and solver-encoded marks, never an answer picture.
- All direct deductions in a wave use the same snapshot. Only after direct waves stall are two-clue overlap comparisons used; comparisons are exhausted before bounded contradiction lookahead. The trace distinguishes long write-down chains from simultaneous hypothetical assumptions.
- On an ordinary-rule stall a bounded solution counter classifies inconsistent or non-unique boards; its answer search never supplies deduction marks. `lookaheadDepth` is null unless the complete model path succeeds. Depth and node limits produce explicit unresolved statuses rather than claiming a human must guess.
- `tool/analyze_puzzles.dart` loads campaign records without Flutter assets/Book, or uses the existing daily/practice generator. It writes a compact table, Markdown reports and full JSON proofs. `--input` accepts generic constraints/partial marks. See [THINKING_DEPTH.md](THINKING_DEPTH.md) for encodings, strategy, limits and interpretation.
- `test/thinking_test.dart` covers clue-order invariance, one- and two-level lookahead, exact small-system enumeration, partial/invalid boards, budget handling and all campaign traces. Answer-bearing test fixtures are never passed into the analyzer itself.
## UI, layout and rendering rules
- All visible handwriting uses `hand(size)` (`MaraHand` → Dancing Script). Colours live in `lib/ui/paper.dart`: `ink` `#36413c`, `blue` `#274956`, `muted` `#796b55`, `cream` `#f3e7cc`, `amber` `#e0b568`.
@@ -364,6 +379,7 @@ Board key formats (`<key>`):
| File | Covers |
| --- | --- |
| `test/thinking_test.dart` | Snapshot-wave invariance, 1/2-level contradiction proofs, exhaustive checks of 200 small systems, partial/invalid boards, search limits and all campaign traces |
| `test/narration_autoplay_test.dart` | Exact 3-second delay, one start per visit, cancellation/replacement, recorded-page eligibility, unfolding notes and backgrounding |
| `integration_test/autoplay_test.dart` | Real-device delayed playback of bundled WAVs, cancellation when entering a puzzle and Stop preventing restart |
| `test/ambience_test.dart` | Scene mapping, voice ducking, mute/background stop, stale loading requests, backend failure/recovery and disposal |