Package-level declarations

Pure Kotlin game rules: the Tic-Tac-Toe board and AI, the Blocks falling-block engine and the Word Hive generator. No Android dependencies, so everything here is unit-tested on the JVM.

Types

Link copied to clipboard
object Ai

Computer opponent.

Link copied to clipboard
@Serializable
enum BlocksDifficulty : Enum<BlocksDifficulty>

Board size, starting speed and a line milestone. Play is endless — a run ends only when the stack tops out — and a run that passed its milestone counts as a win.

Link copied to clipboard
class BlocksGame(val difficulty: BlocksDifficulty, random: Random = Random.Default)

Falling-block puzzle state. Pure logic: the screen calls tick on a timer and the move functions from gestures, then redraws. Cells hold 0 for empty or Tetromino.ordinal + 1.

Link copied to clipboard
@Serializable
data class BlocksSnapshot(val difficulty: BlocksDifficulty, val grid: List<Int>, val piece: Tetromino, val rot: Int, val px: Int, val py: Int, val bag: List<Tetromino>, val score: Int, val lines: Int, val won: Boolean)
Link copied to clipboard
class Board

Immutable board snapshot.

Link copied to clipboard
Link copied to clipboard
data class Hex(val q: Int, val r: Int)

Axial hex coordinate.

Link copied to clipboard
class HivePuzzle(val spec: HiveSpec, val letters: Map<Hex, Char>, val words: List<PlacedWord>)

A hive of letters hiding words as paths of neighbouring cells. Players trace any path of adjacent cells; target words are accepted, other real words count as extras.

Link copied to clipboard
data class HiveScore(val base: Int, val bonus: Int, val tier: String?)

A scored word: base points plus any long-word bonus, and its bonus tier name.

Link copied to clipboard
data class HiveSpec(val level: Int)

How big and wordy each level is.

Link copied to clipboard
sealed interface HiveVerdict

What a traced sequence of cells turned out to be.

Link copied to clipboard
object Ludo
Link copied to clipboard
@Serializable
sealed interface LudoAction

Something a seat does. Every action names who is doing it, so the host can check they're allowed to.

Link copied to clipboard
object LudoBoard
Link copied to clipboard
object LudoBot

A CPU seat's choices.

Link copied to clipboard
@Serializable
enum LudoColor : Enum<LudoColor>

Seat colours, in clockwise turn order, placed like the photo: blue TL, red TR, green BR, yellow BL.

Link copied to clipboard
@Serializable
data class LudoDuel(val challenger: LudoColor, val opponent: LudoColor, val board: String = ".........", val round: Int = 1, val toMove: Mark = Mark.X, val draws: Int = 0)

A Tic-Tac-Toe duel for the right to roll. challenger plays ✕ in odd rounds and ◯ in even rounds.

Link copied to clipboard
@Serializable
enum LudoPhase : Enum<LudoPhase>
Link copied to clipboard
@Serializable
data class LudoSeat(val color: LudoColor, val kind: SeatKind, val name: String, val device: Int = 0, val avatarColor: Long = color.argb)
Link copied to clipboard
@Serializable
data class LudoState(val seats: List<LudoSeat>, val pawns: Map<LudoColor, List<Int>>, val turn: LudoColor, val phase: LudoPhase = LudoPhase.CHOOSE_OPPONENT, val duel: LudoDuel? = null, val roller: LudoColor? = null, val die: Int? = null, val movable: List<Int> = emptyList(), val winner: LudoColor? = null, val difficulty: Difficulty = Difficulty.MEDIUM, val version: Int = 0, val lastEvent: String = "")
Link copied to clipboard
enum Mark : Enum<Mark>
Link copied to clipboard
data class PlacedWord(val word: String, val cells: List<Hex>)
Link copied to clipboard
class Rules

Line geometry for an N×N board. 3×3 needs three in a row; larger boards need four, which keeps 4×4 and 5×5 winnable without being trivial.

Link copied to clipboard
@Serializable
enum SeatKind : Enum<SeatKind>
Link copied to clipboard
@Serializable
enum Tetromino : Enum<Tetromino>
Link copied to clipboard
data class WinLine(val cells: List<Int>, val mark: Mark)

A completed line: the cell indices in board order, and who owns them.

Link copied to clipboard
object WordBank

Functions

Link copied to clipboard
fun hiveHintCost(level: Int): Int
Link copied to clipboard
fun hiveScore(word: String, level: Int, extra: Boolean, hinted: Boolean): HiveScore

Longer words pay more per letter and earn escalating bonuses: 5 letters "Nice", 6 "Great", 7 "Superb", 8+ "Legendary". Extras pay less; hints halve targets.