Skip to content

Commit 98936cf

Browse files
author
Matt Tucker
committed
Fix isometric tests for Backgammon
1 parent 45f0f12 commit 98936cf

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

src/main/scala/backgammon/format/FEN.scala

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ final case class FEN(value: String) extends AnyVal {
6060
}
6161
.toMap
6262

63+
def unusedDice: List[Int] = value.split(' ')(1).split('/').flatMap(_.toIntOption).toList
64+
65+
def usedDice: List[Int] = value.split(' ')(2).split('/').flatMap(_.toIntOption).toList
66+
6367
def pocketData: Option[PocketData] = {
6468
val start = value.indexOf("[", 0)
6569
val end = value.indexOf("]", start)

src/main/scala/backgammon/format/Forsyth.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ object Forsyth {
1919
Board(
2020
pieces = fen.pieces,
2121
history = History(),
22-
variant = variant
22+
variant = variant,
23+
pocketData = fen.pocketData,
24+
unusedDice = fen.unusedDice
2325
),
2426
fen.value.split(' ')(3) match {
2527
case "w" => P1
@@ -28,6 +30,9 @@ object Forsyth {
2830
}
2931
).withHistory(
3032
History(
33+
currentTurn = List((fen.unusedDice ++ fen.usedDice).take(2))
34+
.filter(_.nonEmpty)
35+
.map(Uci.DiceRoll(_)),
3136
score = Score(fen.player1Score, fen.player2Score),
3237
// seems like we might be using History.halfMoveClock incorrectly
3338
halfMoveClock = fen.fullMove.getOrElse(0)

src/test/scala/backgammon/BackgammonVariantTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5095,7 +5095,7 @@ class BackgammonVariantTestIsometry extends strategygames.chess.ChessTest {
50955095
)
50965096

50975097
val bgGameP1StartsActionStrs = Vector(
5098-
Vector("2/3", "13/10", "13/11", "endturn"),
5098+
Vector("2/3", "l2i2", "g1i1", "endturn"),
50995099
Vector("3/1")
51005100
)
51015101

src/test/scala/chess/ChessTest.scala

+4-5
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ trait ChessTest extends Specification with ValidatedMatchers {
215215
// TODO: add in end game conditions, etc.
216216
}
217217

218-
def turnsAndPliesAreEqual(g1: StratGame, gameData: GameFenIsometryData) = {
219-
gameData.plies must_== g1.plies
218+
def turnsAreEqual(g1: StratGame, gameData: GameFenIsometryData) = {
220219
gameData.turnCount must_== g1.turnCount
221220
}
222221

@@ -239,9 +238,9 @@ trait ChessTest extends Specification with ValidatedMatchers {
239238
newFenGame2 <- stratFenToGame(lib, fen1, v)
240239
} yield {
241240
val newGameData = gameData.nextPly(newBaseGame, newFenGame)
242-
turnsAndPliesAreEqual(newBaseGame, newGameData)
243-
turnsAndPliesAreEqual(newFenGame, newGameData)
244-
turnsAndPliesAreEqual(newFenGame2, newGameData)
241+
turnsAreEqual(newBaseGame, newGameData)
242+
turnsAreEqual(newFenGame, newGameData)
243+
turnsAreEqual(newFenGame2, newGameData)
245244
gamesAreEqual(lib, newBaseGame, newFenGame)
246245
gamesAreEqual(lib, newBaseGame, newFenGame2)
247246
gamesAreEqual(lib, newFenGame, newFenGame2)

0 commit comments

Comments
 (0)