split
this.split = function()
{
var i, maxIndex = 0, maxRadius = 0.0;
var emptySlot;
var motherBlob, newBlob;
if(this.numActive == this.maxNum)
{
return;
}
emptySlot = this.blobs.length;
for(i = 0; i < this.blobs.length; i++)
{
if(this.blobs[i] != null && this.blobs[i].getRadius() > maxRadius)
{
maxRadius = this.blobs[i].getRadius();
motherBlob = this.blobs[i];
}
else if(this.blobs[i] == null)
{
emptySlot = i;
}
}
motherBlob.scale(0.75);
newBlob = new Blob(motherBlob.getXPos(),
motherBlob.getYPos(), motherBlob.getRadius(), 8);
for(i = 0; i < this.blobs.length; i++)
{
if(this.blobs[i] == null)
{
continue;
}
this.blobs[i].addBlob(newBlob);
newBlob.addBlob(this.blobs[i]);
}
this.blobs[emptySlot] = newBlob;
this.numActive++;
}