games/nonogram: an untouched board no longer counts auto-crosses as player progress
- Commit
aad490579e275d39df74ff205be84b144ca18d57- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 02:25 UTC (5 days ago)
- Parents
ea54fdd
Auto-crosses are a deterministic function of the fills: a
real clue line can only complete when a fill exists, and a
zero-clue row/column re-derives identical crosses after
restart ('an untouched board restarts into itself'). But the
controls counted autoCrossed as progress, so on real levels
2 and 5 โ which start with 5 auto-crosses from their empty
row โ a fresh board showed no how-to hint, and Restart popped
the 'All your marks will be cleared' confirmation for a
player who had placed nothing.
Progress is now player marks only (filled + manual crossed +
revealed blanks) for both the hint gate and the
restart-confirmation gate. Promoting an auto-cross still
counts (as a manual cross), completed-by-fills lines still
count (via filled). The domain derivation is untouched. New
UI regression test builds the exact post-load fresh state and
asserts the hint shows, Restart fires immediately and no
confirmation appears. The solver was independently verified
against brute force and the remaining state paths were
audited and cleared. Verified: :games:nonogram:testDevUnitTest
149 tests and lint pass.Diff
games/nonogram/src/main/java/com/vayunmathur/games/nonogram/ui/NonogramGameScreen.kt
diff --git a/games/nonogram/src/main/java/com/vayunmathur/games/nonogram/ui/NonogramGameScreen.kt b/games/nonogram/src/main/java/com/vayunmathur/games/nonogram/ui/NonogramGameScreen.ktindex 6430c1912f..599287f16d 100644--- a/games/nonogram/src/main/java/com/vayunmathur/games/nonogram/ui/NonogramGameScreen.kt+++ b/games/nonogram/src/main/java/com/vayunmathur/games/nonogram/ui/NonogramGameScreen.kt@@ -263,9 +263,13 @@ private fun NonogramControls( val daily = state.mode == GameMode.DAILY var confirmRestart by remember { mutableStateOf(false) } // Restart clears every mark, so only ask when there is something to lose:- // an untouched board restarts into itself.+ // an untouched board restarts into itself. Auto-crosses don't count: they+ // are re-derived from the fills, so a line completed by fills is already+ // progress through those fills, and the only auto-crosses a board with no+ // fills can carry come from zero-clue lines โ which a restart re-derives+ // identically on the fresh board. val hasProgress = game.filled.isNotEmpty() || game.crossed.isNotEmpty() ||- game.autoCrossed.isNotEmpty() || game.revealedBlanks.isNotEmpty()+ game.revealedBlanks.isNotEmpty() when { game.isWon -> { Text(@@ -303,8 +307,11 @@ private fun NonogramControls( else -> { MarkModeToggle(state.markMode, actions::setMarkMode)+ // Fresh means the player has placed nothing of their own; the+ // auto-crosses a zero-clue line starts with (see hasProgress)+ // must not hide the how-to-play hint on an untouched board. if (game.filled.isEmpty() && game.crossed.isEmpty() &&- game.autoCrossed.isEmpty() && game.revealedBlanks.isEmpty()+ game.revealedBlanks.isEmpty() ) { Text( // Follows the toggle: in Cross mode a tap crosses and a long press fills.
games/nonogram/src/test/java/com/vayunmathur/games/nonogram/ui/NonogramScreensTest.kt
diff --git a/games/nonogram/src/test/java/com/vayunmathur/games/nonogram/ui/NonogramScreensTest.kt b/games/nonogram/src/test/java/com/vayunmathur/games/nonogram/ui/NonogramScreensTest.ktindex ec73a8e3a0..badd767826 100644--- a/games/nonogram/src/test/java/com/vayunmathur/games/nonogram/ui/NonogramScreensTest.kt+++ b/games/nonogram/src/test/java/com/vayunmathur/games/nonogram/ui/NonogramScreensTest.kt@@ -29,6 +29,7 @@ import com.vayunmathur.games.nonogram.data.MarkMode import com.vayunmathur.games.nonogram.data.NonogramGameState import com.vayunmathur.games.nonogram.data.NonogramPuzzle import com.vayunmathur.games.nonogram.data.STARTING_HEARTS+import com.vayunmathur.games.nonogram.domain.NonogramClues import com.vayunmathur.games.nonogram.platform.NonogramGameActions import com.vayunmathur.games.nonogram.platform.NonogramUiState import com.vayunmathur.games.nonogram.platform.SettingsActions@@ -146,6 +147,29 @@ class NonogramScreensTest { assertEquals(1, a.restarts, "untouched board restarts without confirmation") } + @Test fun freshBoardWithOnlyAutoCrossesShowsHintAndRestartsWithoutConfirm() {+ // A puzzle with a zero-clue line: the middle row and right column need+ // no fills, so the load-time derivation (as the ViewModel applies it)+ // starts the untouched board with auto-crosses already on it. Real+ // levels 2 and 5 generate exactly this shape.+ val striped = NonogramPuzzle.from(3, listOf(true, true, false, false, false, false, true, true, false))+ val fresh = NonogramClues.withAutoCrosses(+ NonogramGameState(striped, emptySet(), emptySet(), emptySet(), STARTING_HEARTS, GameMode.CASUAL, 2)+ )+ assertTrue(fresh.autoCrossed.isNotEmpty(), "setup: the zero-clue lines auto-cross from the start")+ assertTrue(fresh.filled.isEmpty() && fresh.crossed.isEmpty() && fresh.revealedBlanks.isEmpty(),+ "setup: the player has placed nothing")+ val a = Recording()+ rule.setContent { NonogramGameScreen(NonogramUiState(game = fresh, level = 2, markMode = MarkMode.FILL), a, {}, {}) }+ // The how-to-play hint must not be hidden by crosses the game placed.+ rule.onNodeWithText(str(R.string.how_to_play_fill)).assertExists()+ // And restart must not ask to confirm clearing marks the player never+ // made: a restart re-derives the same auto-crosses on the fresh board.+ rule.onNodeWithText(str(UiR.string.restart)).performSemanticsAction(SemanticsActions.OnClick)+ rule.onNodeWithText(str(R.string.confirm_restart_title)).assertDoesNotExist()+ assertEquals(1, a.restarts, "untouched board restarts without confirmation")+ }+ @Test fun undoButtonFollowsCanUndo() { val a = Recording() var state by androidx.compose.runtime.mutableStateOf(NonogramUiState(game = game(filled = setOf(1)), level = 2, canUndo = false))