Grid events are functions that can be called before or after updating the grid points. For example, after individuals have reproduced, you may want to
apply some random mixing by using the Toffoli-Margolus diffusion algorithm:
Other available "mixing" functions are:
Or you can define your own functions, for example a bottleneck where a fraction of the population dies:
this.MargolusDiffusion()
Other available "mixing" functions are:
this.perfectMix()
this.diffuseStates(state,rate)
this.diffuseODEstates() // Uses diffusion rates as defined in ODE system
Custom events
Or you can define your own functions, for example a bottleneck where a fraction of the population dies:
sim.model.bottleneck = function(fraction){
for (let i = 0; i < this.nc; i++) {
for (let j = 0; j < this.nr; j++) {
if(this.rng.genrand_real1() < fraction){
this.grid[i][j].alive = 0
this.grid[i][j].helping_rate = 0
}
}
}
}
for (let j = 0; j < this.nr; j++) {
}
if(this.rng.genrand_real1() < fraction){
} this.grid[i][j].alive = 0
this.grid[i][j].helping_rate = 0
}
sim.model.update = function() {
sim.model.synchronous()
if(sim.time%100==0) sim.model.bottleneck(0.95)
}
if(sim.time%100==0) sim.model.bottleneck(0.95)