GameState
($0)
parameter | type | description |
---|---|---|
$0 |
Object
= {}
|
|
$0.artificialIntelligenceViewEventHandler | any | |
$0.firstPlayerId | any |
const gameState = new GameState();
currentPlayer
()
number
:
The numeric representation (
0
for white player or
1
for black player) of the current player.
currentPlayerObject
()
object
:
The object representation of the current player.
fenString
()
string
:
log
()
array
:
aiSettings
()
array
:
newGame
($0)
parameter | type | description |
---|---|---|
$0 |
Object
= {}
|
|
$0.gameId | any |
undefined
:
export
()
string
:
The current game state as stringified JSON.
import
(unparsedGameData, options)
parameter | type | description |
---|---|---|
unparsedGameData |
string | |
options |
object
= {}
|
|
options.resumeGame |
any
(default false )
|
|
options.noConsoleOutput |
any
(default false )
|
undefined
:
updateTimePlayed
()
undefined
:
pause
()
undefined
:
resume
()
undefined
:
nextTurn
()
undefined
:
recordMove
(move)
parameter | type | description |
---|---|---|
move |
any |
undefined
:
getFirstPiece
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.type | any | |
$0.player | any |
(Piece | undefined)
:
getPieceAt
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any |
(Piece | undefined)
:
The piece at the coordinates.
const piece = getPieceAt({ x: 2, y: 1 });
hasPieceAt
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any |
boolean
:
true
if there is a piece at the coordinates; otherwise,
false
.
const isPiece = hasPieceAt({ x: 4, y: 5 });
removePiece
(pieceToRemove)
parameter | type | description |
---|---|---|
pieceToRemove |
any |
undefined
:
removePiece({
id: '297a7c98-da21-4309-8751-9e187f51259b',
type: 'pawn',
x: 1,
y: 3,
player: 0
});
select
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any |
boolean
:
unselect
()
undefined
:
isSelectedSquare
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any |
boolean
:
true
if the coordinates correspond to a selected tile; otherwise,
false
.
isPawnCapturing
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any | |
$0.vectorX | any | |
$0.vectorY | any | |
$0.direction | any |
boolean
:
isPawnMoving
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any | |
$0.vectorX | any | |
$0.vectorY | any | |
$0.firstMove | any | |
$0.direction | any |
boolean
:
isEnPassant
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any | |
$0.vectorX | any | |
$0.vectorY | any | |
$0.direction | any |
boolean
:
isBishopPattern
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.vectorX | any | |
$0.vectorY | any |
boolean
:
isBishopMoveFree
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.origin | any | |
$0.destination | any | |
$0.vector | any |
boolean
:
isRookPattern
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.vectorX | any | |
$0.vectorY | any |
boolean
:
isRookMoveFree
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.origin | any | |
$0.vector | any |
boolean
:
isKingPattern
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.vectorX | any | |
$0.vectorY | any |
boolean
:
isCastlePattern
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.vectorX | any | |
$0.vectorY | any |
boolean
:
performCastle
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.castleVectorX | any | |
$0.selectedPiece | any | |
$0.destination | any | |
$0.from | any |
boolean
:
isPiecePattern
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.destination.x | any | |
$0.destination.y | any | |
$0.origin | any | |
$0.type | any | |
$0.player | any | |
$0.firstMove | any |
boolean
:
Whether the pattern corresponds to the piece
isKingInCheck
(kingProjection)
parameter | type | description |
---|---|---|
kingProjection |
any |
boolean
:
isGameEnd
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.player |
any
(default this.currentPlayer )
|
(boolean | string)
:
isLegalMove
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.destination | any | |
$0.origin | any | |
$0.type | any | |
$0.player | any | |
$0.firstMove | any |
boolean
:
moveSelectedPiece
($0)
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.x | any | |
$0.y | any |
boolean
:
ArtificialIntelligence
()
const eventHandler = (payload) => console.log(payload);
artificialIntelligence.init({ eventHandler });
isIgnoredMessage
(message)
Returns whether this event should be emitted or not.
parameter | type | description |
---|---|---|
message |
object |
boolean
:
responseParser
(message)
Parses UCI output into an event.
parameter | type | description |
---|---|---|
message |
string |
object
:
init
($0)
Initializes Stockfish-js.
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.eventHandler |
any
(default ()=>{} )
|
|
$0.debugLevel |
any
(default STOCKFISH_DEFAULT_DEBUG_LEVEL )
|
instance
:
startGame
()
Using this method before playing is required to support more than one game.
undefined
:
sendRawCommand
(command)
Sends a command to Stockfish-js.
parameter | type | description |
---|---|---|
command |
string |
undefined
:
onMessage
(message)
Handles messages sent by Stockfish-js.
parameter | type | description |
---|---|---|
message |
string |
undefined
:
emitEvent
($0)
Sends payloads to the event handler.
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.debugLevel | any | |
$0.payload | ...any |
undefined
:
computeNextMove
(move, fenstring)
Asks to Stockfish-js to compute the best response to this move.
parameter | type | description |
---|---|---|
move |
string | |
fenstring |
(string | undefined) |
undefined
:
setOption
($0)
Changes an option of the chess engine.
parameter | type | description |
---|---|---|
$0 |
Object | |
$0.name | any | |
$0.value | any |