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
| Name | Type | Description |
|---|---|---|
board | Cell[] | The row-major board cells; null marks an empty point. |
size | number | The number of cells on each side of the board. |
stone | Stone | The black or white colour being examined. |
point | Point | 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)