-
Notifications
You must be signed in to change notification settings - Fork 5
The Modules API
Teodor Elstad edited this page Sep 10, 2017
·
4 revisions
The sample players contain examples showing how to use the modules API
Find the best move by using the minmax algorithm with alpha-beta pruning.
.minmax accepts three arguments:
-
board
is a FEN string representing the current position. -
depth
is an positive integer specifying how deep the algorithm should traverse the decision tree before applying the score function. -
score
is a function accepting a chess.js object as an input argument, and returning a number betweenNumber.NEGATIVE_INFINITY
andNumber.POSITIVE_INFINITY
quantifying how good that position is (positive is better) for the player currently moving.
// JSFiddle
Modules.minmax(board, depth, score);
// node
var minmax = require('../modules/minmax.js');
minmax.move(board, depth, score);
Find the best move by using a minmax inspired iterative deepening algorithm.
.deepening accepts four arguments:
-
board
same as for .minmax. -
depth
same as for .minmax. -
score
same as for .minmax. -
span
is a value determining the number of most promising moves that should be explored when the algorithm descends the decision tree.
// JSFiddle
Modules.deepening(board, depth, score, span);
// node
var deepening = require('../modules/decender.js');
deepening.move(board, depth, score, span);
Find the best move by performing a lookup in a endgame tablebase containing the best moves for all positions with five or fewer pieces. The actual tablebase is located on cheslie-endgame.azurewebsites.net. If the lookup fails, a random legal move is returned.
.endgame accepts one argument:
-
board
is a FEN string representing the current position.
// JSFiddle
Modules.endgame(board);
// node
var endgame = require('../modules/endgame.js');
endgame.move(board);