Frame 1
function Creature() {
this.id;
this.name = "";
this.xpos = 0;
this.ypos = 0;
this.vel = 0;
this.dir = Math.round(Math.random() * 360);
var rd = Math.round((Math.random() * 1000) / 4);
var gr = Math.round((Math.random() * 1000) / 4);
var bl = Math.round((Math.random() * 1000) / 4);
var red = rd.toString(16);
var green = gr.toString(16);
var blue = bl.toString(16);
var notfin = true;
while (notfin) {
if (red.length < 2) {
red = "0" + red;
} else if (green.length < 2) {
green = "0" + green;
} else if (blue.length < 2) {
blue = "0" + blue;
} else {
notfin = false;
}
}
this.splitrt = Math.round(Math.random() * 99);
this.hexcol = (("0x" + red) + green) + blue;
this.fillcol = parseInt(this.hexcol);
this.body = Math.ceil(((Math.random() * 9) + 1) / 2);
this.eyes = Math.ceil(((Math.random() * 9) + 1) / 2);
this.metab = Math.round((Math.random() * 9) + 1);
this.health = 10;
this.alive = true;
this.dna = ((("" + this.metab) + this.eyes) + this.body) + this.hexcol;
}
function Cell() {
this.foodlvl = MAXFOOD;
}
function Dish() {
this.petri = new Array(UNITSW);
var addone;
var tcr;
var i = 0;
while (i < UNITSW) {
this.petri[i] = new Array(UNITSH);
var j = 0;
while (j < UNITSH) {
this.petri[i][j] = new Cell();
addone = Math.round(Math.random() * 100);
if (addone <= SPRAY) {
tcr = new Creature();
tcr.xpos = (i * UNITW) + XBNDMN;
tcr.ypos = (j * UNITH) + YBNDMN;
creatureList.push(tcr);
}
j++;
}
i++;
}
crpop = creatureList.length;
}
function initDispDish() {
var instName;
var lvl;
var i = 0;
while (i < UNITSW) {
var j = 0;
while (j < UNITSH) {
lvl = (10000 + (100 * i)) + j;
instName = "food" + lvl;
this.attachMovie("food", instName, lvl);
instName = eval (instName);
instName._x = (i * UNITW) + XBNDMN;
instName._y = (j * UNITH) + YBNDMN;
instName._width = UNITW;
instName._height = UNITH;
j++;
}
i++;
}
}
function clearFood() {
var instName;
var i = 0;
while (i < UNITSW) {
var j = 0;
while (j < UNITSH) {
instName = "food" + ((10000 + (100 * i)) + j);
instName = eval (instName);
instName.removeMovieClip();
j++;
}
i++;
}
}
function cleanCList() {
var tlst = new Array();
var count = 0;
var iter = 0;
while ((count < crpop) && (iter < creatureList.length)) {
if (creatureList[iter].alive) {
count++;
tlst.push(creatureList[iter]);
}
iter++;
}
creatureList = tlst;
}
function updateCList() {
crpop = 0;
var iterations = creatureList.length;
var i = 0;
while (i < iterations) {
if (creatureList[i].alive) {
creatureList[i].moveAround();
creatureList[i].eat();
crpop++;
} else {
creatureList[i].id.removeMovieClip();
}
i++;
}
if (crpop < MAXPOP) {
var instName;
var inststr;
var lvl;
iterations = creatureList.length;
var i = 0;
while (i < iterations) {
if (creatureList[i].alive) {
if (((Math.random() * 100) < creatureList[i].splitrt) && (creatureList[i].health == (MXHLTH * 0.9))) {
creatureList.push(creatureList[i].splitCr());
creatureList[i].health = Math.round(creatureList[i].health / 2);
lvl = creatureList.length + 20000;
inststr = "critter" + lvl;
instName = eval (inststr);
this.attachMovie("bugholder", inststr, lvl, creatureList[i]);
instName = eval (inststr);
creatureList[i].id = instName;
instName._x = creatureList[i].xpos;
instName._y = creatureList[i].ypos;
instName._rotation = creatureList[i].dir;
instName._xscale = (MXSCL * creatureList[i].health) / MXHLTH;
instName._yscale = (MXSCL * creatureList[i].health) / MXHLTH;
instName.displayCreature(creatureList[i]);
crpop++;
}
}
i++;
}
}
}
function initDispCList() {
var lvl;
var instName;
var inststr;
var iterations = creatureList.length;
var i = 0;
while (i < iterations) {
if (creatureList[i].alive) {
lvl = i + 20000;
inststr = "critter" + lvl;
instName = eval (inststr);
this.attachMovie("bugholder", inststr, lvl, creatureList[i]);
instName = eval (inststr);
creatureList[i].id = instName;
instName._x = creatureList[i].xpos;
instName._y = creatureList[i].ypos;
instName._rotation = creatureList[i].dir;
instName._xscale = (MXSCL * creatureList[i].health) / MXHLTH;
instName._yscale = (MXSCL * creatureList[i].health) / MXHLTH;
instName.displayCreature(creatureList[i]);
} else {
lvl = i + 20000;
inststr = "critter" + lvl;
instName = eval (inststr);
instName.removeMovieClip();
}
i++;
}
}
function dispCList() {
var instName;
var iterations = creatureList.length;
var i = 0;
while (i < iterations) {
if (creatureList[i].alive) {
instName = "critter" + (i + 20000);
instName = eval (instName);
instName._x = creatureList[i].xpos;
instName._y = creatureList[i].ypos;
instName._xscale = (MXSCL * creatureList[i].health) / MXHLTH;
instName._yscale = (MXSCL * creatureList[i].health) / MXHLTH;
instName._rotation = creatureList[i].dir;
}
i++;
}
}
function clearCreatures() {
var instName;
var iterations = creatureList.length;
var i = 0;
while (i < iterations) {
instName = "critter" + (i + 20000);
instName = eval (instName);
instName.removeMovieClip();
i++;
}
}
function setupSliders() {
function setMutation(num) {
MUTATE = Math.round(num);
interf.tmut.text = MUTATE;
}
function setMaxFood(num) {
MAXFOOD = Math.round(num);
interf.tmaxf.text = MAXFOOD;
}
function setRefood(num) {
REFOOD = Math.round(num);
interf.tfrr.text = REFOOD;
}
function setMaxPop(num) {
MAXPOP = Math.round(num * 5);
interf.tmaxp.text = MAXPOP;
}
function setMaxHealth(num) {
MXHLTH = Math.round(num);
interf.tmaxh.text = MXHLTH;
}
function setSca(num) {
MXSCL = Math.round(num * 2);
interf.tsca.text = MXSCL;
}
interf.mut.handle._x = MUTATE;
setMutation(MUTATE);
interf.mut.onPress = function () {
this.handle.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function () {
setMutation(this.handle._x);
updateAfterEvent();
};
};
interf.mut.onRelease = function () {
this.handle.stopDrag();
setMutation(this.handle._x);
updateAfterEvent();
this.onMouseMove = function () {
};
};
interf.maxf.handle._x = MAXFOOD;
setMaxFood(MAXFOOD);
interf.maxf.onPress = function () {
this.handle.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function () {
setMaxFood(this.handle._x);
updateAfterEvent();
};
};
interf.maxf.onRelease = function () {
this.handle.stopDrag();
setMaxFood(this.handle._x);
updateAfterEvent();
this.onMouseMove = function () {
};
};
interf.frr.handle._x = REFOOD;
setReFood(REFOOD);
interf.frr.onPress = function () {
this.handle.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function () {
setRefood(this.handle._x);
updateAfterEvent();
};
};
interf.frr.onRelease = function () {
this.handle.stopDrag();
setRefood(this.handle._x);
updateAfterEvent();
this.onMouseMove = function () {
};
};
interf.maxp.handle._x = MAXPOP / 5;
setMaxPop(Math.round(MAXPOP / 5));
interf.maxp.onPress = function () {
this.handle.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function () {
setMaxPop(this.handle._x);
updateAfterEvent();
};
};
interf.maxp.onRelease = function () {
this.handle.stopDrag();
setMaxPop(this.handle._x);
updateAfterEvent();
this.onMouseMove = function () {
};
};
interf.maxh.handle._x = MXHLTH;
setMaxHealth(MXHLTH);
interf.maxh.onPress = function () {
this.handle.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function () {
setMaxHealth(this.handle._x);
updateAfterEvent();
};
};
interf.maxh.onRelease = function () {
this.handle.stopDrag();
setMaxHealth(this.handle._x);
updateAfterEvent();
this.onMouseMove = function () {
};
};
interf.sca.handle._x = MXSCL / 2;
setSca(MXSCL / 2);
interf.sca.onPress = function () {
this.handle.startDrag(true, 0, 0, 100, 0);
this.onMouseMove = function () {
setSca(this.handle._x);
updateAfterEvent();
};
};
interf.sca.onRelease = function () {
this.handle.stopDrag();
setSca(this.handle._x);
updateAfterEvent();
this.onMouseMove = function () {
};
};
}
function plbutt() {
mode = "playing";
remInterActive();
this.gotoAndStop("down");
interf.gotoAndStop("running");
interf.pauseButt.onRelease = function () {
psButt();
};
this.onRelease = function () {
};
}
function psButt() {
mode = "paused";
makeInterActive();
this.gotoAndStop("down");
interf.gotoAndStop("paused");
setupSliders();
interf.playButt.onRelease = function () {
plButt();
};
this.onRelease = function () {
};
}
function remInterActive() {
var i = 0;
while (i < creatureList.length) {
creatureList[i].id.onRelease = function () {
};
i++;
}
}
function makeInterActive() {
var dn;
var me;
var he;
var sp;
var i = 0;
while (i < creatureList.length) {
dn = creatureList[i].dna;
me = creatureList[i].metab;
he = creatureList[i].health;
sp = creatureList[i].splitrt;
creatureList[i].id.onRelease = function () {
interf.d.text = "";
interf.m.text = "";
interf.h.text = "";
interf.s.text = "";
interf.d.text = dn;
interf.m.text = me;
interf.h.text = he;
interf.s.text = sp;
};
i++;
}
}
function updater() {
if (mode != "paused") {
if ((creatureList.length > MAXPOP) || (cpop < (creatureList.length * 0.9))) {
clearCreatures();
cleanCList();
initDispClist();
}
updateCList();
petriDish.replenish();
}
}
function animate() {
if (mode != paused) {
interf.pop.text = crpop;
dispClist();
petriDish.dispDish();
updateAfterEvent();
}
}
MOVLOC = this;
XBNDMN = 25;
XBNDMX = 325;
YBNDMN = 25;
YBNDMX = 325;
UNITSW = 25;
UNITSH = 25;
UNITW = (XBNDMX - XBNDMN) / UNITSW;
UNITH = (YBNDMX - YBNDMN) / UNITSH;
SPRAY = 50;
MUTATE = 10;
MAXFOOD = 4;
REFOOD = 50;
MAXPOP = 500;
MXHLTH = 50;
MXSCL = 100;
Creature.prototype.moveAround = function () {
this.dir = this.dir + Math.round((Math.random() * 30) - 15);
this.vel = this.vel + Math.round(((Math.random() * 2) - 1) * this.metab);
if (this.vel < 0) {
this.vel = 0;
} else if (this.vel > 10) {
this.vel = 10;
}
this.xpos = this.xpos + Math.round(this.vel * Math.cos((this.dir * Math.PI) / 180));
this.ypos = this.ypos + Math.round(this.vel * Math.sin((this.dir * Math.PI) / 180));
if (this.xpos > XBNDMX) {
this.xpos = XBNDMN;
} else if (this.xpos < XBNDMN) {
this.xpos = XBNDMX;
}
if (this.ypos > YBNDMX) {
this.ypos = YBNDMN;
} else if (this.ypos < YBNDMN) {
this.ypos = YBNDMX;
}
};
Creature.prototype.eat = function () {
var amt = petriDish.petri[Math.floor((this.xpos - XBNDMN) / UNITW)][Math.floor((this.ypos - YBNDMN) / UNITH)].foodlvl;
amt = amt - this.metab;
if (amt < 0) {
this.health = this.health + amt;
if (this.health <= 0) {
this.alive = false;
}
petriDish.petri[Math.floor((this.xpos - XBNDMN) / UNITW)][Math.floor((this.ypos - YBNDMN) / UNITH)].foodlvl = 0;
} else {
petriDish.petri[Math.floor((this.xpos - XBNDMN) / UNITW)][Math.floor((this.ypos - YBNDMN) / UNITH)].foodlvl = amt;
this.health++;
if (this.health > MXHLTH) {
this.health = MXHLTH;
}
}
};
Creature.prototype.splitCr = function () {
var tcr = new Creature();
tcr.xpos = this.xpos;
tcr.ypos = this.ypos;
tcr.dir = this.dir + 180;
tcr.vel = this.vel;
tcr.fillcol = tcr.fillcol + Math.round((((Math.random() * this.fillcol) * MUTATE) / 100) - ((this.fillcol * MUTATE) / 200));
tcr.hexcol = tcr.fillcol.toString(16);
while (tcr.hexcol.length < 6) {
tcr.hexcol = "0" + tcr.hexcol;
}
tcr.hexcol = "0x" + tcr.hexcol;
tcr.splitrt = tcr.splitrt + Math.round((((Math.random() * this.splitrt) * MUTATE) / 100) - ((this.splitrt * MUTATE) / 200));
tcr.body = tcr.body + Math.round((((Math.random() * this.body) * MUTATE) / 100) - ((this.body * MUTATE) / 200));
tcr.eyes = tcr.eyes + Math.round((((Math.random() * this.eyes) * MUTATE) / 100) - ((this.eyes * MUTATE) / 200));
tcr.metab = tcr.metab + Math.round((((Math.random() * this.metab) * MUTATE) / 100) - ((this.metab * MUTATE) / 200));
tcr.health = Math.round(this.health / 2);
if (tcr.splitrt > 99) {
tcr.splitrt = 99;
} else if (tcr.splitrt < 0) {
tcr.splitrt = 0;
}
if (tcr.fillcol > 16777215) {
tcr.fillcol = 16777215 /* 0xFFFFFF */;
} else if (tcr.fillcol < 0) {
tcr.fillcol = 0;
}
if (tcr.body > 10) {
tcr.body = 10;
} else if (tcr.body < 0) {
tcr.body = 1;
}
if (tcr.eyes > 10) {
tcr.eyes = 10;
} else if (tcr.eyes < 0) {
tcr.eyes = 1;
}
tcr.dna = ((("" + tcr.metab) + tcr.eyes) + tcr.body) + tcr.hexcol;
return(tcr);
};
MovieClip.prototype.setPos = function (xpos, ypos) {
this._x = xpos;
this._y = ypos;
};
MovieClip.prototype.setScale = function (scl) {
this._xscale = scl;
this._yscale = scl;
};
MovieClip.prototype.displayCreature = function (creat) {
this.attachMovie("body" + creat.body, "shape", 1);
this.attachMovie("eyes" + creat.eyes, "look", 2);
this.bcol = new Color(this.shape.fill);
this.bcol.setRGB(creat.hexcol);
};
Dish.prototype.replenish = function () {
if ((Math.random() * 100) < REFOOD) {
var i = 0;
while (i < UNITSW) {
var j = 0;
while (j < UNITSH) {
this.petri[i][j].foodlvl++;
if (this.petri[i][j].foodlvl > MAXFOOD) {
this.petri[i][j].foodlvl = MAXFOOD;
}
j++;
}
i++;
}
}
};
Dish.prototype.dispDish = function () {
var instName;
var i = 0;
while (i < UNITSW) {
var j = 0;
while (j < UNITSH) {
instName = "food" + ((10000 + (100 * i)) + j);
instName = eval (instName);
instName.gotoAndStop(Math.round((this.petri[i][j].foodlvl / MAXFOOD) * 50));
j++;
}
i++;
}
};
this.attachMovie("panel", "interf", 30000);
interf.playButt.onRelease = function () {
plButt();
};
interf.pauseButt.onRelease = function () {
};
setupSliders();
interf.playbutt.gotoAndStop("up");
interf.pausebutt.gotoAndStop("down");
crpop = 0;
creatureList = new Array();
interf.setPos(250, 175);
petriDish = new Dish();
initDispDish();
initDispClist();
mode = "paused";
makeInterActive();
setInterval(animate, 1);
setInterval(updater, 1);
Symbol 43 MovieClip [food] Frame 50
stop();
Symbol 47 MovieClip Frame 1
stop();
Symbol 47 MovieClip Frame 2
stop();
Symbol 91 MovieClip [panel] Frame 1
stop();
tdlink.onRollOver = function () {
this.gotoAndStop("over");
};
tdlink.onRollOut = function () {
this.play();
};
tdlink.onRelease = function () {
getURL ("http://taldarian.com", "_blank");
};
Instance of Symbol 47 MovieClip in Symbol 91 MovieClip [panel] Frame 1
onClipEvent (load) {
this.gotoAndStop("down");
}
Symbol 91 MovieClip [panel] Frame 2
stop();
Instance of Symbol 47 MovieClip in Symbol 91 MovieClip [panel] Frame 2
onClipEvent (load) {
this.gotoAndStop("down");
}