Orbit Arcade: Block Drop

A falling-blocks puzzle for the remote (from the game list Paul approved on 2
November 2026): left and right move, up turns, down drops a row, OK drops
all the way, Back pauses. Seven shapes from a shuffled bag, a landing guide,
the next shape shown, rows clear for 100/300/500/800 times the level, the
level rises every ten rows and quickens gravity. Orbit's own colours; best
score kept on the box. In the arcade's honeycomb beside Snake and OrbitHive.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-05 17:25:31 +00:00
co-authored by Claude Opus 5.5
parent 80a37131ab
commit b1a2c88f1b
4 changed files with 283 additions and 3 deletions
@@ -0,0 +1,48 @@
package tv.orbit.classic
import org.junit.Assert.*
import org.junit.Test
/** Block Drop: moves, turns with nudges off the walls, full rows clear for points, the bag deals every shape, and the stack ends it. */
class BlockDropTest {
private val random = java.util.Random(7)
private fun empty() = List(BLOCK_ROWS) { IntArray(BLOCK_COLUMNS) }
@Test fun fourTurnsComeBackToTheStart() {
for (kind in 0 until 7) assertEquals(shapeCells(kind, 0).toSet(), shapeCells(kind, 4).toSet())
assertEquals(4, shapeCells(0, 1).size)
}
@Test fun movesStopAtTheWallsAndATurnIsNudgedOffThem() {
var g = BlockGame(empty(), BlockPiece(0, 1, 0, 2), 1, emptyList()) // the bar, upright
repeat(12) { g = g.move(-1) }
assertTrue(g.piece.cells().all { it.first >= 0 })
val turned = g.turn()
assertNotEquals(g.piece.turns, turned.piece.turns) // turned, nudged clear of the wall
assertTrue(turned.piece.cells().all { it.first in 0 until BLOCK_COLUMNS })
}
@Test fun aFullRowClearsAndScoresByLevel() {
val board = empty().also { b -> for (x in 0 until BLOCK_COLUMNS - 4) b[BLOCK_ROWS - 1][x] = 3 }
val g = BlockGame(board, BlockPiece(0, 0, BLOCK_COLUMNS - 4, 5), 1, emptyList()) // the flat bar fills the gap
val after = g.drop(random)
assertEquals(1, after.lines)
assertTrue(after.board[BLOCK_ROWS - 1].all { it == 0 })
assertEquals(100 + (BLOCK_ROWS - 2 - 5) * 2, after.score) // the row, plus two points a row dropped
assertTrue(after.alive)
}
@Test fun theBagDealsEveryShapeBeforeRepeating() {
var bag = emptyList<Int>(); val seen = mutableListOf<Int>()
repeat(7) { val (k, b) = BlockGame.draw(bag, random); seen += k; bag = b }
assertEquals((0 until 7).toSet(), seen.toSet())
}
@Test fun aStackToTheTopEndsTheGameAndTheLevelQuickens() {
val board = empty().also { b -> for (y in 2 until BLOCK_ROWS) for (x in 0 until BLOCK_COLUMNS) if (x != y % BLOCK_COLUMNS) b[y][x] = 1 }
val over = BlockGame(board, BlockPiece(1, 0, 4, 0), 1, emptyList()).drop(random)
assertFalse(over.alive)
assertTrue(BlockGame(empty(), BlockPiece(1, 0, 4, 0), 1, emptyList(), lines = 50).tickMs < BlockGame.start(random).tickMs)
assertEquals(90L, BlockGame(empty(), BlockPiece(1, 0, 4, 0), 1, emptyList(), lines = 500).tickMs)
}
}