npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sabaki/influence

v1.2.2

Published

Simple static heuristics for estimating influence maps on Go positions.

Downloads

98

Readme

@sabaki/influence Build Status

Simple static heuristics for estimating influence maps on Go positions.

Installation

Use npm to install:

$ npm install @sabaki/influence

Then require it as follows:

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

[[ 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
  • 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.

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

influence.areaMap(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)

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
  • 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.