gobang-ai
describe algo for gobang
Last updated 2 years ago by tinkgu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gobang-ai 
SYNC missed versions from official npm registry.

gobang-ai

build status

describe algo for gobang

Note: This is not the best solution, just to learn.

Install

npm i gobang-ai -S

NOTE

ALL INDEX START FROM 0

API

createBoard

create a board

interface Board {
    width: number,
    height: number,
    blocks: any[], // initial value is `false`
    finder: finder,
}

interface createBoard {
    (width: number, height: number): Board
}

finder

create find functions in all directions

// find piece in another direction
interface DirFunc {
    (i: number): number
}

interface finder {
    (width: number, height: number): {
        up: DirFunc,
        down: DirFunc,
        left: DirFunc,
        right: DirFunc,
        leftUp: DirFunc,
        rightUp: DirFunc,
        leftDown: DirFunc,
        rightDown: DirFunc,
        // if a piece in this board, return true
        inner: (i: number) => boolean
    }
}

pos2index

convert position object to index number


interface Pos {
    x: number,
    y: number,
}

interface pos2index {
    (board: Board, pos: Pos): number
}

checkPass

check 5 pieces in one line

interface checkPass {
    (board: Board, start: number): boolean
}

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2021 © npmmirror.com |