randomCuboidScramble関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A scramble. Without a length, a puzzle that has few enough states
(hasRandomStateScramble) is scrambled to a state drawn uniformly from all
the states that are not solved, by the shortest turns that reach it; any
other is scrambled by a random walk of cuboidScrambleLength turns, one
more than that half the time, so that a puzzle whose graph has two sides can
land on either. With a length, a random walk of exactly that many turns,
each of a layer chosen at random and a turn that layer can make, never two
in a row of the same layer, which would join into one. Never leaves the
puzzle solved: a turn is added until it is not.
random is a number in [0, 1), like Math.random; pass seededRandom(seed)
for the same scramble from the same seed everywhere.
インポート
import { randomCuboidScramble } from "@johnmorrisdotca/kyuubu/cuboid";
定義
function randomCuboidScramble(dims: CuboidDims, length?: number, random?: () => number): CuboidMove[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
dims | CuboidDims | The cuboid’s x, y and z dimensions, in that order. |
length (省略可) | number | undefined | The requested number of scramble moves; omitted cuboid lengths use its scrambling strategy. |
random (省略可) | () => number | A source of numbers in [0, 1), such as seededRandom(seed). |
戻り値
CuboidMove[]
A scramble. Without a length, a puzzle that has few enough states (hasRandomStateScramble) is scrambled to a state drawn uniformly from all the states that are not solved, by the shortest turns that reach it; any other is scrambled by a random walk of cuboidScrambleLength turns, one more than that half the time, so that a puzzle whose graph has two sides can land on either. With a length, a random walk of exactly that many turns, each of a layer chosen at random and a turn that layer can make, never two in a row of the same layer, which would join into one. Never leaves the puzzle solved: a turn is added until it is not. random is a number in [0, 1), like Math.random; pass seededRandom(seed) for the same scramble from the same seed everywhere.
例
import { cuboidMovesNotation, randomCuboidScramble } from "@johnmorrisdotca/kyuubu/cuboid";
import { seededRandom } from "@johnmorrisdotca/kyuubu";
const dims = [2, 3, 3] as const;
console.log(cuboidMovesNotation(randomCuboidScramble(dims, 8, seededRandom("docs")), dims));R2 B2 F2 R2 F2 D2 L R出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。