Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.71 KB

README.md

File metadata and controls

66 lines (46 loc) · 1.71 KB

JChess

Build Status Coverage Status Jitpack

JChess is a pure Java chess library.

API

The public API of the latest release is available here.

Examples

/* 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())));
}

Currently Implemented

  • Board and game representation.
  • Magic bitboards.
  • Move generation.
  • Moves in standard algebraic notation (SAN).

Feature Wishlist

  • Scalable PGN reader/writer.
  • UCI engine interface.
  • Chess game analysis.
  • Chess problem extractor.

Installation

All release versions and latest snapshots are hosted by JitPack.

Acknowledgments

  • Board representation inspired by lc0.