gomokuai

1.0.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i gomokuai

Weekly Downloads

8

Version

1.0.2

License

LGPL-3.0

Last publish

Collaborators

  • litemerafrukt