1.0.2 • Published 6 years ago

gomokuai v1.0.2

Weekly downloads
1
License
LGPL-3.0
Repository
-
Last release
6 years ago

Simple gompku ai

Build Status Maintainability Scrutinizer Code Quality Code Coverage Build Status

Calculates next move for a gomoku game.

Install

npm install gomokuai.

Usage

Gomokuai has a simple API with just two funktions:

// bestMove :: ([Mark], Size) -> Position
//  Mark = 0 | 1 | 2
//  Size = Integer
//  Position = { x: Integer, y: Integer }
const bestMove = (board, boardSize) => {
    /*...*/
};

// randomMove :: ([Mark], Size) -> Position
//  Mark = 0 | 1 | 2
//  Size = Integer
//  Position = { x: Integer, y: Integer }
const randomMove = (board, boardSize) => {
    /*...*/
};

You put in a flat array representing your gomoku game board, the size of the game board (quadratic, eg 10x10 gives Size = 10) and you get back a position object.

bestMove calculates the best move to make on the current game board and randomMove just gives you a random placement on any free space.

Example

const ai = require("gomokuai");

/* ... */

const { x, y } = ai.bestMove(gameBoard.getBoard(), gameBoard.getSize());
gameBoard.play(x, y);

Tests

Clone the repo, cd in, npm install, npm test.

TODO

  • Write a new best-move calculator.
  • Increase code quality.

Shoutout

The best-move calculator is a ripped from a jQuery plugin by Stefan Gabos

Licens LGPL-3.0

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago