Template:Langton's ant

From mediawiki.org
(Redirected from Template:Formicarium)
Template documentation


Use this template to create an interactive instance of Langton's ant.

This template is a template gadget that requires the Formicarium gadget to work. Follow the installation instructions to get it working in your wiki.

Usage[edit]

Call this template with no parameters to create a small instance with a single ant in the center, like so:

Markup Renders as
{{Langton's ant}}

Use the parameters to change the initial conditions. Click on the canvas to introduce additional ants.

Installation[edit]

To install this template in your wiki:

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

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

Template data[edit]

Use this template to create an interactive instance of Langton's ant.

Template parameters[Edit template data]

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Autoplayautoplay

Start the game automatically

Example
yes
Booleanoptional
Widthwidth

Width of the instance, in pixels

Default
300
Example
600
Numberoptional
Heightheight

Height of the instance, in pixels

Default
150
Example
400
Numberoptional
Zoomzoom

Initial zoom of the instance

Example
3
Numberoptional
Gridgrid

Initial state of the grid

Example
on
Booleanoptional
Antsants

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

Default
0,0
Example
0,0; -1,0
Stringoptional
Cellscells

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

Example
0,1; 0,2; -1,1; -1,2
Stringoptional
Fallbackfallback

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

Default
[[File:LangtonsAntAnimated.gif]]
Unknownoptional

See also[edit]