!function(t){var e={};function i(s){if(e[s])return e[s].exports;var o=e[s]={i:s,l:!1,exports:{}};return t[s].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(s,o,function(e){return t[e]}.bind(null,o));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=15)}([function(t,e){class i{constructor(t){this.name=t,this.color="black"}render(t,e,i){t.fillStyle=this.color,t.fillRect(e.x,e.y,i,i)}}const s={empty:new class extends i{constructor(){super("empty")}},food:new class extends i{constructor(){super("food")}},wall:new class extends i{constructor(){super("wall")}},mouth:new class extends i{constructor(){super("mouth")}},producer:new class extends i{constructor(){super("producer")}},mover:new class extends i{constructor(){super("mover")}},killer:new class extends i{constructor(){super("killer")}},armor:new class extends i{constructor(){super("armor")}},eye:new class extends i{constructor(){super("eye"),this.slit_color="black"}render(t,e,i){if(t.fillStyle=this.color,t.fillRect(e.x,e.y,i,i),1!=i){var s=i/2,o=-i/8,r=-s,a=i/2+i/4,n=i/4;t.translate(e.x+s,e.y+s),t.rotate(90*e.cell_owner.getAbsoluteDirection()*Math.PI/180),t.fillStyle=this.slit_color,t.fillRect(o,r,n,a),t.setTransform(1,0,0,1,0,0)}}},defineLists(){this.all=[this.empty,this.food,this.wall,this.mouth,this.producer,this.mover,this.killer,this.armor,this.eye],this.living=[this.mouth,this.producer,this.mover,this.killer,this.armor,this.eye]},getRandomName:function(){return this.all[Math.floor(Math.random()*this.all.length)].name},getRandomLivingType:function(){return this.living[Math.floor(Math.random()*this.living.length)]}};s.defineLists(),t.exports=s},function(t,e,i){const s=i(6),o={setDefaults:function(){this.lifespanMultiplier=100,this.foodProdProb=4,this.foodProdProbScalar=4,this.killableNeighbors=s.adjacent,this.edibleNeighbors=s.adjacent,this.growableNeighbors=s.adjacent,this.useGlobalMutability=!1,this.globalMutability=5,this.addProb=33,this.changeProb=33,this.removeProb=33,this.moversCanRotate=!0,this.offspringRotate=!0,this.foodBlocksReproduction=!0,this.moversCanProduce=!1,this.instaKill=!1,this.lookRange=20,this.foodDropProb=0},balanceMutationProbs:function(t){if(1==t){var e=100-this.addProb;this.changeProb=e/2,this.removeProb=e/2}else if(2==t){e=100-this.changeProb;this.addProb=e/2,this.removeProb=e/2}else{e=100-this.removeProb;this.changeProb=e/2,this.addProb=e/2}}};o.setDefaults(),t.exports=o},function(t,e,s){const o=s(0),r=s(12),a={init:function(){this.extant_species=[],this.extinct_species=[],this.min_discard=10,this.total_relavent_organisms=0,this.record_size_limit=500},setEnv:function(t){this.env=t,this.setData()},addSpecies:function(t,e){var i=new r(t.anatomy,e,this.env.total_ticks);return this.extant_species.push(i),t.species=i,i},addSpeciesObj:function(t){return this.extant_species.push(t),t},fossilize:function(t){for(i in t.end_tick=this.env.total_ticks,this.extant_species){var e=this.extant_species[i];if(e==t)return this.extant_species.splice(i,1),!(t.cumulative_pop0&&(e=this.env.total_cells/this.total_relavent_organisms),this.av_cells.push(e),this.tick_record.length>this.record_size_limit&&(this.tick_record.shift(),this.pop_counts.shift(),this.species_counts.shift(),this.av_mut_rates.shift(),this.av_cells.shift(),this.av_cell_counts.shift())},calcCellCountAverages(){var t=0,e={};for(let t of o.living)e[t.name]=0;var i=!0;for(let s of this.extant_species)if(!(s.cumulative_pop3&&(t=0),t}};t.exports=i},function(t,e,i){i(0);const s=i(3);t.exports=class{constructor(t,e,i,s){this.state=t,this.org=e,this.loc_col=i,this.loc_row=s;var o=Math.max(2*Math.abs(s)+2,2*Math.abs(i)+2);this.org.anatomy.birth_distance0&&(e=this.data[0].dataPoints[this.data[0].dataPoints.length-1].x,e=this.data[0].dataPoints[0].x),e1){c=this.anatomy.getRandomCell();e=this.anatomy.removeCell(c.loc_col,c.loc_row)}return e}attemptMove(){var t=a.scalars[this.direction],e=t[0],i=t[1],o=this.c+e,r=this.r+i;if(this.isClear(o,r)){for(var n of this.anatomy.cells){var l=this.c+n.rotatedCol(this.rotation),h=this.r+n.rotatedRow(this.rotation);this.env.changeCell(l,h,s.empty,null)}return this.c=o,this.r=r,this.updateGrid(),!0}return!1}attemptRotate(){if(!this.can_rotate)return this.direction=a.getRandomDirection(),this.move_count=0,!0;var t=a.getRandomDirection();if(this.isClear(this.c,this.r,t)){for(var e of this.anatomy.cells){var i=this.c+e.rotatedCol(this.rotation),o=this.r+e.rotatedRow(this.rotation);this.env.changeCell(i,o,s.empty,null)}return this.rotation=t,this.direction=a.getRandomDirection(),this.updateGrid(),this.move_count=0,!0}return!1}changeDirection(t){this.direction=t,this.move_count=0}isStraightPath(t,e,i,s,o){if(t==i){if(e>s){var r=s;s=e,e=r}for(var a=e;a!=s;a++){var n=this.env.grid_map.cellAt(t,a);if(!this.isPassableCell(n,o))return!1}return!0}if(t>i){r=i;i=t,t=r}for(a=t;a!=i;a++){n=this.env.grid_map.cellAt(a,e);if(!this.isPassableCell(n,o))return!1}return!0}isPassableCell(t,e){return null!=t&&(t.state==s.empty||t.owner==this||t.owner==e||t.state==s.food)}isClear(t,e,i=this.rotation,o=!1){for(var a of this.anatomy.cells){var n=this.getRealCell(a,t,e,i);if(null==n)return!1;if(!(n.owner==this||n.state==s.empty||!r.foodBlocksReproduction&&n.state==s.food||o&&a.state==s.armor&&n.state==s.food))return!1}return!0}harm(){this.damage++,(this.damage>=this.maxHealth()||r.instaKill)&&this.die()}die(){for(var t of this.anatomy.cells){var e=this.c+t.rotatedCol(this.rotation),i=this.r+t.rotatedRow(this.rotation);this.env.changeCell(e,i,s.food,null)}this.species.decreasePop(),this.living=!1}updateGrid(){for(var t of this.anatomy.cells){var e=this.c+t.rotatedCol(this.rotation),i=this.r+t.rotatedRow(this.rotation);this.env.changeCell(e,i,t.state,t)}}update(){if(this.lifetime++,this.lifetime>this.lifespan())return this.die(),this.living;for(var t of(this.food_collected>=this.foodNeeded()&&this.reproduce(),this.anatomy.cells))if(t.performFunction(),!this.living)return this.living;if(this.anatomy.is_mover){this.move_count++;var e=!1;0==this.ignore_brain_for?e=this.brain.decide():this.ignore_brain_for--;var i=this.attemptMove();if(this.move_count>this.move_range&&!e||!i)this.attemptRotate()||(this.changeDirection(a.getRandomDirection()),e&&(this.ignore_brain_for=this.move_range+1))}return this.living}getRealCell(t,e=this.c,i=this.r,s=this.rotation){var o=e+t.rotatedCol(s),r=i+t.rotatedRow(s);return this.env.grid_map.cellAt(o,r)}}t.exports=c},function(t,e){t.exports={None:0,FoodDrop:1,WallDrop:2,ClickKill:3,Select:4,Edit:5,Clone:6,Drag:7}},function(t,e){t.exports=class{constructor(){}update(){alert("Environment.update() must be overriden")}changeCell(t,e,i,s){this.grid_map.setCellType(t,e,i),this.grid_map.setCellOwner(t,e,s)}}},function(t,e,i){i(0),i(3);t.exports=class{constructor(t,e,i){this.cell_size=i,this.canvas=document.getElementById(t),this.ctx=this.canvas.getContext("2d"),this.fillWindow(e),this.height=this.canvas.height,this.width=this.canvas.width,this.cells_to_render=new Set,this.cells_to_highlight=new Set,this.highlighted_cells=new Set}fillWindow(t){this.fillShape($("#"+t).height(),$("#"+t).width())}fillShape(t,e){this.canvas.width=e,this.canvas.height=t,this.height=this.canvas.height,this.width=this.canvas.width}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.height,this.width)}renderFullGrid(t){for(var e of t)for(var i of e)this.renderCell(i)}renderCells(){for(var t of this.cells_to_render)this.renderCell(t);this.cells_to_render.clear()}renderCell(t){t.state.render(this.ctx,t,this.cell_size)}renderOrganism(t){for(var e of t.anatomy.cells){var i=t.getRealCell(e);this.renderCell(i)}}addToRender(t){this.highlighted_cells.has(t)&&this.cells_to_highlight.add(t),this.cells_to_render.add(t)}renderHighlights(){for(var t of this.cells_to_highlight)this.renderCellHighlight(t),this.highlighted_cells.add(t);this.cells_to_highlight.clear()}highlightOrganism(t){for(var e of t.anatomy.cells){var i=t.getRealCell(e);this.cells_to_highlight.add(i)}}highlightCell(t){this.cells_to_highlight.add(t)}renderCellHighlight(t,e="yellow"){this.renderCell(t),this.ctx.fillStyle=e,this.ctx.globalAlpha=.5,this.ctx.fillRect(t.x,t.y,this.cell_size,this.cell_size),this.ctx.globalAlpha=1,this.highlighted_cells.add(t)}clearAllHighlights(t=!1){for(var e of this.highlighted_cells)this.renderCell(e);this.highlighted_cells.clear(),t&&this.cells_to_highlight.clear()}}},function(t,e,i){const s=i(17),o=i(0);t.exports=class{constructor(t,e,i){this.resize(t,e,i)}resize(t,e,i){this.grid=[],this.cols=t,this.rows=e,this.cell_size=i;for(var r=0;r=0&&e>=0}getCenter(){return[Math.floor(this.cols/2),Math.floor(this.rows/2)]}xyToColRow(t,e){var i=Math.floor(t/this.cell_size),s=Math.floor(e/this.cell_size);return i>=this.cols?i=this.cols-1:i<0&&(i=0),s>=this.rows?s=this.rows-1:s<0&&(s=0),[i,s]}}},function(t,e,i){const s=i(0);t.exports=class{constructor(t,e,i){if(this.anatomy=t,this.ancestor=e,this.population=1,this.cumulative_pop=1,this.start_tick=i,this.end_tick=-1,this.color=Math.floor(16777215*Math.random()).toString(16),null!=e){var s=Math.floor(16777215*Math.random())-8e6;this.color=(s+parseInt(e.color,16)).toString(16)}this.name="_"+Math.random().toString(36).substr(2,9),this.extinct=!1,this.calcAnatomyDetails()}calcAnatomyDetails(){var t={};for(let e of s.living)t[e.name]=0;for(let e of this.anatomy.cells)t[e.state.name]+=1;this.cell_counts=t}addPop(){this.population++,this.cumulative_pop++}decreasePop(){if(this.population--,this.population<=0){this.extinct=!0;i(2).fossilize(this)}}lifespan(){return this.end_tick-this.start_tick}}},function(t,e){t.exports=class{constructor(t,e){this.env=t,this.canvas=e,this.mouse_x,this.mouse_y,this.mouse_c,this.mouse_r,this.left_click=!1,this.right_click=!1,this.cur_cell=null,this.cur_org=null,this.highlight_org=!0,this.defineEvents()}setControlPanel(t){this.control_panel=t}defineEvents(){this.canvas.addEventListener("mousemove",t=>{this.updateMouseLocation(t.offsetX,t.offsetY),this.mouseMove()}),this.canvas.addEventListener("mouseup",function(t){t.preventDefault(),this.updateMouseLocation(t.offsetX,t.offsetY),this.mouseUp(),this.left_click=!1,this.right_click=!1}.bind(this)),this.canvas.addEventListener("mousedown",function(t){t.preventDefault(),this.updateMouseLocation(t.offsetX,t.offsetY),0==t.button&&(this.left_click=!0),2==t.button&&(this.right_click=!0),this.mouseDown()}.bind(this)),this.canvas.addEventListener("contextmenu",(function(t){t.preventDefault()})),this.canvas.addEventListener("mouseleave",function(){this.right_click=!1,this.left_click=!1,this.env.renderer.clearAllHighlights(!0)}.bind(this))}updateMouseLocation(t,e){var i=this.cur_cell,s=this.cur_org;this.mouse_x=t,this.mouse_y=e;var o=this.env.grid_map.xyToColRow(this.mouse_x,this.mouse_y);this.mouse_c=o[0],this.mouse_r=o[1],this.cur_cell=this.env.grid_map.cellAt(this.mouse_c,this.mouse_r),this.cur_org=this.cur_cell.owner,this.cur_org==s&&this.cur_cell==i||(this.env.renderer.clearAllHighlights(!0),null!=this.cur_org&&this.highlight_org?this.env.renderer.highlightOrganism(this.cur_org):null!=this.cur_cell&&this.env.renderer.highlightCell(this.cur_cell,!0))}mouseMove(){alert("mouse move must be overridden")}mouseDown(){alert("mouse down must be overridden")}mouseUp(){alert("mouse up must be overridden")}}},function(t,e,i){const s=i(16),o=i(29),r=i(35),a=i(37);t.exports=class{constructor(){this.fps=60,this.env=new s(5),this.organism_editor=new r,this.controlpanel=new o(this),this.colorscheme=new a(this.env,this.organism_editor),this.colorscheme.loadColorScheme(),this.env.OriginOfLife(),this.last_update=Date.now(),this.delta_time=0,this.actual_fps=0,this.running=!1}start(t=60){t<=0&&(t=1),t>300&&(t=300),this.fps=t,this.game_loop=setInterval(function(){this.environmentUpdate()}.bind(this),1e3/t),this.running=!0,this.fps>=60?null!=this.render_loop&&(clearInterval(this.render_loop),this.render_loop=null):this.setRenderLoop()}stop(){clearInterval(this.game_loop),this.running=!1,this.setRenderLoop()}setRenderLoop(){null==this.render_loop&&(this.render_loop=setInterval(function(){this.necessaryUpdate()}.bind(this),1e3/60))}environmentUpdate(){this.delta_time=Date.now()-this.last_update,this.last_update=Date.now(),this.env.update(this.delta_time),this.actual_fps=1/this.delta_time*1e3,null==this.render_loop&&this.necessaryUpdate()}necessaryUpdate(){this.env.render(),this.controlpanel.update(),this.organism_editor.update()}}},function(t,e,i){"use strict";i.r(e);var s=i(14),o=i.n(s);$("document").ready((function(){(function(){let t=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0)}(navigator.userAgent||navigator.vendor||window.opera),t})()&&(alert("Though the simulation still works on mobile, most features are disabled. Try it on desktop for the full experience!"),$(".control-panel").css("display","none")),(new o.a).start(60)}))},function(t,e,i){const s=i(9),o=i(10),r=i(11),a=i(7),n=i(0),l=i(28),h=i(1),c=i(2);t.exports=class extends s{constructor(t){super(),this.renderer=new o("env-canvas","env",t),this.controller=new l(this,this.renderer.canvas);var e=Math.floor(this.renderer.height/t),i=Math.floor(this.renderer.width/t);this.grid_map=new r(i,e,t),this.organisms=[],this.walls=[],this.total_mutability=0,this.auto_reset=!0,this.largest_cell_count=0,this.reset_count=0,this.total_ticks=0,this.total_cells=0,this.data_update_rate=100,c.setEnv(this)}update(t){var e=[];for(var i in this.organisms){var s=this.organisms[i];s.living&&s.update()||e.push(i)}h.foodDropProb>0&&this.generateFood(),this.removeOrganisms(e),this.total_ticks++,this.total_ticks%this.data_update_rate==0&&c.updateData()}render(){this.renderer.renderCells(),this.renderer.renderHighlights()}removeOrganisms(t){for(var e of t.reverse())this.total_mutability-=this.organisms[e].mutability,this.total_cells-=this.organisms[e].anatomy.cells.length,this.organisms.splice(e,1);0==this.organisms.length&&this.auto_reset&&(this.reset_count++,this.reset())}OriginOfLife(){var t=this.grid_map.getCenter(),e=new a(t[0],t[1],this);e.anatomy.addDefaultCell(n.mouth,0,0),e.anatomy.addDefaultCell(n.producer,1,1),e.anatomy.addDefaultCell(n.producer,-1,-1),this.addOrganism(e),c.addSpecies(e,null)}addOrganism(t){t.updateGrid(),this.total_mutability+=t.mutability,this.organisms.push(t),t.anatomy.cells.length>this.largest_cell_count&&(this.largest_cell_count=t.anatomy.cells.length),this.total_cells+=t.anatomy.cells.length}averageMutability(){return this.organisms.length<1?0:h.useGlobalMutability?h.globalMutability:this.total_mutability/this.organisms.length}changeCell(t,e,i,s){super.changeCell(t,e,i,s),this.renderer.addToRender(this.grid_map.cellAt(t,e)),i==n.wall&&this.walls.push(this.grid_map.cellAt(t,e))}clearWalls(){for(var t of this.walls)this.grid_map.cellAt(t.col,t.row).state==n.wall&&this.changeCell(t.col,t.row,n.empty,null)}clearOrganisms(){for(var t of this.organisms)t.die();this.organisms=[]}generateFood(){for(var t=Math.max(Math.floor(this.grid_map.cols*this.grid_map.rows*h.foodDropProb/5e4),1),e=h.foodDropProb,i=0;i3&&(t-=4),t}performFunction(){var t=this.look();this.org.brain.observe(t)}look(){var t=this.org.env,e=this.getAbsoluteDirection(),i=0,o=0;switch(e){case a.up:o=-1;break;case a.down:o=1;break;case a.right:i=1;break;case a.left:i=-1}for(var l=this.getRealCol(),h=this.getRealRow(),c=l,d=h,u=null,p=0;p