模板:Conway's Game of Life
| 文件:Unofficial JavaScript logo 2.svg | This template is a template gadget. It requires the Vivarium gadget to work, which is loaded automatically when this template is used. |
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:
- 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>
- 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' );
- 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
| 参数 | 描述 | 类型 | 状态 | |
|---|---|---|---|---|
| Autoplay | autoplay | Start the game automatically
| 布尔 | 可选 |
| Width | width | Width of the instance, in pixels
| 数字 | 可选 |
| Height | height | Height of the instance, in pixels
| 数字 | 可选 |
| Zoom | zoom | Initial zoom of the instance
| 数字 | 可选 |
| Grid | grid | Initial state of the grid
| 布尔 | 可选 |
| Cells | cells | Initial cells of the instance, specified by a semicolon-separated list of coordinates
| 字符串 | 可选 |
| Fallback | fallback | Fallback file or text, for users with JavaScript disabled or when printing
| 未知 | 可选 |
See also
- es:Plantilla:Juego de la vida - Spanish localization of this template
- Template:Langton's ant - Related template
- User:Sophivorus - Main author of this template