go-game

0.2.1 • Public • Published

Go game on nodejs

Simple library that provides go game api to play with

Install

$ npm install go-game

Run & use

Basic usage

'use strict';
 
const go = require('go-game');
 
let game = new go(19);
 
// be sure to pass correct player on queue
// you can use game.currentPlayer to get one
game.playerTurn(go.BLACK, [0, 3]);
game.playerTurn(go.WHITE, [1, 3]);

Logging, back-ups and restores

// ...
 
console.log(game.printField());
 
// get current game in JSON format
let json = JSON.stringify(game);
 
// create instance from json
let prevGame = new go(json);
let oldGame  = new go(19).fromJSON(json);

Rollbacks

let turns = 2;
game.rollback(turns); // number of turns

Score

let score = game.score;
console.log(score[go.BLACK], score[go.WHITE]);

TODO

  • return ko rule
  • add final score calculation and game end
  • improve printField output

Readme

Keywords

Package Sidebar

Install

npm i go-game

Weekly Downloads

1

Version

0.2.1

License

ISC

Last publish

Collaborators

  • damirka