reversi
Core logics for the Reversi
Playtest
Installation
npm install -g reversi
Run by CUI
You can start the Reversi game by reversi
command:
$reversi 012345670--------1--------2--------3---ox---4---xo---5--------6--------7--------x: 2, o: 2> Place a "x" piece:
If you input like this:
(x,y):3,2
It becomes such a result:
01234567
0--------
1--------
2---x----
3---xx---
4---xo---
5--------
6--------
7--------
x: 4, o: 1
> Place a "o" piece
(x,y):
Use in Node.js
Installation
npm install --save reversi
Examples
More examples can be found in here.
var reversi = ;var Game = reversiGame;var PIECE_TYPES = reversiPIECE_TYPES; //// Start a game//var game = ;console;//// 01234567// 0--------// 1--------// 2--------// 3---ox---// 4---xo---// 5--------// 6--------// 7--------// x: 2, o: 2// > Place a "x" piece// //// Place a piece by (rowIndex, colIndex)//var report = game;console;//// 01234567// 0--------// 1--------// 2---x----// 3---xx---// 4---xo---// 5--------// 6--------// 7--------// x: 4, o: 1// > Place a "o" piece// //// Get more information at "proceed" execution//console;//// { pieceType: 'BLACK',// rivalPieceType: 'WHITE',// rowIndex: 2,// colIndex: 3,// isSuccess: true,// isNextActorPassed: false }// //// Get status//gameisEnded; // -> falsegame; // -> PIECE_TYPES.BLACK //// Board object//var board = gameboard;var squares = boardsquares; // -> squares[rowIndex][colIndex] //// Chack placable squares//board; // -> falseboard; // -> trueboard; // -> 3 squaresboard; // -> true //// Get score detail//board; // -> { [PIECE_TYPES.BLACK]: 4, [PIECE_TYPES.WHITE]: 1, [PIECE_TYPES.BLANK]: 59 }