stepBetween関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The way from a to its neighbour b as a step (-1, +1, -size, +size),
counting a step across a wrapped edge as the step it is — right off the
right edge is +1, though the cells' numbers differ by size - 1. On a
hexagon, the two slanting steps too: up-right (1 - size) and down-left
(size - 1). Zero for cells that are not neighbours.
インポート
import { stepBetween } from "@johnmorrisdotca/tsunagi";
定義
function stepBetween(size: number, a: number, b: number, wrap: boolean, hex?: boolean): number
引数
| 名前 | 型 | 説明 |
|---|---|---|
size | number | The number of cells on each side of the board. |
a | number | The first cell index. |
b | number | The second cell index. |
wrap | boolean | Whether opposite board edges connect. |
hex (省略可) | boolean | Whether to use hexagonal neighbours. |
戻り値
number
The way from a to its neighbour b as a step (-1, +1, -size, +size), counting a step across a wrapped edge as the step it is — right off the right edge is +1, though the cells' numbers differ by size - 1. On a hexagon, the two slanting steps too: up-right (1 - size) and down-left (size - 1). Zero for cells that are not neighbours.
例
import { stepBetween } from "@johnmorrisdotca/tsunagi";
console.log(stepBetween(4,0,1,false));1出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。