Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lazy val app = project
"org.reactivemongo" %% "reactivemongo" % "1.1.0-RC15",
"org.reactivemongo" %% "reactivemongo-akkastream" % "1.1.0-RC15",
"com.github.lichess-org.scalalib" %% "scalalib-core" % "11.10.11",
"com.github.lichess-org.scalachess" %% "scalachess" % "17.16.1",
"com.github.lichess-org.scalachess" %% "scalachess" % "18.0.0",
"com.typesafe.akka" %% "akka-actor" % "2.6.21",
"com.typesafe.akka" %% "akka-stream" % "2.6.21",
"com.typesafe.akka" %% "akka-slf4j" % "2.6.21",
Expand Down
18 changes: 13 additions & 5 deletions src/main/scala/lila/analyse/Info.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,24 @@ object Info:

def start(ply: Int) = Info(ply, Eval.initial, Nil)

private def strCp(s: String) = s.toIntOption.map(Cp.apply)
private def strMate(s: String) = s.toIntOption.map(Mate.apply)
private def strCp(s: String) = s.toIntOption.map(Cp.apply)

// keep mate in +/-0 only when it has the standard meaning
// (side to move is mated), like WhiteScore.exportMate
private def strMate(s: String, ply: Int): Option[Mate] =
val whiteToMove = ply % 2 == 0
s match
case "+0" => Option.when(!whiteToMove)(Mate(0))
case "-0" | "0" => Option.when(whiteToMove)(Mate(0))
case _ => s.toIntOption.map(Mate.apply)

private def decode(ply: Int, str: String): Option[Info] = str.split(separator) match
case Array() => Some(Info(ply, Eval.empty))
case Array(cp) => Some(Info(ply, Eval(strCp(cp), None, None)))
case Array(cp, ma) => Some(Info(ply, Eval(strCp(cp), strMate(ma), None)))
case Array(cp, ma, va) => Some(Info(ply, Eval(strCp(cp), strMate(ma), None), va.split(' ').toList))
case Array(cp, ma) => Some(Info(ply, Eval(strCp(cp), strMate(ma, ply), None)))
case Array(cp, ma, va) => Some(Info(ply, Eval(strCp(cp), strMate(ma, ply), None), va.split(' ').toList))
case Array(cp, ma, va, be) =>
Some(Info(ply, Eval(strCp(cp), strMate(ma), Uci.Move.fromChars(be)), va.split(' ').toList))
Some(Info(ply, Eval(strCp(cp), strMate(ma, ply), Uci.Move.fromChars(be)), va.split(' ').toList))
case _ => None

def decodeList(str: String, fromPly: Int): Option[List[Info]] = {
Expand Down
Loading