Skip to content

Commit e5f54a4

Browse files
feat: 3fold, improve codestyle
- trigger draw by 3fold repetition - delegate to Move.finalizeAfter all the work except the pieceMap update which remain in Variant.boardAfter - improve Situation.piecesAfterAction codestyle - Replay.replayMove now works - remove notion of promotion - add more unit tests
1 parent 6b42fcb commit e5f54a4

24 files changed

+474
-5966
lines changed

src/main/scala/Game.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ object Game {
12371237
partialCaptures: Boolean = false
12381238
): Validated[String, (Game, Move)] = (orig, dest) match {
12391239
case (Pos.Abalone(orig), Pos.Abalone(dest)) =>
1240-
g.apply(orig, dest, None, metrics)
1240+
g.apply(orig, dest)
12411241
.toEither
12421242
.map(t => (Abalone(t._1), Move.Abalone(t._2)))
12431243
.toValidated

src/main/scala/Situation.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ object Situation {
12871287
partialCaptures: Boolean = false
12881288
): Validated[String, Move] = (from, to) match {
12891289
case (Pos.Abalone(from), Pos.Abalone(to)) =>
1290-
s.move(from, to, promotion.map(_.toAbalone)).toEither.map(m => Move.Abalone(m)).toValidated
1290+
s.move(from, to).toEither.map(m => Move.Abalone(m)).toValidated
12911291
case _ => sys.error("Not passed Abalone objects")
12921292
}
12931293

src/main/scala/abalone/Board.scala

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ case class Board(
3535

3636
def materialImbalance: Int = variant.materialImbalance(this)
3737

38+
def autoDraw: Boolean = history.threefoldRepetition && variant.repetitionEnabled
39+
3840
override def toString = s"$variant Position after ${history.recentTurnUciString}"
3941

4042
lazy val actors: Map[Pos, Actor] = pieces.map {

src/main/scala/abalone/Game.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ case class Game(
1717
def apply(
1818
orig: Pos,
1919
dest: Pos,
20-
promotion: Option[PromotableRole] = None,
2120
metrics: MoveMetrics = MoveMetrics()
2221
): Validated[String, (Game, Move)] =
23-
situation.move(orig, dest, promotion).map(_ withMetrics metrics) map { move =>
22+
situation.move(orig, dest).map(_ withMetrics metrics) map { move =>
2423
apply(move) -> move
2524
}
2625

@@ -38,7 +37,7 @@ case class Game(
3837
}
3938

4039
def apply(uci: Uci.Move): Validated[String, (Game, Move)] =
41-
apply(uci.orig, uci.dest, uci.promotion)
40+
apply(uci.orig, uci.dest)
4241

4342
private def applyClock(metrics: MoveMetrics, gameActive: Boolean, switchClock: Boolean) =
4443
clock.map { c =>

0 commit comments

Comments
 (0)