Simple gompku ai
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 = { /*...*/}; // randomMove :: ([Mark], Size) -> Position// Mark = 0 | 1 | 2// Size = Integer// Position = { x: Integer, y: Integer }const randomMove = { /*...*/};
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 = ; /* ... */ const x y = ai;gameBoard;
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