# @sabaki/influence

> Simple static heuristics for estimating influence maps on Go positions.

Latest version **1.2.2** (published 2019-12-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sabaki/influence
pnpm add @sabaki/influence
yarn add @sabaki/influence
bun add @sabaki/influence
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2019-12-13 |
| First published | 2018-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Yichuan Shen |
| Maintainers | sabaki |
| Keywords | go, weiqi, baduk, strategy, analyzer, boardgame, influence |

## Links

- npm: https://www.npmjs.com/package/@sabaki/influence
- Repository: https://github.com/SabakiHQ/influence
- Issues: https://github.com/SabakiHQ/influence/issues
- npm.io page: https://npm.io/package/@sabaki/influence

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2019-12-13
- 1.1.0-beta4 (next) — 2018-05-14
- 1.2.1 — 2019-08-13
- 1.2.0 — 2019-08-13
- 1.1.4 — 2018-05-15
- 1.1.3 — 2018-05-15
- 1.1.2 — 2018-05-14
- 1.1.1 — 2018-05-14
- 1.1.0 — 2018-05-14
- 1.1.0-beta3 — 2018-05-14
- 1.1.0-beta2 — 2018-05-14
- 1.1.0-beta — 2018-05-14
- 1.0.2 — 2018-03-30
- 1.0.1 — 2018-03-16
- 1.0.0 — 2018-03-13

## README

# @sabaki/influence [![Build Status](https://travis-ci.org/SabakiHQ/influence.svg?branch=master)](https://travis-ci.org/SabakiHQ/influence)

Simple static heuristics for estimating influence maps on Go positions.

## Installation

Use npm to install:

~~~
$ npm install @sabaki/influence
~~~

Then require it as follows:

~~~js
const influence = require('@sabaki/influence');
~~~

## API

### Board Data

The board arrangement is represented by an array of arrays. Each of those subarrays represent one row, all containing the same number of integers. `-1` denotes a white stone, `1` a black stone, and `0` represents an empty vertex

#### Example

~~~js
[[ 0,  0,  1,  0, -1, -1,  1,  0, 0],
 [ 1,  0,  1, -1, -1,  1,  1,  1, 0],
 [ 0,  0,  1, -1,  0,  1, -1, -1, 0],
 [ 1,  1,  1, -1, -1, -1,  1, -1, 0],
 [ 1, -1,  1,  1, -1,  1,  1,  1, 0],
 [-1, -1, -1, -1, -1,  1,  0,  0, 0],
 [ 0, -1, -1,  0, -1,  1,  1,  1, 1],
 [ 0,  0,  0,  0,  0, -1, -1, -1, 1],
 [ 0,  0,  0,  0,  0,  0,  0, -1, 0]]
~~~

### `influence.map(data[, options])`

* `data` - [Board data](#board-data)
* `options` `<Object>` *(optional)*
    * `discrete` `<Boolean>` *(optional)* - Default: `false`
    * `maxDistance` `<Number>` *(optional)* - Default: `6`

      Only assigns a non-zero number to a vertex if its Manhattan distance to a stone of corresponding color is less or equal to `maxDistance`.

    * `minRadiance` `<Number>` *(optional)* - Default: `2`

      Only assigns a non-zero number to a vertex if the vertex has radiance in its corresponding color greater or equal to `minRadiance`.

Returns an array of arrays of the same size as `data`. Each entry is a number between `-1` and `1` inclusive. A negative number corresponds to white influence whereas a positive number denotes black influence.

This map does not take dead stones into account, i.e. it will assume all stones specified in `data` are alive. To get better results, remove dead stones first, either manually or with the [`deadstones` module](https://github.com/SabakiHQ/deadstones).

If `discrete` is set to `true`, the map will only contain `-1`, `0`, or `1` as values.

### `influence.areaMap(data)`

* `data` - [Board data](#board-data)

Returns an array of arrays of the same size as `data`. Each entry is either `-1`, `0`, or `1`, corresponding to white area, neutral area, and black area.

### `influence.nearestNeighborMap(data, sign)`

* `data` - [Board data](#board-data)
* `sign` `-1` | `1`

Returns an array of arrays of the same size as `data`. Each entry is an non-negative integer which denotes the Manhattan distance to the nearest stone with the color given by `sign`. `-1` denotes white and `1` corresponds to black.

### `influence.radianceMap(data, sign[, options])`

* `data` - [Board data](#board-data)
* `sign` `-1` | `1`
* `options` `<Object>` *(optional)*
    * `p1` `<Number>` *(optional)* - Default: `6`
    * `p2` `<Number>` *(optional)* - Default: `1.5`
    * `p3` `<Number>` *(optional)* - Default: `2`

Returns an array of arrays of the same size as `data`. Each entry is a non-negative number which encodes how many stones of the color corresponding to `sign` is in its vicinity. `-1` corresponds to white stones whereas `1` denotes black stones. Each chain of the color corresponding to `sign` emits *radiance* which diminishes over distance, adds up with the radiance of other chains, and reflects at the board edge.

`p1`, `p2`, and `p3` are parameters, controlling how strong the radiance is initially and how it diminishes.

---
_Source: https://npm.io/package/@sabaki/influence · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
