UNPKG

cacatoo

Version:

Building, exploring, and sharing spatially structured models

4,388 lines (975 loc) 49.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Gridmodel</title> <link rel="icon" type="image/png" href="images/favicon.png" /> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <script src="scripts/jquery.js"></script> <script> $(function(){ $("#Navigator").load("navigator.html"); }); </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 (currently only) 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#line370">line 370</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <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#line582">line 582</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#line545">line 545</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#line567">line 567</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#line998">line 998</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#line454">line 454</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) </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#line496">line 496</a> </li></ul></dd> </dl> <h4 class="name" id="countMoore8"><span class="type-signature"></span>countMoore8<span class="signature">(grid, col, row, val, property)</span><span class="type-signature"></span></h4> <div class="description"> Count the number of grid points in the Moore (8) neighbourhood which have a certain value (val) for a certain 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>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>val</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">what value should the GP have to be counted</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 For example, if one wants to count all the "cheater" surrounding a gridpoint in cheater.js, one needs to look for value '3' in the property 'species': this.countMoore8(this,10,10,3,'species');</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#line669">line 669</a> </li></ul></dd> </dl> <h4 class="name" id="countMoore9"><span class="type-signature"></span>countMoore9<span class="signature">(grid, col, row, val, property)</span><span class="type-signature"></span></h4> <div class="description"> Count the number of grid points in the Moore (9) neighbourhood which have a certain value (val) for a certain 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>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>val</code></td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">what value should the GP have to be counted</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 For example, if one wants to count all the "cheater" surrounding a gridpoint in cheater.js, one needs to look for value '3' in the property 'species': this.countMoore9(this,10,10,3,'species');</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#line634">line 634</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#line759">line 759</a> </li></ul></dd> </dl> <h4 class="name" id="getGridpoint"><span class="type-signature"></span>getGridpoint<span class="signature">(i, j)</span><span class="type-signature"></span></h4> <div class="description"> Get the gridpoint at coordinates i,j 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>i</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>j</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#line716">line 716</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#line745">line 745</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#line977">line 977</a> </li></ul></dd> </dl> <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#line820">line 820</a> </li></ul></dd> </dl> <h4 class="name" id="nextState"><span class="type-signature"></span>nextState<span class="signature">(i, j)</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>i</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>j</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#line513">line 513</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) 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#line801">line 801</a> </li></ul></dd> </dl> <h4 class="name" id="plotArray"><span class="type-signature"></span>plotArray<span class="signature">(graph_labels, graph_values, cols, title, opts)</span><span class="type-signature"></span></h4> <div class="description"> Adds a dygraph-plot to your DOM (if the DOM is loaded) </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>graph_labels</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of strings for the graph legend</td> </tr> <tr> <td class="name"><code>graph_values</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of floats to plot (here plotted over time)</td> </tr> <tr> <td class="name"><code>cols</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of colours to use for plotting</td> </tr> <tr> <td class="name"><code>title</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Title of the plot</td> </tr> <tr> <td class="name"><code>opts</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">dictionary-style list of opts to pass onto dygraphs</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#line877">line 877</a> </li></ul></dd> </dl> <h4 class="name" id="plotPopsizes"><span class="type-signature"></span>plotPopsizes<span class="signature">(property, values)</span><span class="type-signature"></span></h4> <div class="description"> Easy function to add a pop-sizes plot (wrapper for plotArrays) </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">What property to plot (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 plotted (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#line937">line 937</a> </li></ul></dd> </dl> <h4 class="name" id="plotXY"><span class="type-signature"></span>plotXY<span class="signature">(graph_labels, graph_values, cols, title, opts)</span><span class="type-signature"></span></h4> <div class="description"> Adds a dygraph-plot to your DOM (if the DOM is loaded) </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>graph_labels</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of strings for the graph legend</td> </tr> <tr> <td class="name"><code>graph_values</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of 2 floats to plot (first value for x-axis, second value for y-axis)</td> </tr> <tr> <td class="name"><code>cols</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last">Array of colours to use for plotting</td> </tr> <tr> <td class="name"><code>title</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Title of the plot</td> </tr> <tr> <td class="name"><code>opts</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">dictionary-style list of opts to pass onto dygraphs</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#line910">line 910</a> </li></ul></dd> </dl> <h4 class="name" id="printGrid"><span class="type-signature"></span>printGrid<span class="signature">(property, fract)</span><span class="type-signature"></span></h4> <div class="description"> Print the entire grid to the console. Not always recommended, but useful for debugging :D </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">float</span> </td> <td class="description last">What property is printed</td> </tr> <tr> <td class="name"><code>fract</code></td> <td class="type"> <span class="param-type">float</span> </td> <td class="description last">Subset to be printed (from the top-left)</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#line1036">line 1036</a> </li></ul></dd> </dl> <h4 class="name" id="printgrid"><span class="type-signature"></span>printgrid<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Print the entire grid to the console </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#line503">line 503</a> </li></ul></dd> </dl> <h4 class="name" id="randomMoore8"><span class="type-signature"></span>randomMoore8<span class="signature">(grid, col, row)</span><span class="type-signature"></span></h4> <div class="description"> Return a random neighbour from the Moore (8) neighbourhood </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> </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#line683">line 683</a> </li></ul></dd> </dl> <h4 class="name" id="randomMoore9"><span class="type-signature"></span>randomMoore9<span class="signature">(grid, col, row)</span><span class="type-signature"></span></h4> <div class="description"> Return a random neighbour from the Moore (9) neighbourhood (self inclusive) </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> </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#line699">line 699</a> </li></ul></dd> </dl> <h4 class="name" id="set_update_order"><span class="type-signature"></span>set_update_order<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> If called for the first time, make an update order (list of ints), otherwise just shuffle it. </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#line595">line 595</a> </li></ul></dd> </dl> <h4 class="name" id="setGridpoint"><span class="type-signature"></span>setGridpoint<span class="signature">(i, j, @Gridpoint)</span><span class="type-signature"></span></h4> <div class="description"> Change the gridpoint at position i,j 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>i</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>j</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#line732">line 732</a> </li></ul></dd> </dl> <h4 class="name" id="setupColours"><span class="type-signature"></span>setupColours<span class="signature">(object)</span><span class="type-signature"></span></h4> <div class="description"> Initiate a dictionary with colour arrays [R,G,B] used by Graph and Canvas classes </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>object</code></td> <td class="type"> <span class="param-type">statecols</span> </td> <td class="description last">given object can be in two forms | either {state:colour} tuple (e.g. 'alive':'white', see gol.html) | or {state:object} where objects are {val:'colour}, | e.g. {'species':{0:"black", 1:"#DDDDDD", 2:"red"}}, see cheater.html</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#line416">line 416</a> </li></ul></dd> </dl> <h4 class="name" id="solve_all_odes"><span class="type-signature"></span>solve_all_odes<span class="signature">(delta_t, opt_pos)</span><span class="type-signature"></span></h4> <div class="description"> Numerically solve the ODEs for each grid point </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>delta_t</code></td> <td class="type"> <span class="param-type">float</span> </td> <td class="default"> 0.1 </td> <td class="description last">Step size</td> </tr> <tr> <td class="name"><code>opt_pos</code></td> <td class="type"> <span class="param-type">bool</span> </td> <td class="default"> false </td> <td class="description last">When enabled, negative values are set to 0 automatically</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#line1017">line 1017</a> </li></ul></dd> </dl> <h4 class="name" id="synchronous"><span class="type-signature"></span>synchronous<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Synchronously apply the nextState function (defined by user) to the entire grid Synchronous means that all grid points will be updated simultaneously. This is ensured by making a back-up grid, which will serve as a reference to know the state in the previous time step. First all grid points are updated based on the back-up. Only then will the actual grid be changed. </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#line523">line 523</a> </li></ul></dd> </dl> <h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> The update is, like nextState, user-defined (hence, empty by default). It should contains all functions that one wants to apply every time step (e.g. grid manipulations and printing statistics) For example, and update function could look like: this.synchronous() // Update all cells this.MargolusDiffusion() // Apply Toffoli Margolus diffusion algorithm this.plotPopsizes('species',[1,2,3]) // Plot the population sizes </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#line616">line 616</a> </li></ul></dd> </dl> </article> </section> </div> <div id="Navigator"></div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Wed Jul 28 2021 15:33:33 GMT+0200 (Central European Summer Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>