Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more perft tests for Chess960 castles #352

Merged
merged 2 commits into from
Jan 20, 2023

Conversation

lenguyenthanh
Copy link
Member

@lenguyenthanh lenguyenthanh commented Jan 20, 2023

@lenguyenthanh
Copy link
Member Author

lenguyenthanh commented Jan 20, 2023

script to convert pert files using scala-cli.
It looks pretty nice, so I post it here 😆

//> using scala "3.2.1"
//> using lib "co.fs2::fs2-core:3.5.0"
//> using lib "co.fs2::fs2-io:3.5.0"
//> using lib "org.typelevel::cats-effect:3.4.5"

import cats.effect.{IO, IOApp}
import fs2.{Stream, text}
import fs2.io.file.{Files, Path}

object Converter extends IOApp.Simple:

  val converter: Stream[IO, Unit] =
    def raw2Perft(id: Long, raw: String): String =
      val builder = StringBuilder(s"id $id\n")
      val list = raw.split(";").toList
      builder.append(s"epd ${list(0)}\n")
      for(i <- 1 to 6) {
        val size = list(i).split(" ")(1)
        builder.append(s"perft $i $size\n")
      }
      builder.toString

    Files[IO].readUtf8Lines(Path("raw.txt"))
      .filter(s => !s.trim.isEmpty)
      .zipWithIndex
      .map((x, i) => raw2Perft(i, x))
      .intersperse("\n")
      .through(text.utf8.encode)
      .through(Files[IO].writeAll(Path("chess960.perft")))

  def run: IO[Unit] =
    converter.compile.drain

@lenguyenthanh lenguyenthanh merged commit 09db568 into lichess-org:master Jan 20, 2023
@niklasf
Copy link
Member

niklasf commented Jan 20, 2023

Nice. Adding these to shakmaty, too ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants