Rename isChess960 to includeAlternateCastlingMoves

This commit is contained in:
Vincent Velociter
2025-03-31 10:28:37 +02:00
parent a38a35d414
commit 3bb93ad3c2
4 changed files with 11 additions and 5 deletions
+6
View File
@@ -1,3 +1,9 @@
## 0.11.0
- Rename `makeLegalMove` parameter `isChess960` to
`includeAlternateCastlingMoves` and invert its meaning. It now defaults to
`false`.
## 0.10.0
- Remove the type parameter from `Position` class.
+3 -3
View File
@@ -5,10 +5,10 @@ import 'position.dart';
/// Returns all the legal moves of the [Position] in a convenient format.
///
/// Includes both possible representations of castling moves (unless `chess960` is true).
/// Includes both possible representations of castling moves unless `includeAlternateCastlingMoves` is false.
IMap<Square, ISet<Square>> makeLegalMoves(
Position pos, {
bool isChess960 = false,
bool includeAlternateCastlingMoves = true,
}) {
final Map<Square, ISet<Square>> result = {};
for (final entry in pos.legalMoves.entries) {
@@ -16,7 +16,7 @@ IMap<Square, ISet<Square>> makeLegalMoves(
if (dests.isNotEmpty) {
final from = entry.key;
final destSet = dests.toSet();
if (!isChess960 &&
if (includeAlternateCastlingMoves &&
from == pos.board.kingOf(pos.turn) &&
entry.key.file == 4) {
if (dests.contains(Square.a1)) {
+1 -1
View File
@@ -1,7 +1,7 @@
name: dartchess
description: Provides chess and chess variants rules and operations including chess move generation, read and write FEN, read and write PGN.
repository: https://github.com/lichess-org/dartchess
version: 0.10.0
version: 0.11.0
platforms:
android:
ios:
+1 -1
View File
@@ -60,7 +60,7 @@ void main() {
),
);
expect(
makeLegalMoves(pos, isChess960: true)[Square.b8],
makeLegalMoves(pos, includeAlternateCastlingMoves: false)[Square.b8],
equals(ISet(const {Square.a8, Square.c8, Square.e8})),
);
});