}
}
- function universe() {
+ function universe(blank) {
this.population = [];
this.generation = 0;
+ var blank = blank || 0;
for (var i = 0; i < rows; i++) {
var world = [];
for (var ii = 0; ii < columns; ii++) {
world.push(new cell(x, y, cellWidth, cellHeight));
x += cellWidth;
- Math.random() > .5 ? world[ii].revive() : world[ii].kill();
+ if (blank) { world[ii].kill(); }
+ else { Math.random() > .5 ? world[ii].revive() : world[ii].kill(); }
}
this.population.push(world);
}
}
}
- function tick(automaton) {
+ function tick(automaton, blank) {
automaton.generation += 1;
var universe = automaton.population;
var newUniverse = [];
if (running) clearInterval(tickID);
$('#controls #stop-automaton').hide();
$('#controls #start-automaton').show();
+ automaton = new universe();
+ running = 0;
+ });
+
+ $('#controls #custom-seed-automaton').click(function(e){
+ if (running) clearInterval(tickID);
+ $('#controls #stop-automaton').hide();
+ $('#controls #start-automaton').show();
+ automaton = new universe(1);
running = 0;
- automaton = new universe;
});
$('#2d-automaton').click(function(e) {
<br>
<span class='label'>2500 cells</span>
<br><br>
- <span id='start-automaton' class='control'>Start automaton</span>
- <span id='stop-automaton' class='control'>Stop automaton</span>
- <span id='reseed-automaton' class='control'>Reseed automaton</span>
+ <span id='start-automaton' class='control'>Start automaton</span><br>
+ <span id='stop-automaton' class='control'>Stop automaton</span><br>
+ <span class='label'>
+ Reseed <span id='reseed-automaton' class='control'>random</span>
+ or <span id='custom-seed-automaton' class='control'>blank</span>
+ </span>
</div>
</div>
<div id='1d-container'>