Skip to the content

Jirai地雷

Deal seeded minefields, prove hints from visible clues and mount square, orthogonal, hexagonal or wraparound boards.

Jirai is the Japanese word 地雷 for a land mine. About the name

Contents

Reference · Four-neighbour rules

orthogonalNeighboursfunction

Returns the adjacent cells under the orthogonal rules.

Import it

import { orthogonalNeighbours } from "@johnmorrisdotca/jirai/orthogonal";

Also exported from: @johnmorrisdotca/jirai

Definition

function orthogonalNeighbours(settings: OrthogonalSettings, cell: number): number[]

Parameters

NameTypeDescription
settingsOrthogonalSettings

The validated native field dimensions, mine count, topology, shape, opening, generation policy and numeric seed.

cellnumber

An active native cell index in row-major board order.

Returns

number[]

Returns the adjacent cells under the orthogonal rules.

Examples

import type { OrthogonalSettings } from "@johnmorrisdotca/jirai/orthogonal";
import { orthogonalNeighbours } from "@johnmorrisdotca/jirai/orthogonal";

const orthogonalSettings: OrthogonalSettings={width:3,height:3,mines:1,noGuess:false,opening:"clear",seed:42};
console.log(orthogonalNeighbours(orthogonalSettings,0));
[ 1, 3 ]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/jirai 0.5.0.