JChess is a pure Java chess library.
The public API of the latest release is available here.
/* EXAMPLE 1 */
// Play a game from a given position (as FEN string).
Game game = new Game("8/8/8/8/8/p7/2K1N3/k7 w - -");
// Play some moves.
game.playMoves("Nc1", "a2", "Nb3#");
// Print the resulting FEN string.
System.out.println(game.getCurrentPosition().getFen());
// Prints "8/8/8/8/8/1N6/p1K5/k b - - 1 1".
/* EXAMPLE 2 */
// Play a random game from the starting position.
Game game = new Game();
while(true)
{
List<Move> moves = game.getLegalMoves();
if(moves.isEmpty() || game.isThreefoldRepetition())
{
break;
}
game.playMoves(moves.get(new Random().nextInt(moves.size())));
}
- Board and game representation.
- Magic bitboards.
- Move generation.
- Moves in standard algebraic notation (SAN).
- Scalable PGN reader/writer.
- UCI engine interface.
- Chess game analysis.
- Chess problem extractor.
All release versions and latest snapshots are hosted by JitPack.
- Board representation inspired by lc0.