feat: Refactor promotion handling to use UCI notation and improve move validation
Build & Test (NowChessSystems) TeamCity build failed
Build & Test (NowChessSystems) TeamCity build failed
This commit is contained in:
@@ -455,13 +455,21 @@ object DefaultRules extends RuleSet:
|
||||
|
||||
// ── Insufficient material ──────────────────────────────────────────
|
||||
|
||||
private def squareColor(sq: Square): Int = (sq.file.ordinal + sq.rank.ordinal) % 2
|
||||
|
||||
private def insufficientMaterial(board: Board): Boolean =
|
||||
val pieces = board.pieces.values.toList.filter(_.pieceType != PieceType.King)
|
||||
pieces match
|
||||
case Nil => true
|
||||
case List(p) if p.pieceType == PieceType.Bishop || p.pieceType == PieceType.Knight => true
|
||||
case List(p1, p2)
|
||||
val nonKings = board.pieces.toList.filter(_._2.pieceType != PieceType.King)
|
||||
nonKings match
|
||||
case Nil => true
|
||||
case List((_, p)) if p.pieceType == PieceType.Bishop || p.pieceType == PieceType.Knight => true
|
||||
case List((sq1, p1), (sq2, p2))
|
||||
if p1.pieceType == PieceType.Bishop && p2.pieceType == PieceType.Bishop
|
||||
&& p1.color != p2.color =>
|
||||
&& p1.color != p2.color
|
||||
&& squareColor(sq1) == squareColor(sq2) =>
|
||||
true
|
||||
case bishops
|
||||
if bishops.forall(_._2.pieceType == PieceType.Bishop)
|
||||
&& bishops.map(_._2.color).distinct.size == 1
|
||||
&& bishops.map(e => squareColor(e._1)).distinct.size == 1 =>
|
||||
true
|
||||
case _ => false
|
||||
|
||||
Reference in New Issue
Block a user