Files
logic-puzzle/README.md
T
2026-10-31 03:28:48 +01:00

107 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Lumen — The Last Light (Android 1.7)
A native Android 7.0+ app styled as a lightkeeper’s family notebook: faded blue cloth, stitched binding, warm ruled paper, a ribbon bookmark and pressed heather. A hand-drawn twilight harbour connects the home screen to the island story. No account or game backend. Players restore a darkened island through picture puzzles, or play generated 5×5 daily and classic grids.
The opening six-leaf storybook prototype is implemented. The wider [product roadmap](ROADMAP.md) describes the next chapters and further exploration features.
## Opening notebook prototype
Open Mara’s notebook from the home screen. The opening trail contains:
1. Gran’s handwritten dedication.
2. A cottage entry with an original watercolour illustration.
3. The existing match puzzle, using its original save key.
4. A match sketch and a personal memory.
5. A folded note that can be opened and kept.
6. A lantern illustration with a repair detail to inspect.
Use the corner arrows or swipe horizontally from a page margin. Gestures starting inside the grid cannot turn the page. Navigation stays fixed below the reading area; text can overflow-scroll for larger fonts or landscape. A short fade/slide respects disabled system animations. Contents links to these leaves, a ribbon bookmark, and the existing three-chapter campaign. The final lantern leaf links to the next existing entry; the rest of the campaign still uses the earlier screens.
Five pre-rendered readings ship as lossless FLAC files, with editable 24 kHz mono WAV masters in `assets/narration/wav/`. Android MediaPlayer provides play, pause, exact-position resume, stop and replay, optional speed settings, and passage highlighting. There is no Android text-to-speech service, runtime synthesis, voice download, or per-listen network request. These are synthetic British-English readings rendered during development, not a human actor’s performance. Playback stops on page changes and when the app backgrounds. See [audio provenance and regeneration](assets/narration/README.md).
The last leaf, explicit ribbon bookmark, opened note, inspected handle and viewed-page flags are saved independently of puzzle completion. Closing the app in the notebook restores the same leaf. Reading ahead from an unsolved puzzle asks once per attempted turn and keeps all marks without awarding completion. Existing campaign grids and counts are preserved; the original match can be revisited if already solved. The opening prototype contains no interstitials, and narration/discoveries require no ad.
The cottage and lantern PNGs were generated using the built-in image tool with alpha backgrounds. Originals and exact prompts are in `assets/artwork/`; sampled decoded copies are used for the small on-page illustrations.
For isolated tablet smoke tests:
```sh
JAVA_HOME=/path/to/jdk-21 ./gradlew :app:assembleDebug -PqaBuild=true
adb -s YOUR_SERIAL install -r app/build/outputs/apk/debug/app-debug.apk
python3 scripts/check_storybook.py --serial YOUR_SERIAL
```
The test script enforces a `.qa` package because it writes disposable fixtures. It checks edge swipes, bundled recording playback, pause/resume and speed settings, grid gesture isolation, read-ahead, folded-note persistence, bookmarks, process restart, completion without duplicate awards, and rotation. It restores the tablet’s original rotation settings. Screenshots and results go to `artifacts/storybook-check/`.
## The Last Light
Twelve 7×7 picture puzzles across three chapters: the keeper’s cottage, the tidal crossing, and the lighthouse. Follow grandmother Mara’s notebook to recover a match, lantern, key, compass, boat, anchor, bridge, bell, gear, lens, lighthouse and home. Each solution is the actual pictured object, shown as clean pixel art after completion. Story pages appear before and after each puzzle; recovered pictures remain in the notebook. Everything ships in the APK.
The first two patterns teach row and column totals. Patterns 3–12 add three overlapping rectangular areas. Select A, B or C to highlight its cells; shared cells count in both totals. Later puzzles **cannot** be completed by line saturation alone. Subtracting overlapping constraints resolves cells outside their overlap; tests verify this technique is necessary and sufficient, without branching/guessing. These are introductory area puzzles, not a promise of expert-level challenge.
Campaign completion unlocks the next page, increments the existing solved counter once, and preserves all prior classic/daily data. Campaign progress is separate from the daily streak. Every fourth story page can show an interstitial when turning to the next chapter, once per chapter transition; re-reading never repeats it. No ad interrupts a story reveal. Campaign replay currently means re-reading recovered pages, not resetting puzzles.
Hints now explain a forced line or area deduction and mark one cell. If an earlier player mark is wrong, a hint corrects one such cell first. Each puzzle has one free hint, with additional hints requiring the AdMob reward callback.
## Notebook theme
The home screen now uses newly generated watercolour harbour and faded-blue notebook-cover PNGs (`HomeArtwork.java`), with a native handwritten cover label. All app-created headings, passages, menus, captions, puzzle clues and dialogs use the cursive handwriting family; system consent screens retain their provider styling. Recovered objects sit on taped paper keepsakes. The lighthouse app icon uses a vector drawable.
The book cover on the home screen opens a generated 1024×1536 single diary page, bundled without density scaling. `NotebookPage.java` positions transparent content directly on its blank writing area, with no floating panel. Portrait shows the whole page; landscape crops vertically through the blank paper, retaining the binding. Handwritten menu actions have a fine ink underline, and empty puzzle cells have thin pencil outlines so the paper stays visible. The grid sizes to available width and scrolls into view on entry. Source artwork and the exact generation prompt are in `assets/artwork/`. All drawings are static apart from the existing short picture fade; paper texture work is limited to the visible part of the page. Existing puzzle definitions and save keys are unchanged.
## Classic and daily modes
- Deterministic generated practice levels and a date-seeded daily puzzle.
- Easy, Medium, and Hard practice, with independent saved progress and a remembered selection.
- Solver checks uniqueness and rates boards by simultaneous deduction rounds: Easy 1–2, Medium 3–4, Hard 5. A round fills lines where all unknown cells must be lit or all must be crossed out; later rounds use those deductions. No guessing is needed.
- Generation tries up to 256 deterministic candidates, then uses a permuted known board of the requested grade. These are relative chain-depth ratings, not a calibrated measure of solve time.
- Existing daily grids retain their original generation. Earlier in-progress practice is accessible through “Continue earlier puzzle.”
- Saved boards, level progress, daily streaks and completion counts on device.
- Undo, one free explained hint per board, then optional rewarded hints.
- Interstitials at a natural transition after every fourth practice completion across all difficulties. No ads during a board or when returning home.
- AdMob and UMP consent flow; ads only requested when consent information permits.
- Google test IDs by default. Games remain playable without connectivity or ad availability.
Campaign grids use fixed `story_v1_…` save keys. Preserve the order, pictures, givens and area layouts of existing entries when adding future pages; changing an existing puzzle requires a new save-key version.
## Build
Requires JDK 17–24 (JDK 21 recommended) and Android SDK 36. Set `sdk.dir` in your own `local.properties` or configure `ANDROID_HOME`.
```sh
JAVA_HOME=/path/to/jdk-21 ./gradlew :app:testDebugUnitTest :app:assembleDebug
```
Debug APK: `app/build/outputs/apk/debug/app-debug.apk`. A shareable copy of version 1.7 is in `artifacts/lumen-1.7.apk`.
For an isolated device test build, add `-PqaBuild=true` to `assembleDebug`; it installs as `com.lumen.daily.qa`, with independent progress. Build without that property for the normal app. Device smoke-test screenshots and results are under `artifacts/`.
## Before publishing on Google Play
1. Choose a permanent application ID in `app/build.gradle` (currently `com.lumen.daily`).
2. Create the Android app and rewarded/interstitial ad units in AdMob. Configure Privacy & messaging for the markets you serve.
3. Supply production IDs via Gradle properties `ADMOB_APP_ID`, `ADMOB_REWARDED_ID`, and `ADMOB_INTERSTITIAL_ID`. Keep Google test IDs in development builds.
4. Configure your private upload signing key outside version control, then build a signed release AAB. Release signing is intentionally not supplied by this repository.
5. Supply a public privacy policy, store artwork, support contact, content rating, target audience, ads declaration and accurate Data safety answers based on the Google ads SDK and your final configuration. The in-app privacy summary is not a replacement for a published policy.
6. Test consent (including refusal/revocation), reward completion/cancellation, no-fill, offline play, process restart, device rotation and small screens on physical devices. Complete Play testing requirements for your developer account.
The daily date uses the device’s local calendar. Progress and streaks are local, not protected against clock changes or restored after uninstall. A daily puzzle remains available to replay after completion; a solved practice board advances the practice counter. Puzzle generation guarantees a unique answer and grades deduction depth.
## Source map
- `Campaign.java`: authored story, 7×7 pixel patterns, precomputed fixed clues and area layouts.
- `LogicSolver.java`: count-constraint search, line/area deductions and explained hints.
- `CampaignTest.java`: all twelve unique pictures; necessary area deductions on pages 3–12; hint completion and restoration checks.
- `LogicSolverTest.java`: deductions and solution counts compared with exhaustive enumeration over 1,000 small overlapping constraint systems.
- `Puzzle.java`: seeded classic generation, general constraints, solution counting, deduction grading, completion validation.
- `Difficulty.java`: difficulty names, descriptions and grade thresholds.
- `DifficultyTest.java`: 1,500 generated boards checked for requested grades and uniqueness, deterministic regeneration, legacy compatibility and ambiguous-board rejection.
- `StoryBook.java`: stable six-leaf story records and narration sentence boundaries.
- `StoryNotebook.java`: page layouts, fixed navigation, folded note and inspection interaction.
- `StoryNarrator.java`: bundled recording playback, passage progress, audio focus and speed settings.
- `PageTurnGesture.java`: page-margin gesture recognition, tested against grid drags.
- `MainActivity.java`: notebook routing, puzzle completion, local progress, streaks, hints.
- `Ads.java`: consent, ad loading and presentation.
- `PuzzleTest.java`: uniqueness, determinism and completion across 500 seeds.
- `DailyStreakTest.java`: consecutive days, replay handling and missed-day reset.