dartchess 0.6.1 copy "dartchess: ^0.6.1" to clipboard
dartchess: ^0.6.1 copied to clipboard

Provides chess and chess variants rules and operations including chess move generation, read and write FEN, read and write PGN.

example/dartchess_example.dart

import 'package:dartchess/dartchess.dart';

void main() {
  // Parse fen and create a valid chess position
  final setup = Setup.parseFen(
      'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
  final pos = Chess.fromSetup(setup);

  // Generate legal moves in algebraic notation
  final legalMoves = algebraicLegalMoves(pos);

  assert(legalMoves['e2']!.length == 2);

  const move = NormalMove(from: 12, to: 28);

  assert(pos.isLegal(move));

  // Play moves
  final pos2 = pos.play(move);

  // Detect game end conditions
  assert(pos2.isGameOver == false);
  assert(pos2.isCheckmate == false);
  assert(pos2.outcome == null);
  assert(pos2.isInsufficientMaterial == false);
}
9
likes
0
points
639
downloads

Publisher

verified publisherlichess.org

Weekly Downloads

Provides chess and chess variants rules and operations including chess move generation, read and write FEN, read and write PGN.

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

lichess.org

License

unknown (license)

Dependencies

fast_immutable_collections, meta

More

Packages that depend on dartchess