!function(t){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=t();elseif("function"==typeofdefine&&define.amd)define([],t);else{vare;"undefined"!=typeofwindow?e=window:"undefined"!=typeofglobal?e=global:"undefined"!=typeofself&&(e=self),e.terra=t()}}(function(){vart;returnfunctione(t,n,r){functiono(a,u){if(!n[a]){if(!t[a]){varc="function"==typeofrequire&&require;if(!u&&c)returnc(a,!0);if(i)returni(a,!0);varf=newError("Cannot find module '"+a+"'");throwf.code="MODULE_NOT_FOUND",f}vars=n[a]={exports:{}};t[a][0].call(s.exports,function(e){varn=t[a][1][e];returno(n?n:e)},s,s.exports,e,t,n,r)}returnn[a].exports}for(vari="function"==typeofrequire&&require,a=0;a<r.length;a++)o(r[a]);returno}({1:[function(t,e){varn=t("./terrarium.js"),r=t("./creature.js");e.exports={Terrarium:n,registerCreature:r.registerCreature,registerCA:r.registerCA}},{"./creature.js":2,"./terrarium.js":5}],2:[function(t,e){varn=t("./util.js"),r=function(){functiont(){this.age=-1}functione(){this.age=-1}t.prototype.initialEnergy=50,t.prototype.maxEnergy=100,t.prototype.efficiency=.7,t.prototype.size=50,t.prototype.actionRadius=1,t.prototype.sustainability=2,t.prototype.reproduceLv=.7,t.prototype.moveLv=0,t.prototype.boundEnergy=function(){this.energy>this.maxEnergy&&(this.energy=this.maxEnergy)},t.prototype.isDead=function(){returnthis.energy<=0},t.prototype.reproduce=function(t){vare=n.filter(t,function(t){return!t.creature});if(e.length){varo=e[n.random(e.length-1)],i=o.coords,a=r.make(this.type),u=function(){returnthis.energy-=this.initialEnergy,!0}.bind(this),c=this.wait;return{x:i.x,y:i.y,creature:a,successFn:u,failureFn:c}}return!1},t.prototype.move=function(t){vare=this,r=n.filter(t,function(t){returnt.creature.size<this.size}.bind(this));if(r.length<this.sustainability&&(r=n.filter(t,function(t){return!t.creature})),r.length){varo=r[n.random(r.length-1)],i=o.coords,a=function(){vart=o.creature.energy*this.efficiency;returnthis.energy=this.energy+(t||-10),!1}.bind(this);return{x:i.x,y:i.y,creature:e,successFn:a}}return!1},t.prototype.wait=function(){returnthis.energy-=5,!0},t.prototype.process=function(t){vare={},n=this.maxEnergy;this.energy>n*this.reproduceLv&&this.reproduce?e=this.reproduce(t):this.energy>n*this.moveLv&&this.move&&(e=this.move(t));varr=e.creature;returnr?(r.successFn=e.successFn||r.wait,r.failureFn=e.failureFn||r.wait,{x:e.x,y:e.y,creature:r,observed:!0}):this.energy!==this.maxEnergy},e.prototype.boundEnergy=function(){},e.prototype.isDead=function(){return!1},e.prototype.process=function(){},e.prototype.wait=function(){};varo={};return{make:function(t,e){varn=o[t];returnn?newn(e):!1},registerCreature:function(e,r){vari=e.type;if("string"==typeofi&&"undefined"==typeofo[i]){o[i]="function"==typeofr?function(){this.energy=this.initialEnergy,r.call(this)}:function(){this.energy=this.initialEnergy};vara=e.color;return("object"!=typeofa||3!==a.length)&&(e.color=[n.random(255),n.random(255),n.random(255)]),o[i].prototype=newt,o[i].prototype.constructor=o[i],n.each(e,function(t,e){o[i].prototype[e]=t}),o[i].prototype.successFn=o[i].wait,o[i].prototype.failureFn=o[i].wait,o[i].prototype.energy=e.initialEnergy,!0}return!1},registerCA:function(t,r){vari=t.type;if("string"==typeofi&&"undefined"==typeofo[i]){o[i]="function"==typeofr?function(){r.call(this)}:function(){};vara=t.color;return("object"!=typeofa||3!==a.length)&&(t.color=[n.random(255),n.random(255),n.random(255)]),o[i].prototype=newe,o[i].prototype.constructor=o[i],n.each(t,function(t,e){o[i].prototype[e]=t}),!0}return!1}}}();e.exports=r},{"./util.js":6}],3:[function(t,e){varn=t("./util.js");e.exports=function(t,e,r,o,i){vara=t.getContext("2d");if(o&&i)a.fillStyle="rgba("+i+","+(1-o)+")",a.fillRect(0,0,t.width,t.height);else{if(o)throw"Background must also be set for trails";a.clearRect(0,0,t.width,t.height)}n.each(e,function(t,e){n.each(t,function(t,n){if(t){varo=t.colorFn?t.colorFn():t.color+","+t.energy/t.maxEnergy;a.fillStyle="rgba("+o+")",t.character?a.fillText(t.character,e*r,n*r+r):a.fillRect