跳转到内容

模板:Conway's Game of Life

来自天灾之下:危险连接资料站
wiki>Sophivorus2025年3月1日 (六) 23:35的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
模板文档

Use this template to create an interactive instance of Conway's Game of Life.

See the installation instructions to get it working in your wiki.

Usage

Call this template with no parameters to create a small game with the the well-known R-pentomino, like so:

Markup Renders asLua错误:expandTemplate: template loop detected。

See the examples for other configurations.

Installation

To install this template in your wiki:

  1. Create a template with the following markup. You can choose the template name, parameter names and defaults to suit your wiki.
    <includeonly><div class="Vivarium"
    data-autoplay="{{{autoplay|}}}"
    data-width="{{{width|}}}"
    data-height="{{{height|}}}"
    data-zoom="{{{zoom|}}}"
    data-grid="{{{grid|}}}"
    data-cells="{{{cells|0,0; 0,1; 0,-1; -1,0; 1,1}}}"
    >{{{fallback|[[File:Gospers glider gun.gif]]}}}</div>[[Category:Gadget:Vivarium]]</includeonly>
    
  2. Create MediaWiki:Gadget-Vivarium.js with the following code:
    /**
     * Vivarium produces an interactive instance of Conway's Game of Life
     * Documentation: https://www.mediawiki.org/wiki/Template:Vivarium
     * Source code: https://www.mediawiki.org/wiki/MediaWiki:Gadget-Global-Vivarium.js
     */
    mw.loader.load( '//www.mediawiki.org/w/load.php?modules=ext.gadget.Global-Vivarium' );
    
  3. Add the following gadget to MediaWiki:Gadgets-definition:
    * Vivarium[ResourceLoader|hidden|default|categories=Gadget:Vivarium]|Vivarium.js
    

Done! Add your template to any page to verify that the installation was successful.

Examples

R-pentomino

Markup Renders asLua错误:expandTemplate: template loop detected。

Spaceships

Markup Renders asLua错误:expandTemplate: template loop detected。

Blinkers

Markup Renders asLua错误:expandTemplate: template loop detected。

Template data

Use this template to create an interactive instance of Conway's Game of Life

模板参数[编辑模板数据]

此模板首选参数换行的代码块格式。

参数描述类型状态
Autoplayautoplay

Start the game automatically

示例值
yes
布尔可选
Widthwidth

Width of the instance, in pixels

默认值
300
示例值
600
数字可选
Heightheight

Height of the instance, in pixels

默认值
150
示例值
400
数字可选
Zoomzoom

Initial zoom of the instance

示例值
3
数字可选
Gridgrid

Initial state of the grid

示例值
on
布尔可选
Cellscells

Initial cells of the instance, specified by a semicolon-separated list of coordinates

默认值
0,0; 0,1; 0,-1; -1,0; 1,1
字符串可选
Fallbackfallback

Fallback file or text, for users with JavaScript disabled or when printing

默认值
[[File:Gospers glider gun.gif]]
未知可选

See also