}
}
- 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);
}
running = 0;
});
+ $('#controls #reseed-automaton').click(function(e){
+ 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;
+ });
+
$('#2d-automaton').click(function(e) {
if (!running) {
var x = e.pageX - $('#2d-automaton').offset().left;