本文へ移動

Meikyuu迷宮

シード付きの迷路と矢印パズルを作り、番号付きの問題を進め、平面や立体表面で遊べます。

「迷宮」は迷路のように入り組んだ場所を表す言葉です。 名前について(英語)

目次

リファレンス · 迷路・矢印・混合の盤

MazeGame型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A MAZE BEING DRAWN, as pure functions: each takes a game and returns a new one (or the same one, when nothing changed), so a page, a server and a test play by the same rules.

A line starts at the start cell and runs through open passages, one cell to the next. A cell the line is on again cuts the line back to it, so drawing back shortens it and a line never crosses itself, and never enters a cell with a stone on it (stones.ts). A key is picked up by passing over it and stays picked up when the line is drawn back. The maze is solved when the line's end is on the goal and every key is picked up; after that the line is fixed until Undo or Restart.

A finger is a stroke: pressMaze begins one (on the start, on the line's end, or on any cell of the line, which cuts it back there), dragMaze follows it into each cell, liftMaze ends it and is what Undo undoes. A tap, where the page offers it, is tapMaze.

インポート

import type { MazeGame } from "@johnmorrisdotca/meikyuu";

定義

type MazeGame<M extends MazeCore = Maze> = {
    readonly maze: M;
    readonly path: readonly number[];
    readonly collected: readonly number[];
    readonly solved: boolean;
    readonly drawing: boolean;
    readonly strokes: number;
    readonly stones: readonly number[];
    readonly rules: StoneRules | null;
    readonly undo: readonly {
        readonly path: readonly number[];
        readonly collected: readonly number[];
        readonly solved: boolean;
        readonly stones: readonly number[];
    }[];
};

メンバー

名前型説明
mazeM
pathreadonly number[]

The line, from the start; empty until it is begun.

collectedreadonly number[]

The keys picked up, in the order they were.

solvedboolean
drawingboolean

Whether a stroke is being drawn.

strokesnumber

How many strokes have been made, to count moves.

stonesreadonly number[]

The cells with a stone on them, in the order they were laid (see stones.ts); always empty in a game with no rules.

rulesStoneRules | null

What stones may be laid (StoneRules), or null for a game that has none.

undoreadonly { readonly path: readonly number[]; readonly collected: readonly number[]; readonly solved: boolean; readonly stones: readonly number[]; }[]

What each finished stroke (or each stone laid or taken up) started from, newest last, for Undo.

例

import type { MazeGame, MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze, newMazeGame } from "@johnmorrisdotca/meikyuu";

const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const game = newMazeGame(maze);
const value: MazeGame = game;
console.log(value);
{
  maze: {
    recipe: {
      shape: 'square',
      w: 5,
      h: 5,
      algorithm: 'backtracker',
      mode: 'to-goal',
      seed: 42
    },
    grid: {
      shape: 'square',
      w: 5,
      h: 5,
      centres: [Array],
      sides: [Array],
      box: [Object],
      at: [Function: at],
      cells: 25,
      neighbours: [Array]
    },
    links: [
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array]
    ],
    start: 6,
    goal: 15,
    entrance: null,
    exit: null,
    keys: []
  },
  path: [],
  collected: [],
  solved: false,
  drawing: false,
  strokes: 0,
  undo: [],
  stones: [],
  rules: null
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/meikyuu 3.2.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。