xxxxxxxxxx
28
const columns = 120,
rows = 100,
squareSide = 5;
let grid,
ant,
steps,
currentStep,
stepsIndicator;
function setup() {
createCanvas(columns * squareSide, rows * squareSide);
grid = new Grid(columns, rows, squareSide);
ant = new Ant(grid, Math.floor(columns / 2), Math.floor(rows / 2), 1);
steps = 20;
currentStep = 0;
stepsIndicator = createP("");
stepsIndicator.addClass("indicator");
}
function draw() {
currentStep += steps;
for (let n = 0; n < steps; n++) {
ant.applyRules();
}
grid.show();
ant.show();
stepsIndicator.html("Step <strong>" + currentStep + "</strong>");
}