Test Card Tangle: thirty calm cable puzzles over Orbit's own test card, bot-checked within par

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 11:19:07 +00:00
co-authored by Claude Opus 5.5
parent 17166bc93f
commit 254c5fc09a
5 changed files with 385 additions and 5 deletions
@@ -16,7 +16,7 @@ class KidsArcadeTest {
@Test fun grownUpsSeeEveryGame() {
assertEquals(ArcadeGames.all.map { it.id }, ids(grown))
assertEquals(14, ids(grown).size)
assertEquals(15, ids(grown).size)
// A grown-up's Arcade for Kids setting means nothing.
assertEquals(ArcadeGames.all.map { it.id }, ids(grown.withKidsArcade(KidsArcade.Off)))
assertEquals(ArcadeGames.all.map { it.id }, ids(null))
@@ -70,16 +70,16 @@ class KidsArcadeTest {
@Test fun theFamilyLineSaysWhatKidsReallySee() {
// The audit: "On: the games chosen for Kids" promised a choice that didn't exist.
assertEquals("Off: no Arcade for Kids", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Off)))
assertEquals("Kids-suitable games: 12 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable)))
assertEquals("Kids-suitable games: 13 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.KidsSuitable)))
assertEquals("Chosen games: 2 to play", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, setOf("Pairs", "Sky", "Retired"))))
assertEquals("Chosen games: none chosen yet, so no Arcade", arcadeForKidsLine(kids.withKidsArcade(KidsArcade.Chosen, emptySet())))
}
@Test fun everyGameIsDescribed() {
assertEquals(ArcadeGames.all.size, ArcadeGames.all.map { it.id }.toSet().size)
assertEquals(6, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size)
assertEquals(7, ArcadeGames.originals.size); assertEquals(8, ArcadeGames.classics.size)
// All five Originals play now (Orbiteroids, the last, 9 November 2026); every Classic does.
assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift", "Orbiteroids", "QuizNight"), ArcadeGames.originals.filter { it.launchable }.map { it.id })
assertEquals(listOf("OrbiRaiders", "ChannelChaos", "Hive", "NightShift", "Orbiteroids", "QuizNight", "TestCardTangle"), ArcadeGames.originals.filter { it.launchable }.map { it.id })
assertTrue(ArcadeGames.classics.all { it.launchable })
ArcadeGames.all.forEach { g ->
assertTrue(g.id, g.controls.isNotEmpty()); assertTrue(g.id, g.title.isNotBlank()); assertTrue(g.id, g.goal.isNotBlank())
@@ -0,0 +1,55 @@
package tv.orbit.classic.arcade.tangle
import org.junit.Assert.*
import org.junit.Test
class TangleTest {
/** The bot: walks to each piece and turns it until it matches the answer, counting turns as moves. */
private fun bot(level: TangleLevel): TangleGame {
var g = TangleGame(level)
for (i in 0 until level.w * level.h) {
while (g.cursor % level.w != i % level.w) g = g.move(Integer.signum(i % level.w - g.cursor % level.w), 0)
while (g.cursor / level.w != i / level.w) g = g.move(0, Integer.signum(i / level.w - g.cursor / level.w))
while (g.sides[i] != level.solution[i]) g = g.turn()
}
return g
}
@Test fun thirtyLevelsGrowingAndNoneStartsSolved() {
assertEquals(30, TangleLevels.size); assertEquals(3, TanglePacks.size)
assertEquals(TangleLevels.map { it.w * it.h }.sorted(), TangleLevels.map { it.w * it.h })
for (l in TangleLevels) {
assertFalse("level ${l.number} starts solved", TangleGame(l).solved)
// The answer is a proper tangle: every square joined, no loose end.
assertTrue("level ${l.number}'s answer", TangleGame(l, l.solution.copyOf()).solved)
assertTrue(l.solution.all { it != 0 })
}
}
@Test fun aBotSolvesEveryLevelWithinDriftsPar() {
for (l in TangleLevels) {
val g = bot(l)
assertTrue("level ${l.number}", g.solved)
assertEquals("level ${l.number}", l.minTurns, g.moves)
assertTrue(g.moves <= tanglePar(l))
}
}
@Test fun turningAndJoiningUp() {
val l = TangleLevels[0]
var g = TangleGame(l)
assertTrue(g.lit()[l.source])
val before = g.sides[g.cursor]; g = g.turn()
assertEquals(turnSides(before, 1), g.sides[g.cursor]); assertEquals(1, g.moves)
assertEquals(g.cursor, g.move(0, 0).cursor)
assertEquals(0, g.move(-9, -9).cursor)
}
@Test fun starsAndProgress() {
assertEquals(3, tangleStars(10, 10)); assertEquals(2, tangleStars(13, 10)); assertEquals(1, tangleStars(30, 10))
var saved = emptyMap<String, String>()
assertEquals(1, TangleProgress.next(saved))
saved = saved + (TangleProgress.key(1) to "3,8")
assertEquals(2, TangleProgress.next(saved)); assertEquals(1, TangleProgress.cleared(saved)); assertEquals(3, TangleProgress.stars(saved))
}
}