diff --git a/test-kit/src/test/scala/perft/FullPerftTest.scala b/test-kit/src/test/scala/perft/FullPerftTest.scala deleted file mode 100644 index 1eb450827..000000000 --- a/test-kit/src/test/scala/perft/FullPerftTest.scala +++ /dev/null @@ -1,62 +0,0 @@ -package chess -package perft - -// import cats.syntax.all.* -import weaver.* - -// import chess.variant.* -// import cats.effect.IO -import cats.kernel.Monoid - -object FullPerftTest extends SimpleIOSuite: - - given Monoid[Boolean] with - def empty = true - def combine(x: Boolean, y: Boolean) = x && y - - val nodeLimits = 1_000L - - // test("random.perft"): - // perfts(Perft.randomPerfts, Chess960, 10_000L) - // .map(assert(_)) - // - // test("threeCheck.perft"): - // perfts(Perft.threeCheckPerfts, ThreeCheck, nodeLimits) - // .map(assert(_)) - // - // test("antichess.perft"): - // perfts(Perft.antichessPerfts, Antichess, nodeLimits) - // .map(assert(_)) - // - // test("atomic.perft"): - // perfts(Perft.atomicPerfts, Atomic, nodeLimits) - // .map(assert(_)) - // - // test("crazyhouse.perft"): - // perfts(Perft.crazyhousePerfts, Crazyhouse, nodeLimits) - // .map(assert(_)) - // - // test("horde.perft"): - // perfts(Perft.hordePerfts, Horde, nodeLimits) - // .map(assert(_)) - // - // test("racingkings.perft"): - // perfts(Perft.racingkingsPerfts, RacingKings, nodeLimits) - // .map(assert(_)) - // - // test("tricky.perft"): - // perfts(Perft.trickyPerfts, Chess960, nodeLimits) - // .map(assert(_)) - // - // test("chess960.perft"): - // perfts(Perft.chess960, Chess960, nodeLimits) - // .map(assert(_)) - // - // private def perfts(perfts: List[Perft], variant: Variant, nodeLimit: Long): IO[Boolean] = - // perfts.parFoldMapA(perft => IO(perftTest(perft, variant, nodeLimit))) - // - // private def perftTest(perft: Perft, variant: Variant, nodeLimit: Long): Boolean = - // perft - // .withLimit(nodeLimit) - // .calculate(variant) - // .forall(r => r.result === r.expected) diff --git a/test-kit/src/test/scala/perft/PerftTest.scala b/test-kit/src/test/scala/perft/PerftTest.scala index cea34cf79..b36f3ce3a 100644 --- a/test-kit/src/test/scala/perft/PerftTest.scala +++ b/test-kit/src/test/scala/perft/PerftTest.scala @@ -1,27 +1,62 @@ package chess package perft +import cats.syntax.all.* +import weaver.* + import chess.variant.* +import cats.effect.IO +import cats.kernel.Monoid + +object PerftTest extends SimpleIOSuite: + + given Monoid[Boolean] with + def empty = true + def combine(x: Boolean, y: Boolean) = x && y + + val nodeLimits = 1_000L + + test("random.perft"): + perfts(Perft.randomPerfts, Chess960, 10_000L) + .map(assert(_)) + + test("threeCheck.perft"): + perfts(Perft.threeCheckPerfts, ThreeCheck, nodeLimits) + .map(assert(_)) + + test("antichess.perft"): + perfts(Perft.antichessPerfts, Antichess, nodeLimits) + .map(assert(_)) + + test("atomic.perft"): + perfts(Perft.atomicPerfts, Atomic, nodeLimits) + .map(assert(_)) + + test("crazyhouse.perft"): + perfts(Perft.crazyhousePerfts, Crazyhouse, nodeLimits) + .map(assert(_)) + + test("horde.perft"): + perfts(Perft.hordePerfts, Horde, nodeLimits) + .map(assert(_)) + + test("racingkings.perft"): + perfts(Perft.racingkingsPerfts, RacingKings, nodeLimits) + .map(assert(_)) + + test("tricky.perft"): + perfts(Perft.trickyPerfts, Chess960, nodeLimits) + .map(assert(_)) + + test("chess960.perft"): + perfts(Perft.chess960, Chess960, nodeLimits) + .map(assert(_)) + + private def perfts(perfts: List[Perft], variant: Variant, nodeLimit: Long): IO[Boolean] = + perfts.parFoldMapA(perft => IO(perftTest(perft, variant, nodeLimit))) -class PerftTest extends ChessTest: - - private def genTests(name: String, tests: List[Perft], variant: Variant, nodeLimit: Long)(using - munit.Location - ) = - tests.foreach: perft => - val result = perft.withLimit(nodeLimit).calculate(variant) - result.foreach: r => - test(s"$name ${perft.id} depth: ${r.depth}"): - assertEquals(r.result, r.expected) - - val nodeLimits = 1_000_000L - genTests("calculate ThreeCheck perfts", Perft.threeCheckPerfts, ThreeCheck, nodeLimits) - genTests("calculate Antichess perfts", Perft.antichessPerfts, Antichess, nodeLimits) - genTests("calculate Atomic perfts", Perft.atomicPerfts, Atomic, nodeLimits) - genTests("calculate Crazyhouse perfts", Perft.crazyhousePerfts, Crazyhouse, nodeLimits) - genTests("calculate Horde perfts", Perft.hordePerfts, Horde, nodeLimits) - genTests("calculate RacingKings perfts", Perft.racingkingsPerfts, RacingKings, nodeLimits) - // for the shake of time we only test the first 50 cases in random.peft, run FullRandomPerftTest.scala for all cases - genTests("calculate random perfts", Perft.randomPerfts.take(100), Chess960, nodeLimits) - genTests("calculate tricky perfts", Perft.trickyPerfts, Chess960, nodeLimits) - genTests("calculate chess960 perfts", Perft.chess960, Chess960, nodeLimits) + private def perftTest(perft: Perft, variant: Variant, nodeLimit: Long): Boolean = + perft + .withLimit(nodeLimit) + .calculate(variant) + .forall(r => r.result === r.expected)