RSG-Chess-API
Chess APIs based on RSG Chess
Installation
// via NPM
npm install rsg-chess
// via Yarn
yarn add rsg-chess
// via CDN
<script src="https://storage.googleapis.com/rsg-chess-api/cdn/index.min.js">
Usage
Import the modules
// ES6; // NodeJSconst Game AI Pieces tools = ; // CDN// The `RSGChess` global variable can be used once, after all scripts have loaded successfullyvar Game = RSGChessgame;var AI = RSGChessAI;// ect.
Use the functions
To use our API take a look at the docs and the supported functions!
Example:
// ES6const game = Gameprototype;game... // Node.JSconst game = RSGChessGameprototype;game... // Standard JSvar game = RSGChessGameprototype;// RSGChess is a global variablegame
Releases and changelog
Docs
Documentations, Get Started guides and tutorials are available on http://rsg-chess.now.sh/docs/api/
Note that the docs are not completed yet and may contain wrong links and broken demos.
Supported functions
Game logic and controls
new Game (promoCallback)
Game.prototype.initializeGame
Game.prototype.piece (type, x, y, color)
Game.prototype.moveSelected (selected, to, promotionCallback, checkmateCallback, simulate)
Game.prototype.promotePawn (pawn, x, y, color, type)
Game.prototype.simulateAndFilter (moves, piece)
Game.prototype.checkmate (color)
Game.prototype.simpleMovePiece (piece, from, to)
Game.prototype.warning (color)
Game.prototype.allMoves
notations and rules
Game.prototype.threefoldCheck
Game.prototype.halfmoveClock
Game.prototype.castlingTarget
Game.prototype.enPassantTarget
Game.prototype.fullmoveCount
Game.prototype.pieceToAN (x, y)
Game.prototype.boardToFEN
Game.prototype.activeColour
Game.prototype.gameToFEN
Game.prototype
variables
game.board
game.turn
game.threefold
game.FEN
andgame.FENboard
AI
- The
AI
method. -
- syntax and input:
AI(depth, gameState, isMaximisingPlayer)
- syntax and input:
-
- output:
bestmove { from, to }
- output:
Tools
Sometimes you need to manage a lot of different indications such as app performance, AI speed, bundle file size, battery life and more. That's why we've added tools
to RSG Chess API
as built-in methods or external plugins. With them you can run more complex tasks (transfer data from/to servers/back-ends, using workers and threads or databases), manage the performance and improve the speed of the app.
uncycleBoard(boardObject)
uncycleTurns(turnObject)
These two methods remove the cyclic game references from the board and turn objects so you can stringify them, send via HTTP requests or even save as cookies for later usage.
RSG Chess mobile
app and the rest of the "RSG Chess family"
This API is officially powering the - Gitub: https://github.com/RSG-Group/RSG-Chess-mobile
- Google Play Store: https://play.google.com/store/apps/details?id=com.rsg.chess
- Amazon AppStore: https://www.amazon.com/RSG-Group-Chess/dp/B07D1KWTK7