Populating a grid
Initialising the model itself
Initialise the grid points with numbers
initialiseGrid(@Gridmodel, statename, 1st_number, 1st_fraction, 2nd_number, 2nd_fraction, ...)
ORinitialSpot(@Gridmodel, statename, number, spotsize, x, y)
Use cases:
- In cheater.html: set species '1', '2', and '3', to 33% occupancy each
sim.initialGrid(sim.cheater, 'species', 1, 0.33, 2, 0.33, 3, 0.33) - In petridish.html: inoculate the middle of the grid with 'alive' cells
sim.initialSpot(sim.cells, 'alive', 1, 2, sim.cells.nr / 2, sim.cells.nc / 2) - In tutorial_colony.html: give 100% of grid points external resources (set to 1)
sim.initialGrid(sim.growth,'external_resources',1000.0,1.0)
Populating the grid points with custom individuals
First, define your individual(s):
let individuals = [{alive:1, age:1, name: 'Cacatoo'},{alive:1, age:20, name: 'Cash'}]
populateGrid(@Gridmodel, individuals, frequencies)
ORpopulateSpot(@Gridmodel, individuals, frequencies, size, x, y)
Use cases:
- In cooperation.html: populate with 'cooperators' and 'cheaters'
let init_individuals = [{alive:1, helping_rate: helper_rate_cooperator}, {alive:1,helping_rate: helper_rate_cheater}]
sim.populateSpot(sim.coop, init_individuals, [0.5,0.5], 100, config.ncol/2, config.nrow/2) - In tutorial_colony.html: populate with species with different uptake rates
let species = [{species:1,uptake_rate:0.5,internal_resources:1}, {species:2,uptake_rate:5.0,internal_resources:1}, {species:3,uptake_rate:50.0,internal_resources:1}]
sim.populateSpot(sim.growth, species, [0.33,0.33,0.33], 15, config.ncol/2, config.nrow/2)
Manually setting the grid points
for (let i = 0; i < sim.spirals.nc; i++) // i are columns
for (let j = 0; j < sim.spirals.nr; j++) // j are rows
sim.spirals.grid[i][j]['colour'] = Math.ceil(sim.rng.genrand_real1() * n_species)
or another example from "ode_turing.html":
for (let i = 0; i < sim.turing.nc; i++) // i are columns
for (let j = 0; j < sim.turing.nr; j++) // j are rows
sim.turing.grid[i][j].turingeq.state = [1 + sim.rng.genrand_real1(), 1]
Populating a flock
Initialising the model itself
let config = { ncol:100, nrow:100, title="MyModel", ... }
sim = new Simulation(config)
let flockconfig = {num_boids: 100, width: 100, height: 200 }
sim.makeFlockmodel("modelname", flockconfig)
Default boids
If you want to initialise the boids yourself, either use 'populatespot':