UNPKG

cacatoo

Version:

Building, exploring, and sharing spatially structured models

4,576 lines (930 loc) 92.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Gridmodel</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Gridmodel</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span>Gridmodel<span class="signature">(name, config, rng)</span><span class="type-signature"></span></h2> <div class="class-description">Gridmodel is the main type of model in Cacatoo. Most of these models will look and feel like CAs, but GridModels can also contain ODEs with diffusion, making them more like PDEs.</div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="Gridmodel"><span class="type-signature"></span>new Gridmodel<span class="signature">(name, config, rng)</span><span class="type-signature"></span></h4> <div class="description"> The constructor function for a @Gridmodel object. Takes the same config dictionary as used in @Simulation </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>name</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The name of your model. This is how it will be listed in @Simulation 's properties</td> </tr> <tr> <td class="name"><code>config</code></td> <td class="type"> <span class="param-type">dictionary</span> </td> <td class="description last">A dictionary (object) with all the necessary settings to setup a Cacatoo GridModel.</td> </tr> <tr> <td class="name"><code>rng</code></td> <td class="type"> <span class="param-type">MersenneTwister</span> </td> <td class="description last">A random number generator (MersenneTwister object)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line351">line 351</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="MargolusDiffusion"><span class="type-signature"></span>MargolusDiffusion<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Apply diffusion algorithm for grid-based models described in Toffoli & Margolus' book "Cellular automata machines" The idea is to subdivide the grid into 2x2 neighbourhoods, and rotate them (randomly CW or CCW). To avoid particles simply being stuck in their own 2x2 subspace, different 2x2 subspaces are taken each iteration (CW in even iterations, CCW in odd iterations) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1157">line 1157</a> </li></ul></dd> </dl> <h4 class="name" id="apply_async"><span class="type-signature"></span>apply_async<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Analogous to apply_sync(func), but asynchronous </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line693">line 693</a> </li></ul></dd> </dl> <h4 class="name" id="apply_sync"><span class="type-signature"></span>apply_sync<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Like the synchronous function above, but can not take a custom user-defined function rather than the default next-state function. Technically one should be able to refarctor this by making the default function of synchronous "nextstate". But this works. :) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line660">line 660</a> </li></ul></dd> </dl> <h4 class="name" id="asynchronous"><span class="type-signature"></span>asynchronous<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Asynchronously apply the nextState function (defined by user) to the entire grid Asynchronous means that all grid points will be updated in a random order. For this first the update_order will be determined (this.set_update_order). Afterwards, the nextState will be applied in that order. This means that some cells may update while all their neighours are still un-updated, and other cells will update while all their neighbours are already done. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line681">line 681</a> </li></ul></dd> </dl> <h4 class="name" id="attachODE"><span class="type-signature"></span>attachODE<span class="signature">(eq, conf)</span><span class="type-signature"></span></h4> <div class="description"> Attaches an ODE to all GPs in the model. Each gridpoint has it's own ODE. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>eq</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Function that describes the ODEs, see examples starting with "ode"</td> </tr> <tr> <td class="name"><code>conf</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">dictionary style configuration of your ODEs (initial state, parameters, etc.)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1413">line 1413</a> </li></ul></dd> </dl> <h4 class="name" id="clearGrid"><span class="type-signature"></span>clearGrid<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Replaces current grid with an empty grid </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line398">line 398</a> </li></ul></dd> </dl> <h4 class="name" id="colourGradient"><span class="type-signature"></span>colourGradient<span class="signature">(property, n)</span><span class="type-signature"></span></h4> <div class="description"> Initiate a gradient of colours for a property. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The name of the property to which the colour is assigned</td> </tr> <tr> <td class="name"><code>n</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">How many colours the gradient consists off For example usage, see colourViridis below</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line582">line 582</a> </li></ul></dd> </dl> <h4 class="name" id="colourGradientArray"><span class="type-signature"></span>colourGradientArray<span class="signature">(property, n)</span><span class="type-signature"></span></h4> <div class="description"> Initiate a gradient of colours for a property (return array only) </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The name of the property to which the colour is assigned</td> </tr> <tr> <td class="name"><code>n</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">How many colours the gradient consists off For example usage, see colourViridis below</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line544">line 544</a> </li></ul></dd> </dl> <h4 class="name" id="colourViridis"><span class="type-signature"></span>colourViridis<span class="signature">(property, n, rev)</span><span class="type-signature"></span></h4> <div class="description"> Initiate a gradient of colours for a property, using the Viridis colour scheme (purpleblue-ish to green to yellow) or Inferno (black to orange to yellow) </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="default"> </td> <td class="description last">The name of the property to which the colour is assigned</td> </tr> <tr> <td class="name"><code>n</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="default"> </td> <td class="description last">How many colours the gradient consists off</td> </tr> <tr> <td class="name"><code>rev</code></td> <td class="type"> <span class="param-type">bool</span> </td> <td class="default"> false </td> <td class="description last">Reverse the viridis colour gradient</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line609">line 609</a> </li></ul></dd> </dl> <h4 class="name" id="copyGP"><span class="type-signature"></span>copyGP<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Copy properties from src gridpoint into dst gridpoint (reuses dst object) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line775">line 775</a> </li></ul></dd> </dl> <h4 class="name" id="copyGridpoint"><span class="type-signature"></span>copyGridpoint<span class="signature">(x, y)</span><span class="type-signature"></span></h4> <div class="description"> Return a copy of the gridpoint at position x,y Makes sure wrapping is applied if necessary </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>x</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>y</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line762">line 762</a> </li></ul></dd> </dl> <h4 class="name" id="copyIntoGridpoint"><span class="type-signature"></span>copyIntoGridpoint<span class="signature">(x, y, @Gridpoint)</span><span class="type-signature"></span></h4> <div class="description"> Change the gridpoint at position x,y into gp Makes sure wrapping is applied if necessary </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>x</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>y</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>@Gridpoint</code></td> <td class="type"> <span class="param-type"><a href="Gridpoint.html">Gridpoint</a></span> </td> <td class="description last">object to set the gp to</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line785">line 785</a> </li></ul></dd> </dl> <h4 class="name" id="countMoore8"><span class="type-signature"></span>countMoore8<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> countNeighbours for range 1-8 (see countNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line970">line 970</a> </li></ul></dd> </dl> <h4 class="name" id="countMoore9"><span class="type-signature"></span>countMoore9<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> countNeighbours for range 0-8 (see countNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line973">line 973</a> </li></ul></dd> </dl> <h4 class="name" id="countNeighbours"><span class="type-signature"></span>countNeighbours<span class="signature">(grid, col, row, property, val, range)</span><span class="type-signature"> &rarr; {int}</span></h4> <div class="description"> Count the number of neighbours with 'val' in 'property' (Neu4, Neu5, Moore8, Moore9 depending on range-array) </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>grid</code></td> <td class="type"> <span class="param-type">GridModel</span> </td> <td class="description last">The gridmodel used to check neighbours. Usually the gridmodel itself (i.e., this), but can be mixed to make grids interact.</td> </tr> <tr> <td class="name"><code>col</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>row</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">the property that is counted</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">value property must have to be counted</td> </tr> <tr> <td class="name"><code>range</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">which section of the neighbourhood must be counted? (see this.moore, e.g. 1-8 is Moore8, 0-4 is Neu5,etc)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line958">line 958</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of grid points with "property" set to "val" Below, 4 version of this functions are overloaded (Moore8, Moore9, Neumann4, etc.) For example, if one wants to count all the "alive" individuals in the Moore 9 neighbourhood, use this.countNeighbours(this,10,10,1,'alive',[0-8]); or this.countMoore9(this,10,10,1,'alive'); </div> <dl> <dt> Type </dt> <dd> <span class="param-type">int</span> </dd> </dl> <h4 class="name" id="countNeumann4"><span class="type-signature"></span>countNeumann4<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> countNeighbours for range 1-4 (see countNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line976">line 976</a> </li></ul></dd> </dl> <h4 class="name" id="countNeumann5"><span class="type-signature"></span>countNeumann5<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> countNeighbours for range 0-4 (see countNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line979">line 979</a> </li></ul></dd> </dl> <h4 class="name" id="diffuseODEstates"><span class="type-signature"></span>diffuseODEstates<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Diffuse ODE states on the grid. Because ODEs are stored by reference inside gridpoint, the states of the ODEs have to be first stored (copied) into a 4D array (x,y,ODE,state-vector), which is then used to update the grid. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1099">line 1099</a> </li></ul></dd> </dl> <h4 class="name" id="diffuseStateVector"><span class="type-signature"></span>diffuseStateVector<span class="signature">(rate)</span><span class="type-signature"></span></h4> <div class="description"> Diffuse continuous states on the grid. * @param {string} state The name of the state to diffuse but can be mixed to make grids interact. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>rate</code></td> <td class="type"> <span class="param-type">float</span> </td> <td class="description last">the rate of diffusion. (<0.25)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1053">line 1053</a> </li></ul></dd> </dl> <h4 class="name" id="diffuseStates"><span class="type-signature"></span>diffuseStates<span class="signature">(rate)</span><span class="type-signature"></span></h4> <div class="description"> Diffuse continuous states on the grid. * @param {string} state The name of the state to diffuse but can be mixed to make grids interact. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>rate</code></td> <td class="type"> <span class="param-type">float</span> </td> <td class="description last">the rate of diffusion. (<0.25)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1022">line 1022</a> </li></ul></dd> </dl> <h4 class="name" id="getAllNeighbours"><span class="type-signature"></span>getAllNeighbours<span class="signature">(grid, col, row, range)</span><span class="type-signature"></span></h4> <div class="description"> Get array of grid points with val in property (Neu4, Neu5, Moore8, Moore9 depending on range-array) </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>grid</code></td> <td class="type"> <span class="param-type">GridModel</span> </td> <td class="description last">The gridmodel used to check neighbours. Usually the gridmodel itself (i.e., this), but can be mixed to make grids interact.</td> </tr> <tr> <td class="name"><code>col</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>row</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>range</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">which section of the neighbourhood must be counted? (see this.moore, e.g. 1-8 is Moore8, 0-4 is Neu5,etc) To get all 8 neighbours, use range [1,8] To get all neumann neighbours, use range [1,4]</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line833">line 833</a> </li></ul></dd> </dl> <h4 class="name" id="getGridpoint"><span class="type-signature"></span>getGridpoint<span class="signature">(xpos, ypos)</span><span class="type-signature"></span></h4> <div class="description"> Get the gridpoint at coordinates x,y Makes sure wrapping is applied if necessary </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>xpos</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>ypos</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line732">line 732</a> </li></ul></dd> </dl> <h4 class="name" id="getMoore8"><span class="type-signature"></span>getMoore8<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> getNeighbours for the Moore8 neighbourhood (range 1-8 in function getNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line873">line 873</a> </li></ul></dd> </dl> <h4 class="name" id="getMoore9"><span class="type-signature"></span>getMoore9<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> getNeighbours for the Moore8 neighbourhood (range 1-8 in function getNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line876">line 876</a> </li></ul></dd> </dl> <h4 class="name" id="getNeighXY"><span class="type-signature"></span>getNeighXY<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Get the x,y coordinates of a neighbour in an array. Makes sure wrapping is applied if necessary </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line801">line 801</a> </li></ul></dd> </dl> <h4 class="name" id="getNeighbour"><span class="type-signature"></span>getNeighbour<span class="signature">(grid, col, row, direction)</span><span class="type-signature"></span></h4> <div class="description"> Get a neighbour at compass direction </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>grid</code></td> <td class="type"> <span class="param-type">GridModel</span> </td> <td class="description last">The gridmodel used to check neighbours. Usually the gridmodel itself (i.e., this), but can be mixed to make grids interact.</td> </tr> <tr> <td class="name"><code>col</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>row</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>direction</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">the neighbour to return</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line818">line 818</a> </li></ul></dd> </dl> <h4 class="name" id="getNeighbours"><span class="type-signature"></span>getNeighbours<span class="signature">(grid, col, row, property, val, range)</span><span class="type-signature"> &rarr; {int}</span></h4> <div class="description"> Get array of grid points with val in property (Neu4, Neu5, Moore8, Moore9 depending on range-array) </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>grid</code></td> <td class="type"> <span class="param-type">GridModel</span> </td> <td class="description last">The gridmodel used to check neighbours. Usually the gridmodel itself (i.e., this), but can be mixed to make grids interact.</td> </tr> <tr> <td class="name"><code>col</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (column) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>row</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">position (row) for the focal gridpoint</td> </tr> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">the property that is counted</td> </tr> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">value 'property' should have</td> </tr> <tr> <td class="name"><code>range</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">which section of the neighbourhood must be counted? (see this.moore, e.g. 1-8 is Moore8, 0-4 is Neu5,etc)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line860">line 860</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of grid points with "property" set to "val" Below, 4 version of this functions are overloaded (Moore8, Moore9, Neumann4, etc.) If one wants to count all the "cheater" surrounding a gridpoint in cheater.js in the Moore8 neighbourhood one needs to look for value '3' in the property 'species': this.getNeighbours(this,10,10,3,'species',[1-8]); or this.getMoore8(this,10,10,3,'species') </div> <dl> <dt> Type </dt> <dd> <span class="param-type">int</span> </dd> </dl> <h4 class="name" id="getNeumann4"><span class="type-signature"></span>getNeumann4<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> getNeighbours for the Moore8 neighbourhood (range 1-8 in function getNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line879">line 879</a> </li></ul></dd> </dl> <h4 class="name" id="getNeumann5"><span class="type-signature"></span>getNeumann5<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> getNeighbours for the Moore8 neighbourhood (range 1-8 in function getNeighbours) </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line882">line 882</a> </li></ul></dd> </dl> <h4 class="name" id="getODEstates"><span class="type-signature"></span>getODEstates<span class="signature">(property, values)</span><span class="type-signature"></span></h4> <div class="description"> Returns an array with the population sizes of different types </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Return popsizes for this property (needs to exist in your model, e.g. "species" or "alive")</td> </tr> <tr> <td class="name"><code>values</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Which values are counted and returned (e.g. [1,3,4,6])</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1397">line 1397</a> </li></ul></dd> </dl> <h4 class="name" id="getPopsizes"><span class="type-signature"></span>getPopsizes<span class="signature">(property, values)</span><span class="type-signature"></span></h4> <div class="description"> Returns an array with the population sizes of different types </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>property</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Return popsizes for this property (needs to exist in your model, e.g. "species" or "alive")</td> </tr> <tr> <td class="name"><code>values</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Which values are counted and returned (e.g. [1,3,4,6])</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line1381">line 1381</a> </li></ul></dd> </dl> <h4 class="name" id="grid_from_json"><span class="type-signature"></span>grid_from_json<span class="signature">(gridjson)</span><span class="type-signature"></span></h4> <div class="description"> Loads a JSON object onto this gridmodel. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>gridjson</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">JSON object to build new grid from</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="cacatoo.js.html">cacatoo.js</a>, <a href="cacatoo.js.html#line465">line 465</a> </li></ul></dd> </dl> <h4 class="name" id="load_grid"><span class="type-signature"></span>load_grid<span class="signature">(file)</span><span class="type-signature"></span></h4> <div class="description"> Reads a JSON file and loads a JSON object onto this gridmodel. Reading a local JSON file will not work in browser mode because of security reasons, You can instead use 'addCheckpointButton' instead, which allows you to select a file from the browser manually. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="nam