chess 0.6.5

  • README.md
  • Installing
  • Versions
  • 71

chess.dart

chess.dart is a library for legal chess move generation, maintenance of chess game state, and conversion to and from the formats FEN and PGN. It has no external dependencies.

It is a port of chess.js to Dart. It aims to include all of the functionality in the original library, while making the API a little bit more Dart-like. In limited testing, the Dart version (after some refactoring) now outperforms the JavaScript original.

At this early stage, it is working, and passes all of the unit tests which come with chess.js (which you can find in the test directory). However, beyond this, it is not tested in production.

A Random Game

import "package:chess/chess.dart";

void main() {
  Chess chess = new Chess();
  while (!chess.game_over) {
    print('position: ' + chess.fen);
    print(chess.ascii);
    var moves = chess.moves();
    moves.shuffle();
    var move = moves[0];
    chess.move(move);
    print('move: ' + move);
  }
}

Documentation

The chess.js documentation is largely relevant, but there are also DartDocs generated within the lib/docs directory. The only change in naming from chess.js, is that history() has been changed to getHistory() due to a conflict with the history ivar and some methods have been changed into properties.

The test directory contains tests.dart which is a port of chess.js's unit tests. The program random.dart plays a random game of chess. ai.dart is an example of a simple 4 ply alpha beta search for black (yes a simple chess-playing program) that uses a purely material evaluation function (it is rather slow).

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  chess: ^0.6.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:chess/chess.dart';
  
Version Uploaded Documentation Archive
0.6.5 Sep 3, 2018 Go to the documentation of chess 0.6.5 Download chess 0.6.5 archive
0.6.4 Feb 7, 2018 Go to the documentation of chess 0.6.4 Download chess 0.6.4 archive
0.6.3 Sep 7, 2017 Go to the documentation of chess 0.6.3 Download chess 0.6.3 archive
0.6.2 Jul 23, 2014 Go to the documentation of chess 0.6.2 Download chess 0.6.2 archive
0.6.1 Jul 6, 2014 Go to the documentation of chess 0.6.1 Download chess 0.6.1 archive
0.6.0 Apr 12, 2014 Go to the documentation of chess 0.6.0 Download chess 0.6.0 archive
0.5.1 Feb 7, 2014 Go to the documentation of chess 0.5.1 Download chess 0.5.1 archive
0.5.0 Feb 1, 2014 Go to the documentation of chess 0.5.0 Download chess 0.5.0 archive
0.0.2 Jan 31, 2014 Go to the documentation of chess 0.0.2 Download chess 0.0.2 archive
0.0.1 Jan 31, 2014 Go to the documentation of chess 0.0.1 Download chess 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
56
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:chess/chess.dart.

Health suggestions

Fix lib/chess.dart. (-2.96 points)

Analysis of lib/chess.dart reported 6 hints, including:

line 211 col 12: The value of the local variable 'valid' isn't used.

line 293 col 37: 'onError' is deprecated and shouldn't be used.

line 311 col 33: 'onError' is deprecated and shouldn't be used.

line 376 col 43: 'onError' is deprecated and shouldn't be used.

line 1599 col 11: Always override hashCode if overriding ==.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use chess.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
benchmark_harness >=1.0.0 <1.1.0
test >=1.2.0 <2.0.0