本文へ移動

Jirai地雷

シード付きの地雷の盤を作り、見える数字からヒントを証明し、四角・四近傍・六角・端がつながる盤で遊べます。

「地雷」は、地面に埋められた爆弾のことです。 名前について(英語)

目次

リファレンス · 表示用の盤モデル

BoardModel型

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

Layout and cell presentation returned by boardModel.

インポート

import type { BoardModel } from "@johnmorrisdotca/jirai/draw";

定義

type BoardModel = {
    width: number;
    height: number;
    cells: CellModel[];
};

メンバー

名前型説明
widthnumber
heightnumber
cellsCellModel[]

例

import type { Settings } from "@johnmorrisdotca/jirai";
import { newGame, play } from "@johnmorrisdotca/jirai";
import type { BoardModel } from "@johnmorrisdotca/jirai/draw";
import { boardModel } from "@johnmorrisdotca/jirai/draw";

const settings: Settings={width:3,height:3,mines:1,grid:"square",noGuess:false,opening:"clear",seed:42};
const game=play(newGame(settings),{kind:"reveal",cell:0});
const value: BoardModel = boardModel(game);
console.log(value);
{
  width: 3,
  height: 3,
  cells: [
    {
      cell: 0,
      x: 0,
      y: 0,
      width: 1,
      height: 1,
      label: '1, 1: empty',
      text: '',
      kind: 'open',
      hint: false
    },
    {
      cell: 1,
      x: 1,
      y: 0,
      width: 1,
      height: 1,
      label: '1, 2: 1',
      text: '1',
      kind: 'open',
      hint: false
    },
    {
      cell: 2,
      x: 2,
      y: 0,
      width: 1,
      height: 1,
      label: '1, 3: mine',
      text: '✹',
      kind: 'mine',
      hint: false
    },
    {
      cell: 3,
      x: 0,
      y: 1,
      width: 1,
      height: 1,
      label: '2, 1: empty',
      text: '',
      kind: 'open',
      hint: false
    },
    {
      cell: 4,
      x: 1,
      y: 1,
      width: 1,
      height: 1,
      label: '2, 2: 1',
      text: '1',
      kind: 'open',
      hint: false
    },
    {
      cell: 5,
      x: 2,
      y: 1,
      width: 1,
      height: 1,
      label: '2, 3: 1',
      text: '1',
      kind: 'open',
      hint: false
    },
    {
      cell: 6,
      x: 0,
      y: 2,
      width: 1,
      height: 1,
      label: '3, 1: empty',
      text: '',
      kind: 'open',
      hint: false
    },
    {
      cell: 7,
      x: 1,
      y: 2,
      width: 1,
      height: 1,
      label: '3, 2: empty',
      text: '',
      kind: 'open',
      hint: false
    },
    {
      cell: 8,
      x: 2,
      y: 2,
      width: 1,
      height: 1,
      label: '3, 3: empty',
      text: '',
      kind: 'open',
      hint: false
    }
  ]
}

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

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

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