Skip to the content

Narabe並べ

Play forty-eight abstract board games through immutable moves, legal choices and replayable records.

Narabe means arranging in Japanese, as in gomoku-narabe: five in a row. About the name

Contents

Reference · Rules and records

flipsAtfunction

The discs a stone of stone at point would turn. Empty means the move is illegal. directions is the square board's eight unless a caller says otherwise; everything that has a state to hand reads flipDirections.

Import it

import { flipsAt } from "@johnmorrisdotca/narabe";

Definition

function flipsAt(board: Cell[], size: number, stone: Stone, point: Point, directions?: readonly Point[]): Point[]

Parameters

NameTypeDescription
boardCell[]

The row-major board cells; null marks an empty point.

sizenumber

The number of cells on each side of the board.

stoneStone

The black or white colour being examined.

pointPoint

A zero-based row and column on the board.

directions (optional)readonly Point[]

The board directions in which discs can flip.

Returns

Point[]

The discs a stone of stone at point would turn. Empty means the move is illegal. directions is the square board's eight unless a caller says otherwise; everything that has a state to hand reads flipDirections.

Examples

import { createGame, flipsAt } from "@johnmorrisdotca/narabe";

const reversi = createGame({variant:"reversi"});
console.log(flipsAt(reversi.board,8,"black",{row:2,col:3}));
[ { row: 3, col: 3 } ]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/narabe 1.3.0.