Modern Apps git

← Modern-Apps.git

arrows: make every mirror count, cap the opening, and grow boards further

Commit
74f6396dff5d22258acb70c5c450b75463be2deb
Author
vayun-mathur <[email protected]>
When
2026-08-24 22:14 UTC (3 months ago)
Parents
eed5773

Diff

games/arrows/src/main/java/com/vayunmathur/games/arrows/data/ArrowModels.kt
diff --git a/games/arrows/src/main/java/com/vayunmathur/games/arrows/data/ArrowModels.kt b/games/arrows/src/main/java/com/vayunmathur/games/arrows/data/ArrowModels.ktindex 67a33f9f11..02d85ec3ee 100644--- a/games/arrows/src/main/java/com/vayunmathur/games/arrows/data/ArrowModels.kt+++ b/games/arrows/src/main/java/com/vayunmathur/games/arrows/data/ArrowModels.kt@@ -135,14 +135,52 @@ data class ArrowsGameState( /** Hearts a level starts with. Three wrong taps and it resets. */ const val STARTING_HEARTS = 3 -/** Board width and height for [level]. Grows in steps so early levels stay readable. */+/**+ * Board width and height for [level].+ *+ * Grows in steps rather than continuously so a run of levels shares a shape and the player can build an+ * intuition for it before the board changes under them. Each step adds a row or a column but not both:+ * gaining one of each at once would jump the area by a third and read as a difficulty spike.+ *+ * Stops at [MAX_BOARD], where a phone-width board is already down to roughly 46dp cells.+ */ fun boardSizeForLevel(level: Int): Pair<Int, Int> = when {-    level <= 5 -> 5 to 6-    level <= 15 -> 6 to 8-    level <= 30 -> 7 to 9-    else -> 8 to 10+    level <= 3 -> 5 to 6+    level <= 8 -> 5 to 7+    level <= 14 -> 6 to 8+    level <= 21 -> 6 to 9+    level <= 29 -> 7 to 9+    level <= 38 -> 7 to 10+    level <= 48 -> 8 to 10+    level <= 60 -> 8 to 11+    else -> MAX_BOARD } +/** The largest board the ladder reaches, from [BIGGEST_BOARD_LEVEL] on. */+val MAX_BOARD: Pair<Int, Int> = 9 to 12++/** First level played on [MAX_BOARD]. */+const val BIGGEST_BOARD_LEVEL = 61++/**+ * Most arrows that may be launchable at once on a fresh board.+ *+ * A board where everything can go straight away is not a puzzle: the player taps at random and it comes+ * apart. Holding the opening to about a quarter of the arrows means most are pinned by something, so the+ * first move has to be found rather than guessed.+ *+ * Scaled to the arrow count rather than a flat number, because two of six is as tight as five of+ * nineteen — one flat cap would leave a small board trivial and a large one barely generatable.+ */+fun availabilityCapFor(arrowCount: Int): Int =+    ((arrowCount + AVAILABILITY_DIVISOR - 1) / AVAILABILITY_DIVISOR).coerceAtLeast(MIN_AVAILABLE)++/** Rounded up, so six arrows allow two and nineteen allow five. */+private const val AVAILABILITY_DIVISOR = 4++/** Below two there is only ever one legal move, which is a sequence to memorise rather than a puzzle. */+private const val MIN_AVAILABLE = 2+ /** How many arrows [level] should hold, scaled to the board it sits on. */ fun arrowCountForLevel(level: Int): Int {     val (cols, rows) = boardSizeForLevel(level)
games/arrows/src/main/java/com/vayunmathur/games/arrows/domain/ArrowsGenerator.kt
diff --git a/games/arrows/src/main/java/com/vayunmathur/games/arrows/domain/ArrowsGenerator.kt b/games/arrows/src/main/java/com/vayunmathur/games/arrows/domain/ArrowsGenerator.ktindex 0641c623b1..af00cfc17c 100644--- a/games/arrows/src/main/java/com/vayunmathur/games/arrows/domain/ArrowsGenerator.kt+++ b/games/arrows/src/main/java/com/vayunmathur/games/arrows/domain/ArrowsGenerator.kt@@ -4,6 +4,7 @@ import com.vayunmathur.games.arrows.data.ArrowPiece import com.vayunmathur.games.arrows.data.ArrowsPuzzle import com.vayunmathur.games.arrows.data.Direction import com.vayunmathur.games.arrows.data.Mirror+import com.vayunmathur.games.arrows.data.availabilityCapFor import kotlin.random.Random  /**@@ -16,6 +17,10 @@ import kotlin.random.Random  * alternative (paint a board, then search for an order) fails for the overwhelming majority of random  * layouts.  *+ * On top of that, two properties are steered for rather than left to chance, because random boards give+ * neither: every mirror lies on some arrow's route, and only a handful of arrows can leave at the start.+ * See [chooseCandidate].+ *  * A generated board can still have many solutions; nothing here tries to make the order unique.  */ object ArrowsGenerator {@@ -25,6 +30,9 @@ object ArrowsGenerator {      *      * Mirrors are placed first and permanently: arrows may not sit on them, and they bend any route      * that crosses them, so every subsequent exit check already accounts for them.+     *+     * @param openSlack added to the cap from [availabilityCapFor], for callers that would rather have a+     *   slightly loose board than none at all. Zero asks for the strict cap.      */     fun generate(         cols: Int,@@ -34,9 +42,10 @@ object ArrowsGenerator {         rng: Random,         minPieces: Int = (targetPieces * 2) / 3,         attempts: Int = DEFAULT_ATTEMPTS,+        openSlack: Int = 0,     ): ArrowsPuzzle? {         repeat(attempts) {-            build(cols, rows, targetPieces, mirrorCount, rng)+            build(cols, rows, targetPieces, mirrorCount, rng, openSlack)                 ?.takeIf { it.pieces.size >= minPieces }                 ?.let { return it }         }@@ -48,6 +57,17 @@ object ArrowsGenerator {      *      * Every seed is a pure function of [seed], so the same level number always yields the same board      * however many rounds it takes — that is what lets saved progress stay valid.+     *+     * Later rounds ask for less. Both board properties are hard rejections, and on some shapes the strict+     * pair is simply unreachable — measured across 120 levels, a fixed strict budget left about 4% of them+     * with no board at all, which is a dead level the player cannot pass. Conceding difficulty is far+     * better than that, so the concessions are ordered by how little they cost:+     *+     *  1. allow one or two more arrows to be launchable at the start;+     *  2. only then place fewer mirrors.+     *+     * Mirrors are never allowed to go *unused*, whatever the round — that was the whole point of the+     * exercise. Fewer redirectors that all matter beats four where one is scenery.      */     fun generateSeeded(         cols: Int,@@ -58,23 +78,50 @@ object ArrowsGenerator {         rounds: Int = DEFAULT_ROUNDS,     ): ArrowsPuzzle? {         for (round in 0 until rounds) {+            val concession = CONCESSIONS[round.coerceAtMost(CONCESSIONS.lastIndex)]             generate(                 cols = cols,                 rows = rows,                 targetPieces = targetPieces,-                mirrorCount = mirrorCount,+                mirrorCount = (mirrorCount - concession.fewerMirrors).coerceAtLeast(0),                 rng = Random(seed + round * SEED_STRIDE),+                openSlack = concession.openSlack,             )?.let { return it }         }         return null     } +    /** The most this will ever concede on the opening, once every round has been tried. */+    val MAX_OPEN_SLACK: Int get() = CONCESSIONS.maxOf { it.openSlack }++    /** How many mirrors it may drop rather than leave one unused. */+    val MAX_MIRRORS_DROPPED: Int get() = CONCESSIONS.maxOf { it.fewerMirrors }++    /** How much a given round is willing to give up. See [generateSeeded]. */+    private class Concession(val openSlack: Int, val fewerMirrors: Int)++    private val CONCESSIONS = listOf(+        // Four strict rounds before conceding anything: the cap is reachable on most shapes given enough+        // tries, and spending them here is what keeps the great majority of the ladder tight.+        Concession(openSlack = 0, fewerMirrors = 0),+        Concession(openSlack = 0, fewerMirrors = 0),+        Concession(openSlack = 0, fewerMirrors = 0),+        Concession(openSlack = 0, fewerMirrors = 0),+        Concession(openSlack = 1, fewerMirrors = 0),+        Concession(openSlack = 1, fewerMirrors = 0),+        Concession(openSlack = 2, fewerMirrors = 0),+        Concession(openSlack = 2, fewerMirrors = 1),+        Concession(openSlack = 3, fewerMirrors = 1),+        Concession(openSlack = 4, fewerMirrors = 2),+    )+     private fun build(         cols: Int,         rows: Int,         targetPieces: Int,         mirrorCount: Int,         rng: Random,+        openSlack: Int,     ): ArrowsPuzzle? {         val cellCount = cols * rows         // Mirrors are kept off the border: one on an edge cell mostly deflects arrows straight back@@ -88,33 +135,110 @@ object ArrowsGenerator {             .take(mirrorCount.coerceAtMost(interior.size))             .associateWith { if (rng.nextBoolean()) Mirror.FORWARD else Mirror.BACK } -        val occupied = mirrors.keys.toMutableSet()+        // Two different notions of "occupied", and conflating them is what made mirrors decorative: an+        // arrow may not be *drawn* on a mirror, but a mirror does not *block* a route - it bends it.+        // Treating mirror cells as blockers rejected every candidate whose path reached one, and since a+        // bend happens *on* the mirror cell, that was every candidate that would have used it.+        val undrawable = mirrors.keys.toMutableSet()+        val blocking = mutableSetOf<Int>()+         val pieces = mutableListOf<ArrowPiece>()+        // Escape paths depend only on the board's geometry, never on which arrows are present, so each+        // one can be kept from when its arrow was placed instead of being recomputed.+        val paths = mutableListOf<Set<Int>>()+        val unusedMirrors = mirrors.keys.toMutableSet()         var failures = 0          while (pieces.size < targetPieces && failures < MAX_CONSECUTIVE_FAILURES) {-            val candidate = randomPiece(cols, rows, occupied, pieces.size, rng)-            if (candidate == null) {+            val geometry = ArrowsPuzzle(cols, rows, pieces, mirrors)+            val chosen = chooseCandidate(+                geometry = geometry,+                undrawable = undrawable,+                blocking = blocking,+                paths = paths,+                unusedMirrors = unusedMirrors,+                id = pieces.size,+                rng = rng,+            )+            if (chosen == null) {                 failures++                 continue             }-            // The board as it stands, which is exactly what this arrow must be able to escape past.-            val soFar = ArrowsPuzzle(cols, rows, pieces, mirrors)-            val path = ArrowsRules.exitPath(soFar, candidate.head, candidate.direction)-            val blockers = occupied-            if (path == null || path.any { it in blockers }) {-                failures++-                continue-            }-            pieces += candidate-            occupied += candidate.cells+            pieces += chosen.piece+            paths += chosen.path+            undrawable += chosen.piece.cells+            blocking += chosen.piece.cells+            unusedMirrors -= chosen.path             failures = 0         }          if (pieces.isEmpty()) return null+        // A mirror nothing routes through is scenery. Throwing the board away is cheap next to shipping a+        // level whose one distinguishing feature does nothing.+        if (unusedMirrors.isNotEmpty()) return null+        if (openCount(pieces, paths) > availabilityCapFor(pieces.size) + openSlack) return null         return ArrowsPuzzle(cols, rows, pieces, mirrors)     } +    private class Candidate(val piece: ArrowPiece, val path: Set<Int>)++    /**+     * The most useful of several random candidates, or null if none was placeable.+     *+     * Sampling a handful and picking rather than taking the first legal one is what makes the two board+     * constraints reachable. Left to chance, mirrors are almost never on any arrow's route and most arrows+     * end up unobstructed, so nearly every board would be rejected and generation would stall.+     *+     * Scoring, in order of weight:+     *  - routing through a mirror nothing uses yet, since a board with one left over is discarded outright;+     *  - crossing existing escape paths, which is what pins other arrows and holds the opening down.+     *+     * Deliberately *not* scored: pinning only those arrows that can currently leave. It sounds like the+     * sharper objective, and measurably is not — chasing it concentrates arrows into the same region, which+     * starves later placements and leaves boards short of the arrow floor more often than it tightens them.+     */+    private fun chooseCandidate(+        geometry: ArrowsPuzzle,+        undrawable: Set<Int>,+        blocking: Set<Int>,+        paths: List<Set<Int>>,+        unusedMirrors: Set<Int>,+        id: Int,+        rng: Random,+    ): Candidate? {+        var best: Candidate? = null+        var bestScore = Int.MIN_VALUE+        repeat(CANDIDATES_PER_PIECE) {+            val piece = randomPiece(geometry.cols, geometry.rows, undrawable, id, rng)+                ?: return@repeat+            val path = ArrowsRules.exitPath(geometry, piece.head, piece.direction) ?: return@repeat+            // Must still be able to leave past everything already placed - that is what makes the+            // insertion order a solution - and must not be turned back into itself, which a mirror can+            // do. An arrow blocked by its own tail can never leave, at which point the board is unwinnable.+            if (path.any { it in blocking || it in piece.cells }) return@repeat++            var score = 0+            if (path.any { it in unusedMirrors }) score += MIRROR_SCORE+            score += paths.count { existing -> piece.cells.any { it in existing } }+            if (score > bestScore) {+                bestScore = score+                best = Candidate(piece, path.toSet())+            }+        }+        return best+    }++    /**+     * How many arrows could leave a finished board immediately.+     *+     * Mirrors [ArrowsRules.travel]: an arrow is stopped by any arrow cell on its route, its own included,+     * so the test is whether its path avoids every cell any arrow sits on.+     */+    private fun openCount(pieces: List<ArrowPiece>, paths: List<Set<Int>>): Int {+        val arrowCells = pieces.flatMapTo(mutableSetOf()) { it.cells }+        return pieces.indices.count { index -> paths[index].none { it in arrowCells } }+    }+     /**      * A random polyline of two to [MAX_LENGTH] cells that avoids [occupied] and itself.      *@@ -160,11 +284,23 @@ object ArrowsGenerator {     /** Longest arrow the generator will draw. Beyond this a piece dominates a small board. */     private const val MAX_LENGTH = 5 +    /**+     * Random candidates weighed up per arrow.+     *+     * The single biggest lever on how tangled a board comes out: more choice per arrow means more chance+     * one of them crosses an existing route. Costs a linear amount of work per arrow, which is cheap next+     * to discarding a whole board and starting again.+     */+    private const val CANDIDATES_PER_PIECE = 20++    /** Outweighs any amount of blocking: a board with an unused mirror is discarded outright. */+    private const val MIRROR_SCORE = 100+     /** Give up on a board once this many placement attempts in a row have failed. */     private const val MAX_CONSECUTIVE_FAILURES = 200      private const val DEFAULT_ATTEMPTS = 24-    private const val DEFAULT_ROUNDS = 8+    private const val DEFAULT_ROUNDS = 12      /** Keeps per-round seeds far apart so consecutive rounds do not rebuild near-identical boards. */     private const val SEED_STRIDE = 1_000_003L
games/arrows/src/main/java/com/vayunmathur/games/arrows/ui/ArrowsGameScreen.kt
diff --git a/games/arrows/src/main/java/com/vayunmathur/games/arrows/ui/ArrowsGameScreen.kt b/games/arrows/src/main/java/com/vayunmathur/games/arrows/ui/ArrowsGameScreen.ktindex 20ea3f2ee8..89cfd986d8 100644--- a/games/arrows/src/main/java/com/vayunmathur/games/arrows/ui/ArrowsGameScreen.kt+++ b/games/arrows/src/main/java/com/vayunmathur/games/arrows/ui/ArrowsGameScreen.kt@@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier@@ -84,6 +86,7 @@ fun ArrowsGameScreen(             Modifier                 .fillMaxSize()                 .padding(padding)+                .verticalScroll(rememberScrollState())                 .padding(horizontal = Spacing.md),             horizontalAlignment = Alignment.CenterHorizontally,             verticalArrangement = Arrangement.spacedBy(Spacing.md),
games/arrows/src/screenshotTest/kotlin/com/vayunmathur/games/arrows/MetadataPreviews.kt
diff --git a/games/arrows/src/screenshotTest/kotlin/com/vayunmathur/games/arrows/MetadataPreviews.kt b/games/arrows/src/screenshotTest/kotlin/com/vayunmathur/games/arrows/MetadataPreviews.ktindex 0fad332d04..20e369fa72 100644--- a/games/arrows/src/screenshotTest/kotlin/com/vayunmathur/games/arrows/MetadataPreviews.kt+++ b/games/arrows/src/screenshotTest/kotlin/com/vayunmathur/games/arrows/MetadataPreviews.kt@@ -11,6 +11,8 @@ import com.vayunmathur.games.arrows.data.DAILY_MIRRORS import com.vayunmathur.games.arrows.data.GameMode import com.vayunmathur.games.arrows.data.STARTING_HEARTS import com.vayunmathur.games.arrows.data.arrowCountForLevel+import com.vayunmathur.games.arrows.data.BIGGEST_BOARD_LEVEL+import com.vayunmathur.games.arrows.data.MAX_BOARD import com.vayunmathur.games.arrows.data.boardSizeForLevel import com.vayunmathur.games.arrows.data.mirrorCountForLevel import com.vayunmathur.games.arrows.domain.ArrowsGenerator@@ -78,6 +80,20 @@ class MetadataPreviews {         Board(game(level(2), level = 2, cleared = 0))     } +    /**+     * The largest board the ladder ever deals.+     *+     * Here to guard the layout: at [MAX_BOARD] a phone-width board is twelve rows deep, which is taller+     * than the content area, so this is what shows whether the screen still holds together at the extreme+     * rather than only at the tutorial sizes.+     */+    @PreviewTest+    @Preview(name = "5-largest", device = PHONE, showSystemUi = true)+    @Composable+    fun Preview5Largest() {+        Board(game(level(BIGGEST_BOARD_LEVEL), level = BIGGEST_BOARD_LEVEL, cleared = 2))+    }+     @Composable     private fun Board(game: ArrowsGameState, streak: Long = 0) {         // Layoutlib has no wallpaper to sample, so Material You falls back to the default palette.
games/arrows/src/test/java/com/vayunmathur/games/arrows/domain/GeneratedBoardPropertiesTest.kt
diff --git a/games/arrows/src/test/java/com/vayunmathur/games/arrows/domain/GeneratedBoardPropertiesTest.kt b/games/arrows/src/test/java/com/vayunmathur/games/arrows/domain/GeneratedBoardPropertiesTest.ktnew file mode 100644index 0000000000..a3424958f7--- /dev/null+++ b/games/arrows/src/test/java/com/vayunmathur/games/arrows/domain/GeneratedBoardPropertiesTest.kt@@ -0,0 +1,185 @@+package com.vayunmathur.games.arrows.domain++import com.vayunmathur.games.arrows.data.ArrowsGameState+import com.vayunmathur.games.arrows.data.ArrowsPuzzle+import com.vayunmathur.games.arrows.data.GameMode+import com.vayunmathur.games.arrows.data.STARTING_HEARTS+import com.vayunmathur.games.arrows.data.arrowCountForLevel+import com.vayunmathur.games.arrows.data.availabilityCapFor+import com.vayunmathur.games.arrows.data.boardSizeForLevel+import com.vayunmathur.games.arrows.data.mirrorCountForLevel+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertNotNull+import kotlin.test.assertTrue++/**+ * The properties every board in the level ladder has to hold, checked against the real level+ * configuration rather than hand-built fixtures — these are the boards players actually get.+ */+class GeneratedBoardPropertiesTest {++    private val ladder = 1..LADDER_DEPTH++    private fun boardFor(level: Int): ArrowsPuzzle? = BOARDS[level]++    @Test+    fun everyLevelInTheLadderProducesABoard() {+        // A null here is a level the player cannot pass, so this is the one result that must never regress.+        val missing = ladder.filter { boardFor(it) == null }+        assertTrue(missing.isEmpty(), "no board generated for levels $missing")+    }++    @Test+    fun everyMirrorIsOnSomeArrowsRoute() {+        // The point of the exercise: a redirector nothing routes through is scenery.+        for (level in ladder) {+            val puzzle = boardFor(level) ?: continue+            val unused = puzzle.mirrors.keys.filter { mirror ->+                puzzle.pieces.none { piece ->+                    ArrowsRules.exitPath(puzzle, piece.head, piece.direction)?.contains(mirror) == true+                }+            }+            assertTrue(unused.isEmpty(), "level $level has mirrors no arrow uses: $unused")+        }+    }++    @Test+    fun mirrorsAreDroppedRatherThanLeftUnused() {+        // Relaxation may place fewer mirrors than asked for, but never more than it is allowed to drop.+        for (level in ladder) {+            val puzzle = boardFor(level) ?: continue+            val asked = mirrorCountForLevel(level)+            val floor = (asked - ArrowsGenerator.MAX_MIRRORS_DROPPED).coerceAtLeast(0)+            assertTrue(+                puzzle.mirrors.size in floor..asked,+                "level $level asked for $asked mirrors and got ${puzzle.mirrors.size}",+            )+        }+    }++    @Test+    fun noBoardOpensWithEveryArrowLaunchable() {+        // The complaint this was built to answer: if everything can go on move one it is not a puzzle.+        for (level in ladder) {+            val puzzle = boardFor(level) ?: continue+            val open = openCount(puzzle)+            assertTrue(+                open < puzzle.pieces.size,+                "level $level opens with all ${puzzle.pieces.size} arrows launchable",+            )+        }+    }++    @Test+    fun theOpeningStaysWithinTheAvailabilityCap() {+        for (level in ladder) {+            val puzzle = boardFor(level) ?: continue+            val cap = availabilityCapFor(puzzle.pieces.size) + ArrowsGenerator.MAX_OPEN_SLACK+            val open = openCount(puzzle)+            assertTrue(open <= cap, "level $level opens $open arrows, over the $cap ceiling")+        }+    }++    @Test+    fun theOpeningIsTightOnTheOverwhelmingMajorityOfLevels() {+        // The ceiling above is the hard guarantee; this pins the typical case, so a change that quietly+        // relies on the slack for every board fails here rather than shipping a ladder of loose openings.+        val strict = ladder.count { level ->+            val puzzle = boardFor(level) ?: return@count false+            openCount(puzzle) <= availabilityCapFor(puzzle.pieces.size)+        }+        assertTrue(+            strict >= LADDER_DEPTH * 8 / 10,+            "only $strict of $LADDER_DEPTH levels met the strict cap",+        )+    }++    @Test+    fun everyBoardCanActuallyBeCleared() {+        // Solvability is structural — arrows are added in the reverse of a working removal order — but+        // mirrors can bend a route back into the arrow that owns it, which would strand it forever. This+        // is what proves the guarantee survived turning mirrors on.+        for (level in ladder) {+            val puzzle = boardFor(level) ?: continue+            val order = ArrowsRules.solve(puzzle)+            assertNotNull(order, "level $level cannot be cleared")+            assertEquals(+                puzzle.pieces.size,+                order.size,+                "level $level solution leaves arrows behind",+            )+        }+    }++    @Test+    fun boardsGrowWithTheLevelAndThenStop() {+        val areas = (1..80).map { boardSizeForLevel(it).let { (c, r) -> c * r } }+        assertTrue(+            areas.zipWithNext().all { (a, b) -> b >= a },+            "board area must never shrink as levels advance",+        )+        assertEquals(+            boardSizeForLevel(200),+            boardSizeForLevel(80),+            "the board should stop growing rather than run away",+        )+    }++    @Test+    fun generatingTheWholeLadderStaysAffordable() {+        // Generation is off the main thread behind a spinner, so this is about not leaving the player+        // watching it. Deliberately loose: it is a guard against a pathological regression, not a target.+        // Generates fresh rather than reusing the shared ladder, since the point is to time the work.+        val started = System.nanoTime()+        val boards = ladder.count { generate(it) != null }+        val millis = (System.nanoTime() - started) / 1_000_000+        assertEquals(LADDER_DEPTH, boards)+        assertTrue(millis < BUDGET_MILLIS, "generating $LADDER_DEPTH boards took ${millis}ms")+    }++    /**+     * Arrows that could leave immediately.+     *+     * Deliberately written from [ArrowsRules] rather than reusing the generator's own bookkeeping, so a+     * bug in that bookkeeping cannot hide behind agreeing with itself.+     */+    private fun openCount(puzzle: ArrowsPuzzle): Int {+        val state = ArrowsGameState(+            puzzle = puzzle,+            removed = emptySet(),+            hearts = STARTING_HEARTS,+            mode = GameMode.CASUAL,+            level = 1,+        )+        return ArrowsRules.clearableNow(state).size+    }++    private companion object {+        /** Deep enough to cover every board size and mirror count the ladder reaches. */+        const val LADDER_DEPTH = 120++        const val LEVEL_SEED = 104_729L++        /** Roughly three times the measured cost, so ordinary variation does not turn this red. */+        const val BUDGET_MILLIS = 25_000L++        fun generate(level: Int): ArrowsPuzzle? = ArrowsGenerator.generateSeeded(+            cols = boardSizeForLevel(level).first,+            rows = boardSizeForLevel(level).second,+            targetPieces = arrowCountForLevel(level),+            mirrorCount = mirrorCountForLevel(level),+            seed = level.toLong() * LEVEL_SEED,+        )++        /**+         * The whole ladder, built once.+         *+         * JUnit makes a fresh instance per test method, so without this every test would rebuild all 120+         * boards and the suite would spend over a minute generating the same thing eight times.+         */+        val BOARDS: Map<Int, ArrowsPuzzle?> by lazy {+            (1..LADDER_DEPTH).associateWith { generate(it) }+        }+    }+}
metadata_data/photos/games-arrows/1.png
diff --git a/metadata_data/photos/games-arrows/1.png b/metadata_data/photos/games-arrows/1.pngindex 601f5b4857..d83edd14ad 100644Binary files a/metadata_data/photos/games-arrows/1.png and b/metadata_data/photos/games-arrows/1.png differ
metadata_data/photos/games-arrows/2.png
diff --git a/metadata_data/photos/games-arrows/2.png b/metadata_data/photos/games-arrows/2.pngindex ee138d3bb8..b837b84254 100644Binary files a/metadata_data/photos/games-arrows/2.png and b/metadata_data/photos/games-arrows/2.png differ
metadata_data/photos/games-arrows/3.png
diff --git a/metadata_data/photos/games-arrows/3.png b/metadata_data/photos/games-arrows/3.pngindex a974d03cca..ee1c1bc01a 100644Binary files a/metadata_data/photos/games-arrows/3.png and b/metadata_data/photos/games-arrows/3.png differ
metadata_data/photos/games-arrows/4.png
diff --git a/metadata_data/photos/games-arrows/4.png b/metadata_data/photos/games-arrows/4.pngindex 0f0fda893e..b6472cf221 100644Binary files a/metadata_data/photos/games-arrows/4.png and b/metadata_data/photos/games-arrows/4.png differ
metadata_data/photos/games-arrows/5.png
diff --git a/metadata_data/photos/games-arrows/5.png b/metadata_data/photos/games-arrows/5.pngnew file mode 100644index 0000000000..d07b82925eBinary files /dev/null and b/metadata_data/photos/games-arrows/5.png differ