xxxxxxxxxx
34
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
class Network {
constructor(x, y) {
this.location = createVector(x,y);
this.neurons = [];
}
// We can add a Neuron
addNeuron(n) {
this.neurons.push(n);
}
// We can connection two Neurons
connect(a, b) {
let c = new Connection(a, b, random(0.000000001, 1));
a.addConnection(c);
}
// We can draw the network
display() {
push();
translate(this.location.x, this.location.y);
this.neurons.forEach( n => {
n.display();
});
pop();
}
}