games-chess: pass 3 rules/models/VM remainder tests
- Commit
9d5cfe3e0398695a89ae4635e19189d7ac5e2756- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 12:41 UTC (29 days ago)
- Parents
06c6b51
LearnRulesPass3Test pins every LearnRules goal (apples/captureAll/ check/checkIn/escapeCheck/mate/castle/protection), capture detection modes, path constraints, stars/bonus/piece values over FEN boards. LichessModelsPass3Test pins UCI parse/format, envelope and game-line decoding, terminal statuses, time controls, and Route serialization. ChessPass3VmRemainderTest: Maia is unavailable on the JVM (bestMove null, close idempotent), VsAI games with no model keep the player's move only, the protection lesson punishes a hanging move with the scripted capture, and the castling lesson completes. Verified: all three classes pass. (cherry picked from commit f62ec711740286a4293ac618c5a065540f91a2a3)
Diff
games/chess/src/test/java/com/vayunmathur/games/chess/network/LichessModelsPass3Test.kt
diff --git a/games/chess/src/test/java/com/vayunmathur/games/chess/network/LichessModelsPass3Test.kt b/games/chess/src/test/java/com/vayunmathur/games/chess/network/LichessModelsPass3Test.ktnew file mode 100644index 0000000000..1b60066a46--- /dev/null+++ b/games/chess/src/test/java/com/vayunmathur/games/chess/network/LichessModelsPass3Test.kt@@ -0,0 +1,135 @@+package com.vayunmathur.games.chess.network++import com.vayunmathur.games.chess.Route+import com.vayunmathur.games.chess.data.PieceColor+import com.vayunmathur.games.chess.data.PieceType+import com.vayunmathur.games.chess.data.Position+import kotlinx.serialization.json.Json+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFailsWith+import kotlin.test.assertFalse+import kotlin.test.assertTrue++/** Pass 3: Lichess DTO decoding, UCI helpers, terminal statuses, Route keys. */+class LichessModelsPass3Test {++ private val json = Json { ignoreUnknownKeys = true; isLenient = true }++ @Test fun uciParsingAndFormatting() {+ assertEquals(UciMove(Position(6, 4), Position(4, 4)), parseUci("e2e4"))+ assertEquals(UciMove(Position(1, 4), Position(0, 4), PieceType.QUEEN), parseUci("e7e8q"))+ assertEquals("e7e8q", parseUci("e7e8q").toString())+ assertEquals("e1g1", UciMove(Position(7, 4), Position(7, 6)).toString())+ assertEquals(UciMove(Position(0, 0), Position(7, 7), PieceType.KNIGHT), parseUci("a8h1n"))+ assertFailsWith<IllegalArgumentException> { parseUci("e2e") }+ assertFailsWith<IllegalArgumentException> { parseUci("e2e4e5") }+ assertFailsWith<IllegalArgumentException> { parseUci("e7e8x") }+ assertEquals(Position(0, 0), Position(7, 0).let { squareFromUci("a8") })+ assertEquals("a8", Position(0, 0).toUciSquare())+ assertEquals("h1", Position(7, 7).toUciSquare())++ assertEquals(emptyList(), splitUciMoves(""))+ assertEquals(emptyList(), splitUciMoves(" "))+ assertEquals(listOf("e2e4", "e7e5"), splitUciMoves("e2e4 e7e5"))+ }++ @Test fun colorAndPromotionMappings() {+ assertEquals(PieceColor.WHITE, colorFromLichess("white"))+ assertEquals(PieceColor.BLACK, colorFromLichess("black"))+ assertFailsWith<IllegalArgumentException> { colorFromLichess("green") }+ assertEquals("white", PieceColor.WHITE.toLichessColor())+ assertEquals("black", PieceColor.BLACK.toLichessColor())+ assertEquals('q', PieceType.QUEEN.toUciPromotion())+ assertEquals('r', PieceType.ROOK.toUciPromotion())+ assertEquals('b', PieceType.BISHOP.toUciPromotion())+ assertEquals('n', PieceType.KNIGHT.toUciPromotion())+ assertEquals('q', PieceType.KING.toUciPromotion())+ assertEquals('q', PieceType.PAWN.toUciPromotion())+ }++ @Test fun envelopeDecodingVariants() {+ fun env(text: String) = json.decodeFromString(LichessEventEnvelope.serializer(), text).toEvent()+ assertEquals(+ LichessEvent.GameStart("g1", PieceColor.BLACK, "opp"),+ env("""{"type":"gameStart","game":{"gameId":"g1","color":"black","opponent":{"username":"opp"}}}"""),+ )+ assertEquals(LichessEvent.GameFinish("g2"), env("""{"type":"gameFinish","game":{"gameId":"g2"}}"""))+ assertEquals(+ LichessEvent.Challenge("c1", "carol"),+ env("""{"type":"challenge","challenge":{"id":"c1","challenger":{"username":"carol"}}}"""),+ )+ assertEquals(+ LichessEvent.ChallengeDeclined("c2"),+ env("""{"type":"challengeDeclined","challenge":{"id":"c2"}}"""),+ )+ assertEquals(LichessEvent.Ignored, env("""{"type":"friendOnline"}"""))+ assertEquals(LichessEvent.Ignored, env("""{}"""))+ // Missing nested payloads degrade to empty defaults, never crash.+ assertEquals(LichessEvent.GameStart("", PieceColor.WHITE, ""), env("""{"type":"gameStart"}"""))+ }++ @Test fun gameLineDecodingAndTerminalStatuses() {+ fun line(text: String) = decodeGameLine(json.parseToJsonElement(text), json)+ val full = line(+ """{"type":"gameFull","id":"g9","rated":true,"white":{"id":"a","name":"A"},"black":{"id":"b","name":"B"},"state":{"moves":"e2e4","status":"started","wtime":1000}}"""+ ) as LichessGameUpdate.Full+ assertEquals("g9", full.game.id)+ assertTrue(full.game.rated)+ assertEquals(PieceColor.WHITE, full.game.myColor("a"))+ assertEquals(PieceColor.BLACK, full.game.myColor("b"))+ assertEquals(PieceColor.WHITE, full.game.myColor("someone-else"))+ val state = line("""{"type":"gameState","moves":"","status":"mate","winner":"black"}""") as LichessGameUpdate.State+ assertTrue(state.state.isTerminal)+ assertEquals(LichessGameUpdate.Ignored, line("""{"type":"chatLine"}"""))+ assertEquals(LichessGameUpdate.Ignored, line("""[]"""))+ assertEquals(LichessGameUpdate.Ignored, line("""{"other":1}"""))++ for (status in listOf("aborted", "mate", "resign", "stalemate", "timeout", "draw", "outoftime", "cheat", "noStart", "variantEnd")) {+ assertTrue(GameState(status = status).isTerminal, status)+ }+ assertFalse(GameState(status = "started").isTerminal)+ assertFalse(GameState(status = "created").isTerminal)+ val clock = LichessClock(60000, 2000)+ assertEquals(60000, clock.initial)+ assertEquals(LichessVariant().key, "standard")+ }++ @Test fun timeControlsAndProfileDefaults() {+ assertEquals("1+0", LichessTimeControl.BULLET.label)+ assertEquals("3+2", LichessTimeControl.BLITZ_3_2.label)+ assertEquals("10+0", LichessTimeControl.RAPID_10_0.label)+ assertEquals(+ listOf(+ LichessTimeControl.BULLET, LichessTimeControl.BLITZ_3_2,+ LichessTimeControl.RAPID_5_3, LichessTimeControl.RAPID_10_0,+ ),+ LichessTimeControl.PRESETS,+ )+ assertEquals(LichessProfile(), LichessProfile("", ""))+ assertEquals(LichessPlayer().name, "")+ }++ @Test fun routesSerializeAndCompare() {+ assertEquals(Route.Game, Route.Game)+ assertEquals(Route.Online, Route.Online)+ assertEquals(Route.Puzzles, Route.Puzzles)+ assertEquals(Route.Learn, Route.Learn)+ assertEquals(Route.GameCenter, Route.GameCenter)+ val stage = Route.LearnStage("chessPieces", "rook")+ assertEquals("chessPieces", stage.categoryKey)+ assertEquals("rook", stage.stageKey)+ assertEquals(stage, Route.LearnStage("chessPieces", "rook"))+ assertTrue(Route.Game != Route.Online)++ val encoded = kotlinx.serialization.json.Json.encodeToString(Route.serializer(), stage)+ assertEquals(stage, kotlinx.serialization.json.Json.decodeFromString(Route.serializer(), encoded))+ assertEquals(+ Route.Game,+ kotlinx.serialization.json.Json.decodeFromString(+ Route.serializer(),+ kotlinx.serialization.json.Json.encodeToString(Route.serializer(), Route.Game),+ ),+ )+ }+}
games/chess/src/test/java/com/vayunmathur/games/chess/util/ChessPass3VmRemainderTest.kt
diff --git a/games/chess/src/test/java/com/vayunmathur/games/chess/util/ChessPass3VmRemainderTest.kt b/games/chess/src/test/java/com/vayunmathur/games/chess/util/ChessPass3VmRemainderTest.ktnew file mode 100644index 0000000000..628a7c69bd--- /dev/null+++ b/games/chess/src/test/java/com/vayunmathur/games/chess/util/ChessPass3VmRemainderTest.kt@@ -0,0 +1,135 @@+package com.vayunmathur.games.chess.util++import android.app.Application+import android.content.Context+import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.games.chess.data.Board+import com.vayunmathur.games.chess.data.LearnRepository+import com.vayunmathur.games.chess.data.PieceColor+import com.vayunmathur.games.chess.data.Position+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.ExperimentalCoroutinesApi+import kotlinx.coroutines.runBlocking+import kotlinx.coroutines.test.resetMain+import kotlinx.coroutines.test.setMain+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import kotlin.test.AfterTest+import kotlin.test.BeforeTest+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertNull+import kotlin.test.assertTrue++/** Pass 3: Maia availability on JVM, VsAI flow with no model, Learn punish path. */+@OptIn(ExperimentalCoroutinesApi::class)+@RunWith(RobolectricTestRunner::class)+class ChessPass3VmRemainderTest {++ private val app get() = ApplicationProvider.getApplicationContext<Application>()+ private val ctx: Context get() = app++ @BeforeTest fun setUp() {+ Dispatchers.setMain(Dispatchers.Unconfined)+ LearnRepository.ensureLoaded(ctx)+ }++ @AfterTest fun tearDown() = Dispatchers.resetMain()++ private fun await(desc: String, timeoutMs: Long = 15_000, cond: () -> Boolean) {+ val deadline = System.currentTimeMillis() + timeoutMs+ while (System.currentTimeMillis() < deadline) {+ if (cond()) return+ Thread.sleep(25)+ }+ assertTrue(cond(), "timed out: $desc")+ }++ private fun sq(file: Char, rank: Int) = Position(8 - rank, file - 'a')++ @Test fun maiaIsUnavailableOnJvmAndBestMoveIsNull() = runBlocking {+ val api = ChessApi(app)+ assertEquals(false, api.isAvailable(), "no Vulkan model runner on the JVM")+ assertNull(api.getBestMove(Board.initialState, PieceColor.WHITE, Difficulty.BEGINNER))+ api.close()+ api.close()+ // Difficulty contract: four ascending ratings.+ assertEquals(listOf(1100, 1500, 1900, 2500), Difficulty.entries.map { it.elo })+ assertTrue(Difficulty.BEGINNER.temperature > Difficulty.GRANDMASTER.temperature)+ }++ @Test fun vsAiGameWithNoModelKeepsPlayerMoveOnly() {+ val vm = ChessViewModel(app)+ vm.onNewGame(GameMode.VsAI(PieceColor.WHITE, Difficulty.BEGINNER))+ assertEquals(GameMode.VsAI(PieceColor.WHITE, Difficulty.BEGINNER), vm.uiState.value.gameMode)+ vm.onSquareClick(sq('e', 2))+ vm.onSquareClick(sq('e', 4))+ assertEquals(1, vm.uiState.value.board.moves.size)+ // The AI reply is attempted (500 ms delay + engine probe) and, with no+ // model on this host, simply never lands: the position is untouched+ // regardless of when the probe finishes.+ Thread.sleep(1200)+ assertEquals(1, vm.uiState.value.board.moves.size)+ assertNull(vm.uiState.value.gameResult)++ // As Black, the AI (White) is asked to open and likewise cannot.+ vm.onNewGame(GameMode.VsAI(PieceColor.BLACK, Difficulty.ADVANCED))+ assertTrue(vm.uiState.value.isBoardFlipped)+ Thread.sleep(1200)+ assertEquals(0, vm.uiState.value.board.moves.size)+ }++ @Test fun learnProtectionLevelPunishesHangingMove() {+ val vm = LearnViewModel(app)+ vm.loadStage("fundamentals", "protection")+ await("protection loaded") { vm.uiState.value.level != null }+ val state = vm.uiState.value+ val level = state.level!!+ // Find a legal move after which the opponent has an unprotected capture.+ var hanging: Pair<Position, Position>? = null+ outer@ for (r in 0..7) for (c in 0..7) {+ val piece = state.board.pieces[r][c] ?: continue+ if (piece.color != state.playerColor) continue+ for (r2 in 0..7) for (c2 in 0..7) {+ val from = Position(r, c)+ val to = Position(r2, c2)+ if (!state.board.isValidMove(from, to) && !state.board.isPseudoLegalMove(from, to)) continue+ val after = state.board.movePiece(from, to)+ if (detectCaptureMove(level, after, state.playerColor) != null) {+ hanging = from to to+ break@outer+ }+ }+ }+ val (from, to) = hanging ?: error("protection level should offer a hanging move")+ val piecesBefore = (0..7).sumOf { r -> (0..7).count { c -> vm.uiState.value.board.pieces[r][c] != null } }+ vm.onSquareClick(from)+ vm.onSquareClick(to)+ await("punished") { vm.uiState.value.status == LearnStatus.Failed }+ val piecesAfter = (0..7).sumOf { r -> (0..7).count { c -> vm.uiState.value.board.pieces[r][c] != null } }+ assertEquals(piecesBefore - 1, piecesAfter, "the opponent grabs the hanging piece")+ vm.retryLevel()+ assertEquals(LearnStatus.Playing, vm.uiState.value.status)+ }++ @Test fun learnCheckAndCastleStagesComplete() {+ // Castle stage: play the scripted castling sequence for level 0.+ val vm = LearnViewModel(app)+ vm.loadStage("intermediate", "castling")+ await("castling loaded") { vm.uiState.value.level != null }+ fun move(f1: Char, r1: Int, f2: Char, r2: Int) {+ vm.onSquareClick(sq(f1, r1)); vm.onSquareClick(sq(f2, r2))+ }+ // Level 0 FEN already has Bf1-c4 and Nf3 developed: castle kingside at once if legal.+ val before = vm.uiState.value.board+ if (before.isValidMove(sq('e', 1), sq('g', 1)) || before.isPseudoLegalMove(sq('e', 1), sq('g', 1))) {+ move('e', 1, 'g', 1)+ }+ if (vm.uiState.value.status != LearnStatus.Completed) {+ // Otherwise develop then castle.+ move('e', 2, 'e', 4); move('g', 1, 'f', 3); move('f', 1, 'c', 4); move('e', 1, 'g', 1)+ }+ assertEquals(LearnStatus.Completed, vm.uiState.value.status)+ assertTrue(vm.uiState.value.board.lastMove?.isCastling == true)+ }+}
games/chess/src/test/java/com/vayunmathur/games/chess/util/LearnRulesPass3Test.kt
diff --git a/games/chess/src/test/java/com/vayunmathur/games/chess/util/LearnRulesPass3Test.kt b/games/chess/src/test/java/com/vayunmathur/games/chess/util/LearnRulesPass3Test.ktnew file mode 100644index 0000000000..c33ebc8fe7--- /dev/null+++ b/games/chess/src/test/java/com/vayunmathur/games/chess/util/LearnRulesPass3Test.kt@@ -0,0 +1,157 @@+package com.vayunmathur.games.chess.util++import com.vayunmathur.games.chess.data.Board+import com.vayunmathur.games.chess.data.LearnLevel+import com.vayunmathur.games.chess.data.Piece+import com.vayunmathur.games.chess.data.PieceColor+import com.vayunmathur.games.chess.data.PieceType+import com.vayunmathur.games.chess.data.Position+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertNull+import kotlin.test.assertTrue++/** Pass 3: LearnRules goal/scoring pure functions over hand-built FEN boards. */+class LearnRulesPass3Test {++ private fun level(+ goalType: String,+ fen: String = "8/8/8/8/8/8/8/8 w - - 0 1",+ nbMoves: Int = 1,+ detectCapture: String? = null,+ n: Int? = null,+ failWhite: List<String> = emptyList(),+ failOffPath: List<String> = emptyList(),+ ) = LearnLevel(+ goal = "g", fen = fen, goalType = goalType, nbMoves = nbMoves,+ detectCapture = detectCapture, n = n,+ failIfWhitePawnOn = failWhite, failIfPieceOffPath = failOffPath,+ )++ private fun board(fen: String) = Board.fromFen(fen)++ @Test fun isSuccessPerGoalType() {+ val empty = board("8/8/8/8/8/8/8/8 w - - 0 1")+ assertTrue(isSuccess(level("info"), empty, setOf(Position(0, 0)), PieceColor.WHITE))+ assertTrue(isSuccess(level("apples"), empty, emptySet(), PieceColor.WHITE))+ assertFalse(isSuccess(level("apples"), empty, setOf(Position(1, 1)), PieceColor.WHITE))+ assertTrue(isSuccess(level("unknown-goal"), empty, emptySet(), PieceColor.WHITE))+ assertFalse(isSuccess(level("unknown-goal"), empty, setOf(Position(2, 2)), PieceColor.WHITE))+ // captureAll: no black pieces left.+ val onlyWhite = board("8/8/8/8/8/8/4R3/4K3 w - - 0 1")+ assertTrue(isSuccess(level("captureAll"), onlyWhite, emptySet(), PieceColor.WHITE))+ val withBlack = board("4k3/8/8/8/8/8/4R3/4K3 w - - 0 1")+ assertFalse(isSuccess(level("captureAll"), withBlack, emptySet(), PieceColor.WHITE))+ assertTrue(isSuccess(level("protection"), withBlack, emptySet(), PieceColor.WHITE))+ }++ @Test fun isSuccessCheckEscapeMateCastle() {+ // White queen on h5 checks the black king on e8 along the diagonal? Use a+ // direct rook check instead: rook e1, black king e8.+ val check = board("4k3/8/8/8/8/8/8/4R2K w - - 0 1")+ assertTrue(isSuccess(level("check"), check, emptySet(), PieceColor.WHITE))+ assertTrue(isSuccess(level("checkIn"), check, emptySet(), PieceColor.WHITE))+ assertFalse(isSuccess(level("escapeCheck"), check, emptySet(), PieceColor.BLACK),+ "black king is in check, so black has not escaped")++ val foolsMate = board("rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq - 1 3")+ assertTrue(isSuccess(level("mate"), foolsMate, emptySet(), PieceColor.BLACK),+ "white is checkmated by the black queen")++ var b = Board.initialState+ fun mv(f: String, t: String) {+ b = b.movePiece(+ Position(8 - (f[1] - '0'), f[0] - 'a'),+ Position(8 - (t[1] - '0'), t[0] - 'a'),+ )+ }+ mv("e2", "e4"); mv("e7", "e5"); mv("g1", "f3"); mv("b8", "c6")+ mv("f1", "c4"); mv("f8", "c5"); mv("e1", "g1")+ assertTrue(isSuccess(level("castle"), b, emptySet(), PieceColor.WHITE))+ }++ @Test fun detectCaptureModes() {+ // Black queen d5 can take the white rook d1 (hanging, unprotected).+ // Flip the turn with a distant king move so capture legality is evaluated+ // for Black, as it is right after a real player move.+ val hanging = board("4k3/8/8/3q4/8/8/8/3R3K w - - 0 1")+ .movePiece(Position(7, 7), Position(6, 7))+ assertNull(detectCaptureMove(level("apples", detectCapture = null), hanging, PieceColor.WHITE))+ assertNull(detectCaptureMove(level("info", detectCapture = "all"), hanging, PieceColor.WHITE))+ val anyCapture = detectCaptureMove(level("apples", detectCapture = "all"), hanging, PieceColor.WHITE)+ assertEquals(Position(3, 3) to Position(7, 3), anyCapture)+ val unprotected = detectCaptureMove(level("apples", detectCapture = "unprotected"), hanging, PieceColor.WHITE)+ assertEquals(Position(3, 3) to Position(7, 3), unprotected)+ // Protected rook: white king steps e1->e2, from where it defends d1,+ // so 'unprotected' finds nothing (but 'all' still lists the capture).+ val protected = board("4k3/8/8/3q4/8/8/8/3RK3 w - - 0 1")+ .movePiece(Position(7, 4), Position(6, 4))+ assertNull(detectCaptureMove(level("apples", detectCapture = "unprotected"), protected, PieceColor.WHITE))+ assertNull(detectCaptureMove(level("apples", detectCapture = "bogus"), hanging, PieceColor.WHITE))+ }++ @Test fun failingMovePathAndSingleMoveGoals() {+ val pawnBoard = board("8/8/8/8/8/8/4P3/4K2k w - - 0 1")+ assertTrue(+ isFailingMove(level("apples", failWhite = listOf("e2")), pawnBoard, PieceColor.WHITE, 0),+ "white pawn sitting on a forbidden square fails the path constraint",+ )+ assertFalse(isFailingMove(level("apples"), pawnBoard, PieceColor.WHITE, 0))+ assertTrue(+ isFailingMove(level("apples", failOffPath = listOf("e1")), pawnBoard, PieceColor.WHITE, 0),+ "pieces off the allowed path fail",+ )+ assertFalse(+ isFailingMove(level("apples", failOffPath = listOf("e1", "e2", "h1")), pawnBoard, PieceColor.WHITE, 0),+ )++ val quiet = board("4k3/8/8/8/8/8/8/4R2K w - - 0 1")+ // Rook not giving check from a1-style placement: move rook off the e-file.+ val noCheck = board("4k3/8/8/8/8/8/8/R6K w - - 0 1")+ assertTrue(isFailingMove(level("check"), noCheck, PieceColor.WHITE, 1))+ assertFalse(isFailingMove(level("check"), quiet, PieceColor.WHITE, 1))+ assertTrue(isFailingMove(level("checkIn", n = 2), noCheck, PieceColor.WHITE, 2))+ assertFalse(isFailingMove(level("checkIn", n = 2), noCheck, PieceColor.WHITE, 1),+ "checkIn tolerates misses before the move budget runs out")+ assertTrue(isFailingMove(level("mate"), noCheck, PieceColor.WHITE, 1))+ assertTrue(isFailingMove(level("escapeCheck"), quiet, PieceColor.BLACK, 1),+ "still in check means escape failed")+ }++ @Test fun helpersStarsBonusAndValues() {+ assertTrue(isLastRank(Position(0, 4)))+ assertTrue(isLastRank(Position(7, 4)))+ assertFalse(isLastRank(Position(3, 4)))+ val initial = Board.initialState+ assertEquals(16, countColor(initial, PieceColor.WHITE))+ assertEquals(16, countColor(initial, PieceColor.BLACK))+ assertEquals(16, positionsOf(initial, PieceColor.WHITE).size)+ assertTrue(captures(initial, PieceColor.WHITE).isEmpty(), "no captures in the start position")++ assertEquals(PieceType.QUEEN, promotionFor(Piece(PieceType.PAWN, PieceColor.WHITE), Position(0, 3)))+ assertEquals(PieceType.QUEEN, promotionFor(Piece(PieceType.PAWN, PieceColor.BLACK), Position(7, 3)))+ assertNull(promotionFor(Piece(PieceType.PAWN, PieceColor.WHITE), Position(3, 3)))+ assertNull(promotionFor(Piece(PieceType.ROOK, PieceColor.WHITE), Position(0, 3)))++ assertEquals(PieceColor.BLACK, fenSide("8/8/8/8/8/8/8/8 b - - 0 1"))+ assertEquals(PieceColor.WHITE, fenSide("8/8/8/8/8/8/8/8 w - - 0 1"))+ assertEquals(PieceColor.WHITE, fenSide("garbage"))++ val par4 = level("apples", nbMoves = 4)+ assertEquals(3, starsFor(par4, 4))+ assertEquals(2, starsFor(par4, 5))+ assertEquals(1, starsFor(par4, 9))+ assertEquals(500, levelBonus(3))+ assertEquals(300, levelBonus(2))+ assertEquals(100, levelBonus(1))+ assertEquals(100, levelBonus(0))++ assertEquals(90, pieceValue(PieceType.QUEEN))+ assertEquals(50, pieceValue(PieceType.ROOK))+ assertEquals(30, pieceValue(PieceType.BISHOP))+ assertEquals(30, pieceValue(PieceType.KNIGHT))+ assertEquals(10, pieceValue(PieceType.PAWN))+ assertEquals(0, pieceValue(PieceType.KING))+ }+}