<!--
###########################################################################################
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> -->
<table>
<tr>
<td><div class="content" id="canvas_holder"> </div></td>
<td valign="top"><div class="content" id="graph_holder"><br>
</div> </div></td>
</tr>
</table>
<div class="content" id="form_holder">
</body>
</html>
/*-----------------------Start user-defined code ---------------------*/
let sim; // Declare a variable named "sim" globally, so that we can access our cacatoo-simulation from wherever we need.
var b = 0.0
var c = 0.3
var d = 0.10
var init_density=0.1
var mengen = 0
var perfect = 0
function cacatoo() {
let config = {
title: "Growth", // The name of your cacatoo-simulation
description: " ", // And a description if you wish
maxtime: 1000000, // How many time steps the model continues to run
ncol: 120, // Number of columns (width of your grid)
nrow: 120, // Number of rows (height of your grid)
wrap: [false, false], // Wrapped boundary conditions? [COLS, ROWS]
scale: 2, // Scale of the grid (nxn pixels per grid point)
graph_update: 1,
graph_interval: 5,
sleep:0,
bgcolour: "white",
statecolours: {
'type': {
1: '#921a20',
2: '#fd9409',
3: 'blue'
}
}, // Colours for each state. Background (0) defaults to black.
}
sim = new Simulation(config)
sim.makeGridmodel("growth")
sim.mengen = 0
sim.reset = function(){
sim.initialGrid(sim.growth,"type",0,1,init_density,2,init_density,3,0.001)
sim.growth.resetPlots()
}
// sim.initialSpot(sim.growth, "heck", 1, 2, sim.config.ncol/2, sim.config.nrow/2)
sim.reset()
//sim.createDisplay("growth", "heck", "Heck runderen") // Create a display so we can see our newly made gridmodel
sim.createDisplay_discrete({
model: "growth",
property: "type",
drawdots: true,
stroke:true, strokeStyle: 'black', strokeWidth: 0.5,
radius: 2.2,
label: "Samenwerken (met <font color='blue'>parasiet</font>)"
})
sim.growth.nextState = function(i, j) {
let gp = this.grid[i][j]
if(gp.type==0) return
else{
let self = gp.type
let other = gp.type == 1 ? 2 : 1
let neigh = this.randomMoore8(this, i, j)
let numneigh = this.countMoore8(this, i, j, "type", other)
let bonus = 0.0
if(self==3) {
numneigh...
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.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
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!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.