ArrowGame型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
AN ARROW PUZZLE BEING PLAYED, as pure functions. tapArrow is the one move: a free arrow
is taken off the board; a blocked one costs a heart (and says which arrow is in its way); a
locked one that has not been unlocked does nothing at all, and costs nothing, because the
player cannot know yet. The same goes for an arrow that no order of taps can clear before the
unlock, because a locked arrow is in its way, directly or behind others (locked, with by naming
the arrow to look at): nothing the player does can free it, so it must not cost the hearts the
puzzle is lost with, and a mixed puzzle cannot be lost before the labyrinth has even been tried.
Clear every arrow to win; lose the last heart and the puzzle is lost until it is restarted.
The mixed puzzles lock some arrows until a button deep in a maze is reached. unlockArrows
is what reaching it does.
インポート
import type { ArrowGame } from "@johnmorrisdotca/meikyuu";
定義
type ArrowGame = {
readonly board: ArrowBoard;
readonly present: readonly boolean[];
readonly hearts: number;
readonly heartsAtStart: number;
readonly unlocked: boolean;
readonly status: "playing" | "cleared" | "lost";
readonly taken: readonly number[];
readonly mistakes: number;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
board | ArrowBoard | |
present | readonly boolean[] | Whether each arrow is still on the board. |
hearts | number | |
heartsAtStart | number | |
unlocked | boolean | Whether the locked arrows have been unlocked. |
status | "playing" | "cleared" | "lost" | |
taken | readonly number[] | The arrows taken, in order, for Undo and for the page's own record. |
mistakes | number | Taps that cost a heart. |
例
import type { ArrowGame, ArrowRecipe } from "@johnmorrisdotca/meikyuu";
import { makeArrows, newArrowGame } from "@johnmorrisdotca/meikyuu";
const arrowRecipe: ArrowRecipe = {shape:"square",w:5,h:5,longest:3,seed:42};
const arrows = makeArrows(arrowRecipe);
const arrowGame = newArrowGame(arrows);
const value: ArrowGame = arrowGame;
console.log(value);{
board: {
recipe: { shape: 'square', w: 5, h: 5, longest: 3, seed: 42 },
w: 5,
h: 5,
inShape: [
true, true, true, true, true,
true, true, true, true, true,
true, true, true, true, true,
true, true, true, true, true,
true, true, true, true, true
],
arrows: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
],
locked: [
false, false, false,
false, false, false,
false, false, false,
false, false, false,
false
]
},
present: [
true, true, true,
true, true, true,
true, true, true,
true, true, true,
true
],
hearts: 3,
heartsAtStart: 3,
unlocked: true,
status: 'playing',
taken: [],
mistakes: 0
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。