class connection { neuron n; float strength=0; connection(neuron n) { this.n=n; strength=0; } connection(neuron n,float s) { this.n=n; strength=s; } } class signal { float amount=0; float weight=0; signal(float a,float w) { amount=a; weight=w; } } class neuron { int id; //the id tag of a neuron position p; //a temporary display position of a neuron connection input[]; //a list of inputs connection output[]; //a list of outputs float refractMax=3; //the refractory rate of a neuron float refract=0; //the current refraction float weight=random(-1,1); //the weight of a node used when calculating output float recievedWeight=0; //the recieved weight from incoming nodes float accumulated=-1; //the accumulation of signals from outputs of other cells to this cell float threshold=0; //the threshold at which, when passed, this cell will fire to its outputs float threshMax=.8; //the maximum the threshold can move up (fatigue) float threshMin=-.3; //the minimum threshold it can move down (sensitive) boolean firing=false; neuron(int id,position p) { this.id=id; input=new connection[0]; output=new connection[0]; this.p=new position(p); } void update() { if(refract>0) refract-=1; if(accumulated>threshold && refract==0 && recievedWeight!=0) { firing=true; } else { firing=false; } accumulated-=.02; accumulated=constrain(accumulated,-1,1); threshold*=.98; if(threshold<.1) threshold-=.005; threshold=constrain(threshold,threshMin,threshMax); recievedWeight=0; } void updateFire() { if(firing) { signal s=new signal(1,weight); pulse(s); refract=refractMax; threshold=threshMax; recievedWeight=0; // accumulated=threshold; } } void pulse() { signal s=new signal(.5,1); for(int i=0;i