UNPKG

cacatoo

Version:

Building, exploring, and sharing spatially structured models

4,623 lines (930 loc) 88.7 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#line353">line 353</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#line1113">line 1113</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#line672">line 672</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#line641">line 641</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#line660">line 660</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#line1367">line 1367</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#line395">line 395</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#line568">line 568</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#line530">line 530</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#line595">line 595</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#line741">line 741</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#line759">line 759</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#line924">line 924</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#line927">line 927</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#line912">line 912</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#line930">line 930</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#line933">line 933</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#line1055">line 1055</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#line1007">line 1007</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#line976">line 976</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#line711">line 711</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#line827">line 827</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#line830">line 830</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#line775">line 775</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#line792">line 792</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#line814">line 814</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#line833">line 833</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#line836">line 836</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#line1351">line 1351</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#line1335">line 1335</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#line460">line 460</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="name"><code>file</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Path to the json file</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#line437">line 437</a> </li></ul></dd> </dl> <h4 class="name" id="nextState"><span class="type-signature"></span>nextState<span class="signature">(x, y)</span><span class="type-signature"></span></h4> <div class="description"> The most important function in GridModel: how to determine the next state of a gridpoint? By default, nextState is empty. It should be defined by the user (see examples) </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 of grid point to update (column)</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 of grid point to update (row)</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#line612">line 612</a> </li></ul></dd> </dl> <h4 class="name" id="perfectMix"><span class="type-signature"></span>perfectMix<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Assign each gridpoint a new random position on the grid. This simulated mixing, but does not guarantee a "well-mixed" system per se (interactions are still local) calculated based on neighbourhoods. </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#line1095">line 1095</a> </li></ul></dd> </dl> <h4 class="name" id="plotArray"><span class="type-signature"></span>plotArray<span class="sig