4

GitHub - ColonelParrot/jchessify: Java chess engine framework.

 1 year ago
source link: https://github.com/ColonelParrot/jchessify
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

logo.png

Java chess engine framework

jChessify makes writing chess engines in Java fun.
It lets you focus on the high-level functionality whilst giving you unparalleled flexibility.

  • minimax
  • alpha-beta pruning
  • opening book support

Basic Chess Engine

Board chessBoard = new Board();
chessBoard.loadFromFen("f/e/n");

Engine engine = new Engine(new PieceValueEvaluator());
engine.maxDepth = 2;
Move bestMove = engine.getBestMove(chessBoard);

Note: chess logic (Board, Move) is powered by bhlangonijr/chesslib

This example uses PieceValueEvaluator, an evaluator which evaluates player advantage through piece values.

Custom Evaluation

class CustomEvaluator implements Evaluator {
    // positive if advantage, negative if disadvantage
    public int evaluate(Board board){
        // random value between -100 and 100
        return new Random().nextInt(201) - 100;
    }
}
Engine engine = new Engine(new CustomEvaluator());

Opening Book

OpeningBook openingBook = new OpeningBook("path/to/book.txt");
String bestMoveSAN = openingBook.findNextMove("e4 e5"); //Nf3
chessBoard.doMove(bestMoveSAN);

Note: jChessify's OpeningBook uses a specific format. The default opening book provided should be enough.

Installation

You can install jChessify through Apache Maven. Add the following to your pom.xml:

<dependency>
  <groupId>io.github.colonelparrot</groupId>
  <artifactId>jchessify</artifactId>
  <version>1.0.2</version>
</dependency>

Installation instructions for Gradle and others can be found here.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK