xxxxxxxxxx
/*
----- Coding Tutorial by Patt Vira -----
Name: Slime Molds (Physarum)
Video Tutorial: https://youtu.be/VyXxSNcgDtg
References:
1. Algorithm by Jeff Jones: https://uwe-repository.worktribe.com/output/980579/characteristics-of-pattern-formation-and-evolution-in-approximations-of-physarum-transport-networks
Connect with Patt: @pattvira
https://www.pattvira.com/
----------------------------------------
*/
let molds = []; let num = 4000;
let d;
function setup() {
createCanvas(windowWidth, windowHeight);
angleMode(DEGREES);
d = pixelDensity();
for (let i=0; i<num; i++) {
molds[i] = new Mold();
}
describe('This sketch simulates behaviors of slime molds. Each slime mold object has position (x and y), traveling direction (r and heading angle) and sensor (in 3 directions: front, left, and forward). As a slime mold moves through the trail, it leaves a trace and the trail map is updated. In each simulation step, a slime mold senses the trail map (the pixel color value) and decides which direction to move and rotate.', LABEL);
}
function draw() {
background(0, 5);
loadPixels();
for (let i=0; i<num; i++) {
molds[i].update();
molds[i].display();
}
}