To use rcSigma
as a JavaScript chess library, It MUST be built and configure to point to one of the engines. As at now, only raccoon
engine is supported.
Please see Getting Started Guide
The code below will randomely plays a complete game of chess.
let { Raccoon } = require("./raccoon.api.js");
let raccoon = new Raccoon();
while (!raccoon.gameOver()) {
let moves = raccoon.moves();
let move = moves[Math.floor(Math.random() * moves.length)];
raccoon.move(move);
console.log(raccoon.ascii());
}
See Chess Library for more APIs
Although it is optional, RaccoonChessSigma can be configured with the following object:
config = {
evaluateFN: "raccoonEvaluate" /* Default */,
startFEN:
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" /* Default */,
bookFile: "pathTochess_book/<book_name>.bin",
nnue_file: "pathTonnue_file/<book_name>.nnue",
};
evaluateFN
: is the evaluation function that will be used while searching for best move. The other choice is"raccoonZeroEvaluate"
. If this is specified, you MUST also providennue_file
. See README for more informationstartFEN
: is the the board configuration in Forsyth-Edwards Notationbook_path
: is the path to a chess book. If not provided, engine calculates opening moves instead of playing book moves.nnue_file
: is the path to the the NNUE evaluation parameters(for instance,nn-c157e0a5755b.nnue
). ONLY provided whenevaluateFN
is"raccoonZeroEvaluate"
The Raccoon() constructor takes an optional parameter which specifies the configuration of raccoon
.
// Raccoon is configured to the default values explained above when called without a parameter
let raccoon = new Raccoon();
let raccoon = new Raccoon({
evaluateFN: "raccoonZeroEvaluate",
startFEN:
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1",
nnue_file: "lol.nnue",
});
Clear the board and set the position to FEN
. Returns {value: true, error: "No error!"}
if the position was
successfully loaded, otherwise {value: false, error: "the-specific-error-message"}
.
let raccoon = new Raccoon();
raccoon.load("8/b7/B7/8/8/8/8/k6K w - - 0 1");
// <. {value: true, error: "No error!"}
raccoon.load("8/T7/B7/8/8/8/8/k6K w - - 0 1");
// => {value: false, error: "Illegal character T"}
Ansi Square Color Table
- Background Black: \u001b[40m
- Background Red: \u001b[41m
- Background Green: \u001b[42m
- Background Yellow: \u001b[43m
- Background Blue: \u001b[44m
- Background Magenta: \u001b[45m
- Background Cyan: \u001b[46m
- Background White: \u001b[47m
- Background Bright Black: \u001b[40;1m
- Background Bright Red: \u001b[41;1m
- Background Bright Green: \u001b[42;1m
- Background Bright Yellow: \u001b[43;1m
- Background Bright Blue: \u001b[44;1m
- Background Bright Magenta: \u001b[45;1m
- Background Bright Cyan: \u001b[46;1m
- Background Bright White: \u001b[47;1m
Ansi Piece Color Table
- Black: \u001b[30m
- Red: \u001b[31m
- Green: \u001b[32m
- Yellow: \u001b[33m
- Blue: \u001b[34m
- Magenta: \u001b[35m
- Cyan: \u001b[36m
- White: \u001b[37m
- Bright Black: \u001b[30;1m
- Bright Red: \u001b[31;1m
- Bright Green: \u001b[32;1m
- Bright Yellow: \u001b[33;1m
- Bright Blue: \u001b[34;1m
- Bright Magenta: \u001b[35;1m
- Bright Cyan: \u001b[36;1m
- Bright White: \u001b[37;1m