<!--
###########################################################################################
This is a JSFiddle example of "Cacatoo". This HTML page does not contain the code itself,
but determines where the grids, graphs, buttons, etc are placed. The real code is in the
Javascript Tab. I recommend enabling "Tabs (Columns)" under the settings in the top-right.
###########################################################################################
-->
<html>
<script src="https://bramvandijk88.github.io/cacatoo/scripts/cacatoo.js"></script>
<script src="https://bramvandijk88.github.io/cacatoo/scripts/all.js"></script> <!-- Dependencies
<link rel="stylesheet" href="style.css"> <!-- Set style sheet -->
<head>
<title>Cacatoo examples</title>
</head>
<script>
/*-------------------------End user-defined code ---------------------*/
</script>
<body onload="cacatoo()">
<div class="header" id="header">
<h2>Cacatoo (example project)</h2>
</div>
<div class="content" id="canvas_holder"> </div>
<div class="content" id="graph_holder"> </div>
<div class="content" id="form_holder"></div>
<div class="footer" id="footer"></div>
</body>
</html>
/*-----------------------Start user-defined code ---------------------*/
let sim;
var birth_rate = 0.85
var mutationrate = 0.0005;
var cell_diffusion = 0;
var death_rate_growing = 0.2;
var mutations_required = 2;
function cacatoo() {
let config = {
title: "Petridish with local growth",
description: "(mutational rescue of elevated death rate)",
maxtime: 10000000,
ncol: 300,
nrow: 300, // dimensions of the grid to build
wrap: [false, false], // Wrap boundary [COLS, ROWS]
scale: 1, // scale of the grid (nxn pixels per grid cell)
graph_interval: 10,
seed: 12,
graph_update: 20,
bgcolour: "white",
statecolours: {
alive: 'default'
} // The background state '0' is never drawn
}
sim = new Simulation(config)
sim.makeGridmodel("cells");
sim.cells.statecolours.alive[0] = [255, 255, 255] // Change bg to white
sim.cells.statecolours.alive[1] = [79, 31, 154] // Change WT 1 to white
sim.cells.statecolours.alive[2] = [228, 178, 36] // Change mutant 1 to gold
sim.cells.statecolours.alive[3] = [32, 100, 100] // Change mutant 2 to dark-turquoise
sim.cells.statecolours.alive[3] = [100, 100, 255] // Change mutant 3 to light blue
sim.createDisplay("cells", "alive", "Colony growth (colours = #mutations)")
sim.makeGridmodel("cells_wellmixed");
sim.cells_wellmixed.statecolours = sim.cells.statecolours
sim.createDisplay("cells_wellmixed", "alive", "Well-mixed population (colours = #mutations)")
sim.cells.nextState = function(x, y) // Define the next-state function. This example is stochastic growth in a petri dish
{
if (this.grid[x][y].alive == undefined) {
let neighbour = this.randomMoore8(this, x, y) // In the Moore8 neighbourhood of this grid count # of 1's for the 'alive' property
if (neighbour.alive > 0 && sim.rng.genrand_real1() < birth_rate) {
this.grid[x][y].alive = neighbour.alive
if...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.