Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Brain.pde
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class Brain {
float heartbeatStrength = 10;
float heartbeatInterval = 0.1;
float timesUsed = 0;
float[][] neurons;
Axon[][][] axons;
int BRAIN_WIDTH = 0;
Expand Down Expand Up @@ -86,10 +89,16 @@ class Brain {
public void useBrain(Creature owner){
ArrayList<Node> n = owner.n;
ArrayList<Muscle> m = owner.m;
for(int i = 0; i < n.size(); i++){
Node ni = n.get(i);

for(int i = 1; i < n.size(); i++){
Node ni = n.get(i - 1);
neurons[0][i] = dist(ni.x, ni.y, ni.z, foodX, foodY, foodZ);
}

neurons[0][0] = ((sin(timesUsed) / 2) + 0.5) * heartbeatStrength;

timesUsed += heartbeatInterval;

for(int i = 0; i < m.size(); i++){
Muscle am = m.get(i);
Node ni1 = n.get(am.c1);
Expand Down
2 changes: 1 addition & 1 deletion Creature.pde
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Creature {
}
}
int getBrainHeight(){
return n.size()+m.size()+1;
return n.size()+m.size()+2;
}
void changeBrainStructure(int rowInsertionIndex, int rowRemovalIndex){
brain.changeBrainStructure(BRAIN_WIDTH, getBrainHeight(), rowInsertionIndex,rowRemovalIndex);
Expand Down