Skip to content

Commit 92e8b7f

Browse files
authored
Merge pull request #75 from lenguyenthanh/scalachess/17.8.3
Update scalachess 17.8.3
2 parents 6a57473 + 063bd05 commit 92e8b7f

7 files changed

Lines changed: 42 additions & 35 deletions

File tree

build.sbt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ lazy val app = project
2020
"-Wunused:all",
2121
"-release:21"
2222
),
23-
resolvers ++= Seq("lila-maven".at("https://raw.githubusercontent.com/lichess-org/lila-maven/master")),
23+
resolvers ++= Seq(
24+
"lila-maven".at("https://raw.githubusercontent.com/lichess-org/lila-maven/master"),
25+
"jitpack".at("https://jitpack.io")
26+
),
27+
resolvers += Resolver.sonatypeRepo("public"),
2428
libraryDependencies ++= Seq(
25-
"org.reactivemongo" %% "reactivemongo" % "1.1.0-RC15",
26-
"org.reactivemongo" %% "reactivemongo-akkastream" % "1.1.0-RC15",
27-
"org.lichess" %% "scalalib-core" % "11.7.0",
28-
"org.lichess" %% "scalachess" % "17.5.0",
29-
"com.typesafe.akka" %% "akka-actor" % "2.6.21",
30-
"com.typesafe.akka" %% "akka-stream" % "2.6.21",
31-
"com.typesafe.akka" %% "akka-slf4j" % "2.6.21",
32-
"org.playframework" %% "play-json" % "3.0.4",
33-
"org.lichess" %% "compression" % "3.0",
34-
"org.slf4j" % "slf4j-nop" % "1.7.36"
29+
"org.reactivemongo" %% "reactivemongo" % "1.1.0-RC15",
30+
"org.reactivemongo" %% "reactivemongo-akkastream" % "1.1.0-RC15",
31+
"org.lichess" %% "scalalib-core" % "11.7.0",
32+
"com.github.lichess-org.scalachess" %% "scalachess" % "17.8.3",
33+
"com.typesafe.akka" %% "akka-actor" % "2.6.21",
34+
"com.typesafe.akka" %% "akka-stream" % "2.6.21",
35+
"com.typesafe.akka" %% "akka-slf4j" % "2.6.21",
36+
"org.playframework" %% "play-json" % "3.0.4",
37+
"org.lichess" %% "compression" % "3.0",
38+
"org.slf4j" % "slf4j-nop" % "1.7.36"
3539
// "ch.qos.logback" % "logback-classic" % "1.4.14"
3640
)
3741
)

src/main/scala/Evals.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ object Evals:
124124
err = Cursor.ContOnError((_, e) => println(e.getMessage))
125125
)
126126
.buffer(1000, OverflowStrategy.backpressure)
127-
.filter(_._id.position.read.board.variant.standard)
127+
.filter(_._id.position.read.position.variant.standard)
128128
.via(toJson)
129129
.runWith(ndjsonSink)
130130
}

src/main/scala/lila/game/BSONHandlers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import chess.{
1010
Game as ChessGame,
1111
HalfMoveClock,
1212
History as ChessHistory,
13-
Mode,
13+
Rated,
1414
Ply,
1515
Status,
1616
UnmovedRooks
@@ -114,7 +114,7 @@ object BSONHandlers:
114114
)
115115

116116
val chessGame = ChessGame(
117-
board = chess.Position(
117+
position = chess.Position(
118118
board = decoded.board,
119119
history = ChessHistory(
120120
lastMove = decoded.lastMove,
@@ -158,7 +158,7 @@ object BSONHandlers:
158158
status = light.status,
159159
daysPerTurn = r.getO[Int](F.daysPerTurn),
160160
binaryMoveTimes = r.bytesO(F.moveTimes),
161-
mode = Mode(r.boolD(F.rated)),
161+
rated = Rated(r.boolD(F.rated)),
162162
createdAt = createdAt,
163163
movedAt = r.dateD(F.movedAt, createdAt),
164164
metadata = Metadata(

src/main/scala/lila/game/BinaryFormat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ object BinaryFormat:
221221
.to(Map)
222222

223223
// cache standard start position
224-
val standard = write(Position.init(chess.variant.Standard, White).pieces)
224+
val standard = write(chess.variant.Standard.initialPieces)
225225

226226
private def intToRole(int: Int, variant: Variant): Option[Role] =
227227
int match

src/main/scala/lila/game/Game.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import chess.format.{ Fen, Uci }
99
import chess.opening.{ Opening, OpeningDb }
1010
import chess.variant.Variant
1111
import chess.format.pgn.SanStr
12-
import chess.{ ByColor, Castles, Centis, CheckCount, Clock, Color, Game as ChessGame, Mode, Status }
12+
import chess.{ ByColor, Castles, Centis, CheckCount, Clock, Color, Game as ChessGame, Rated, Status }
1313

1414
import lila.common.Sequence
1515
import lila.db.ByteArray
@@ -22,13 +22,13 @@ case class Game(
2222
daysPerTurn: Option[Int],
2323
binaryMoveTimes: Option[ByteArray] = None,
2424
clockHistory: Option[ClockHistory] = Option(ClockHistory()),
25-
mode: Mode = Mode.default,
25+
rated: Rated = Rated.default,
2626
createdAt: Instant,
2727
movedAt: Instant,
2828
metadata: Metadata
2929
):
30-
export chess.{ clock, player as turnColor, ply, sans, board, startedAtPly }
31-
export chess.board.{ history, variant }
30+
export chess.{ clock, player as turnColor, ply, sans, position, startedAtPly }
31+
export chess.position.{ history, variant }
3232

3333
def player: Player = players(turnColor)
3434

@@ -147,10 +147,7 @@ case class Game(
147147

148148
def aiPov: Option[Pov] = players.find(_.isAi).map(_.color).map(pov)
149149

150-
def boosted = rated && finished && bothPlayersHaveMoved && playedTurns < 10
151-
152-
def rated = mode.rated
153-
def casual = !rated
150+
def boosted = rated.yes && finished && bothPlayersHaveMoved && playedTurns < 10
154151

155152
def finished = status >= Status.Mate
156153

@@ -197,7 +194,7 @@ case class Game(
197194
def startColor = startedAtPly.turn
198195

199196
def ratingVariant =
200-
if isTournament && board.variant.fromPosition then _root_.chess.variant.Standard
197+
if isTournament && position.variant.fromPosition then _root_.chess.variant.Standard
201198
else variant
202199

203200
def fromPosition = variant.fromPosition || source.contains(Source.Position)

src/main/scala/lila/game/PgnDump.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ object PgnDump:
3333
val player = g.players(color)
3434
player.aiLevel.fold(users(color).name)("lichess AI level " + _)
3535

36+
private def modeName(g: Game) = if g.rated.yes then "Rated" else "Casual"
37+
3638
private def eventOf(game: Game) =
3739
val perf = game.perfType.fold("Standard")(_.name)
3840
game.tournamentId
3941
.map { id =>
40-
s"${game.mode} $perf tournament https://lichess.org/tournament/$id"
42+
s"${modeName(game)} $perf tournament https://lichess.org/tournament/$id"
4143
}
4244
.orElse(game.simulId.map { id =>
4345
s"$perf simul https://lichess.org/simul/$id"
@@ -46,7 +48,7 @@ object PgnDump:
4648
s"$perf swiss https://lichess.org/swiss/$id"
4749
})
4850
.getOrElse {
49-
s"${game.mode} $perf game"
51+
s"${modeName(game)} $perf game"
5052
}
5153

5254
private def ratingDiffTag(p: Player, tag: Tag.type => TagType) =

src/main/scala/lila/game/PgnStorage.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ private object PgnStorage:
4747
private def chessBoard(b: JavaBoard): Board =
4848
Board(
4949
occupied = Bitboard(b.occupied),
50-
white = Bitboard(b.white),
51-
black = Bitboard(b.black),
52-
pawns = Bitboard(b.pawns),
53-
knights = Bitboard(b.knights),
54-
bishops = Bitboard(b.bishops),
55-
rooks = Bitboard(b.rooks),
56-
queens = Bitboard(b.queens),
57-
kings = Bitboard(b.kings)
50+
ByColor(
51+
white = Bitboard(b.white),
52+
black = Bitboard(b.black)
53+
),
54+
ByRole(
55+
pawn = Bitboard(b.pawns),
56+
knight = Bitboard(b.knights),
57+
bishop = Bitboard(b.bishops),
58+
rook = Bitboard(b.rooks),
59+
queen = Bitboard(b.queens),
60+
king = Bitboard(b.kings)
61+
)
5862
)
5963

6064
case class Decoded(

0 commit comments

Comments
 (0)