Skip to content

Commit 5457474

Browse files
committed
fixed bug: certain mutations caused negative mass
1 parent 6cb493b commit 5457474

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fish.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Fish(mass, x, y, hue)
1414
{
1515
// fish's properties
1616
this.ID = Fish.uid();
17-
this.mass = mass;
17+
this.mass = mass > 0 ? mass : -mass;
1818
this.energy = this.mass * ENERGY;
1919
this.maxspeed = MAX_SPEED * this.mass;
2020
this.maxforce = MAX_FORCE / (this.mass * this.mass);
@@ -181,7 +181,7 @@ Fish.prototype = {
181181
var affinity = this.affinity(fishList);
182182

183183
// shoal with fishes of very different colors won't stay together as tightly as shoals of fishes of the same color
184-
separation.mul(1.4 * affinity);
184+
separation.mul(1.2);
185185
alignment.mul(1.2 * affinity);
186186
cohesion.mul(1 * affinity);
187187

0 commit comments

Comments
 (0)