/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./src/Controllers/CanvasController.js": /*!*********************************************!*\ !*** ./src/Controllers/CanvasController.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("\r\n\r\nclass CanvasController{\r\n constructor(env, canvas) {\r\n this.env = env;\r\n this.canvas = canvas;\r\n this.mouse_x;\r\n this.mouse_y;\r\n this.mouse_c;\r\n this.mouse_r;\r\n this.left_click = false;\r\n this.right_click = false;\r\n this.cur_cell = null;\r\n this.cur_org = null;\r\n this.highlight_org = true;\r\n this.defineEvents();\r\n }\r\n\r\n setControlPanel(panel){\r\n this.control_panel = panel;\r\n }\r\n\r\n defineEvents() {\r\n this.canvas.addEventListener('mousemove', e => {\r\n this.updateMouseLocation(e.offsetX, e.offsetY)\r\n this.mouseMove();\r\n });\r\n\r\n this.canvas.addEventListener('mouseup', function(evt) {\r\n evt.preventDefault();\r\n this.updateMouseLocation(evt.offsetX, evt.offsetY)\r\n this.mouseUp();\r\n this.left_click=false;\r\n this.right_click=false;\r\n }.bind(this));\r\n\r\n this.canvas.addEventListener('mousedown', function(evt) {\r\n evt.preventDefault();\r\n this.updateMouseLocation(evt.offsetX, evt.offsetY)\r\n if (evt.button == 0) {\r\n this.left_click = true;\r\n }\r\n if (evt.button == 2) \r\n this.right_click = true;\r\n this.mouseDown();\r\n }.bind(this));\r\n\r\n this.canvas.addEventListener('contextmenu', function(evt) {\r\n evt.preventDefault();\r\n });\r\n\r\n this.canvas.addEventListener('mouseleave', function(){\r\n this.right_click = false;\r\n this.left_click = false;\r\n this.env.renderer.clearAllHighlights(true);\r\n }.bind(this));\r\n\r\n }\r\n\r\n updateMouseLocation(offsetX, offsetY) {\r\n var prev_cell = this.cur_cell;\r\n var prev_org = this.cur_org;\r\n\r\n this.mouse_x = offsetX;\r\n this.mouse_y = offsetY;\r\n var colRow = this.env.grid_map.xyToColRow(this.mouse_x, this.mouse_y);\r\n this.mouse_c = colRow[0];\r\n this.mouse_r = colRow[1];\r\n this.cur_cell = this.env.grid_map.cellAt(this.mouse_c, this.mouse_r);\r\n this.cur_org = this.cur_cell.owner;\r\n\r\n if (this.cur_org != prev_org || this.cur_cell != prev_cell) {\r\n this.env.renderer.clearAllHighlights(true);\r\n if (this.cur_org != null && this.highlight_org) {\r\n this.env.renderer.highlightOrganism(this.cur_org);\r\n }\r\n else if (this.cur_cell != null) {\r\n this.env.renderer.highlightCell(this.cur_cell, true);\r\n }\r\n }\r\n }\r\n\r\n mouseMove() {\r\n alert(\"mouse move must be overridden\");\r\n }\r\n\r\n mouseDown() {\r\n alert(\"mouse down must be overridden\");\r\n }\r\n\r\n mouseUp(){\r\n alert(\"mouse up must be overridden\")\r\n }\r\n}\r\n\r\nmodule.exports = CanvasController;\n\n//# sourceURL=webpack:///./src/Controllers/CanvasController.js?"); /***/ }), /***/ "./src/Controllers/ControlModes.js": /*!*****************************************!*\ !*** ./src/Controllers/ControlModes.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("const Modes = {\r\n None: 0,\r\n FoodDrop: 1,\r\n WallDrop: 2,\r\n ClickKill: 3,\r\n Select: 4,\r\n Edit: 5,\r\n Clone: 6,\r\n Drag: 7\r\n}\r\n\r\nmodule.exports = Modes;\n\n//# sourceURL=webpack:///./src/Controllers/ControlModes.js?"); /***/ }), /***/ "./src/Controllers/ControlPanel.js": /*!*****************************************!*\ !*** ./src/Controllers/ControlPanel.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const Hyperparams = __webpack_require__(/*! ../Hyperparameters */ \"./src/Hyperparameters.js\");\r\nconst Modes = __webpack_require__(/*! ./ControlModes */ \"./src/Controllers/ControlModes.js\");\r\n\r\nclass ControlPanel {\r\n constructor(engine) {\r\n this.engine = engine;\r\n this.defineMinMaxControls();\r\n this.defineEngineSpeedControls();\r\n this.defineGridSizeControls();\r\n this.defineTabNavigation();\r\n this.defineHyperparameterControls();\r\n this.defineModeControls();\r\n this.defineChallenges();\r\n this.fps = engine.fps;\r\n this.organism_record=0;\r\n this.env_controller = this.engine.env.controller;\r\n this.editor_controller = this.engine.organism_editor.controller;\r\n this.env_controller.setControlPanel(this);\r\n this.editor_controller.setControlPanel(this);\r\n }\r\n\r\n defineMinMaxControls(){\r\n $('#minimize').click ( function() {\r\n $('.control-panel').css('display', 'none');\r\n $('.hot-controls').css('display', 'block');\r\n });\r\n $('#maximize').click ( function() {\r\n $('.control-panel').css('display', 'grid');\r\n $('.hot-controls').css('display', 'none');\r\n });\r\n }\r\n\r\n defineEngineSpeedControls(){\r\n this.slider = document.getElementById(\"slider\");\r\n this.slider.oninput = function() {\r\n this.fps = this.slider.value\r\n if (this.engine.running) {\r\n this.changeEngineSpeed(this.fps);\r\n \r\n }\r\n $('#fps').text(\"Target FPS: \"+this.fps);\r\n }.bind(this);\r\n $('.pause-button').click(function() {\r\n $('.pause-button').find(\"i\").toggleClass(\"fa fa-pause\");\r\n $('.pause-button').find(\"i\").toggleClass(\"fa fa-play\");\r\n if (this.engine.running) {\r\n this.engine.stop();\r\n }\r\n else if (!this.engine.running){\r\n this.engine.start(this.fps);\r\n }\r\n }.bind(this));\r\n }\r\n\r\n defineGridSizeControls() {\r\n $('#fill-window').change(function() {\r\n if (this.checked)\r\n $('.col-row-input').css('display' ,'none');\r\n else\r\n $('.col-row-input').css('display' ,'block');\r\n });\r\n\r\n $('#resize').click(function() {\r\n var cell_size = $('#cell-size').val();\r\n var fill_window = $('#fill-window').is(\":checked\");\r\n if (fill_window) {\r\n this.engine.env.resizeFillWindow(cell_size);\r\n }\r\n else {\r\n var cols = $('#col-input').val();\r\n var rows = $('#row-input').val();\r\n this.engine.env.resizeGridColRow(cell_size, cols, rows);\r\n }\r\n \r\n }.bind(this));\r\n }\r\n\r\n defineTabNavigation() {\r\n var self = this;\r\n $('.tabnav-item').click(function() {\r\n $('.tab').css('display', 'none');\r\n var tab = '#'+this.id+'.tab';\r\n self.engine.organism_editor.is_active = (this.id == 'editor');\r\n $(tab).css('display', 'grid');\r\n });\r\n }\r\n\r\n defineHyperparameterControls() {\r\n $('#food-prod-prob').change(function() {\r\n var food_prob = \r\n Hyperparams.foodProdProb = $('#food-prod-prob').val();;\r\n }.bind(this));\r\n $('#lifespan-multiplier').change(function() {\r\n Hyperparams.lifespanMultiplier = $('#lifespan-multiplier').val();\r\n }.bind(this));\r\n\r\n $('#mover-rot').change(function() {\r\n Hyperparams.moversCanRotate = this.checked;\r\n });\r\n $('#offspring-rot').change(function() {\r\n Hyperparams.offspringRotate = this.checked;\r\n });\r\n $('#insta-kill').change(function() {\r\n Hyperparams.instaKill = this.checked;\r\n });\r\n $('#look-range').change(function() {\r\n Hyperparams.lookRange = $('#look-range').val();\r\n });\r\n $('#food-drop-rate').change(function() {\r\n Hyperparams.foodDropProb = $('#food-drop-rate').val();\r\n });\r\n\r\n $('#evolved-mutation').change( function() {\r\n if (this.checked) {\r\n $('.global-mutation-in').css('display', 'none');\r\n $('#avg-mut').css('display', 'block');\r\n }\r\n else {\r\n $('.global-mutation-in').css('display', 'block');\r\n $('#avg-mut').css('display', 'none');\r\n }\r\n Hyperparams.useGlobalMutability = !this.checked;\r\n });\r\n $('#global-mutation').change( function() {\r\n Hyperparams.globalMutability = $('#global-mutation').val();\r\n });\r\n $('.mut-prob').change( function() {\r\n switch(this.id){\r\n case \"add-prob\":\r\n Hyperparams.addProb = this.value;\r\n Hyperparams.balanceMutationProbs(1);\r\n break;\r\n case \"change-prob\":\r\n Hyperparams.changeProb = this.value;\r\n Hyperparams.balanceMutationProbs(2);\r\n break;\r\n case \"remove-prob\":\r\n Hyperparams.removeProb = this.value;\r\n Hyperparams.balanceMutationProbs(3);\r\n break;\r\n }\r\n $('#add-prob').val(Math.floor(Hyperparams.addProb));\r\n $('#change-prob').val(Math.floor(Hyperparams.changeProb));\r\n $('#remove-prob').val(Math.floor(Hyperparams.removeProb));\r\n });\r\n $('#movers-produce').change( function() {\r\n Hyperparams.moversCanProduce = this.checked;\r\n });\r\n $('#food-blocks').change( function() {\r\n Hyperparams.foodBlocksReproduction = this.checked; \r\n });\r\n $('#reset-rules').click( function() {\r\n Hyperparams.setDefaults();\r\n $('#food-prod-prob').val(Hyperparams.foodProdProb);\r\n $('#lifespan-multiplier').val(Hyperparams.lifespanMultiplier);\r\n $('#mover-rot').prop('checked', Hyperparams.moversCanRotate);\r\n $('#offspring-rot').prop('checked', Hyperparams.offspringRotate);\r\n $('#insta-kill').prop('checked', Hyperparams.instaKill);\r\n $('#evolved-mutation').prop('checked', !Hyperparams.useGlobalMutability);\r\n $('#add-prob').val(Hyperparams.addProb);\r\n $('#change-prob').val(Hyperparams.changeProb);\r\n $('#remove-prob').val(Hyperparams.removeProb);\r\n $('#movers-produce').prop('checked', Hyperparams.moversCanProduce);\r\n $('#food-blocks').prop('checked', Hyperparams.foodBlocksReproduction);\r\n if (!Hyperparams.useGlobalMutability) {\r\n $('.global-mutation-in').css('display', 'none');\r\n $('#avg-mut').css('display', 'block');\r\n }\r\n else {\r\n $('.global-mutation-in').css('display', 'block');\r\n $('#avg-mut').css('display', 'none');\r\n }\r\n });\r\n }\r\n\r\n defineModeControls() {\r\n var self = this;\r\n $('.edit-mode-btn').click( function() {\r\n $('#cell-selections').css('display', 'none');\r\n $('#organism-options').css('display', 'none');\r\n self.editor_controller.setDetailsPanel();\r\n switch(this.id){\r\n case \"food-drop\":\r\n self.setMode(Modes.FoodDrop);\r\n break;\r\n case \"wall-drop\":\r\n self.setMode(Modes.WallDrop);\r\n break;\r\n case \"click-kill\":\r\n self.setMode(Modes.ClickKill);\r\n break;\r\n case \"select\":\r\n self.setMode(Modes.Select);\r\n break;\r\n case \"edit\":\r\n self.setMode(Modes.Edit);\r\n self.editor_controller.setEditorPanel();\r\n break;\r\n case \"drop-org\":\r\n self.setMode(Modes.Clone);\r\n self.env_controller.org_to_clone = self.engine.organism_editor.getCopyOfOrg();\r\n self.env_controller.make_new_species = true;\r\n break;\r\n case \"drag-view\":\r\n self.setMode(Modes.Drag);\r\n }\r\n $('.edit-mode-btn').css('background-color', '#9099c2');\r\n $('#'+this.id).css('background-color', '#81d2c7');\r\n });\r\n\r\n $('.reset-view').click( function(){\r\n this.env_controller.resetView();\r\n }.bind(this));\r\n\r\n var env = this.engine.env;\r\n $('#reset-env').click( function() {\r\n this.engine.env.reset();\r\n }.bind(this));\r\n $('#auto-reset').change(function() {\r\n env.auto_reset = this.checked;\r\n });\r\n $('#clear-walls').click( function() {\r\n if (confirm(\"Are you sure you want to clear all the walls?\")) {\r\n this.engine.env.clearWalls();\r\n }\r\n }.bind(this));\r\n $('#clear-editor').click( function() {\r\n this.engine.organism_editor.clear();\r\n this.editor_controller.setEditorPanel();\r\n }.bind(this));\r\n }\r\n\r\n defineChallenges() {\r\n $('.challenge-btn').click(function() {\r\n $('#challenge-title').text($(this).text());\r\n $('#challenge-description').text($(this).val());\r\n });\r\n }\r\n\r\n setMode(mode) {\r\n this.env_controller.mode = mode;\r\n this.editor_controller.mode = mode;\r\n }\r\n\r\n setEditorOrganism(org) {\r\n this.engine.organism_editor.setOrganismToCopyOf(org);\r\n this.editor_controller.clearDetailsPanel();\r\n this.editor_controller.setDetailsPanel();\r\n }\r\n\r\n changeEngineSpeed(change_val) {\r\n this.engine.stop();\r\n this.engine.start(change_val)\r\n this.fps = this.engine.fps;\r\n }\r\n\r\n update() {\r\n $('#fps-actual').text(\"Actual FPS: \" + Math.floor(this.engine.actual_fps));\r\n var org_count = this.engine.env.organisms.length;\r\n $('#org-count').text(\"Organism count: \" + org_count);\r\n if (org_count > this.organism_record) \r\n this.organism_record = org_count;\r\n $('#org-record').text(\"Highest count: \" + this.organism_record);\r\n $('#avg-mut').text(\"Average Mutation Rate: \" + Math.round(this.engine.env.averageMutability() * 100) / 100);\r\n $('#largest-org').text(\"Largest Organism: \" + this.engine.env.largest_cell_count + \" cells\");\r\n $('#reset-count').text(\"Auto reset count: \" + this.engine.env.reset_count);\r\n }\r\n\r\n}\r\n\r\n\r\nmodule.exports = ControlPanel;\n\n//# sourceURL=webpack:///./src/Controllers/ControlPanel.js?"); /***/ }), /***/ "./src/Controllers/EditorController.js": /*!*********************************************!*\ !*** ./src/Controllers/EditorController.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const CanvasController = __webpack_require__(/*! ./CanvasController */ \"./src/Controllers/CanvasController.js\");\r\nconst Modes = __webpack_require__(/*! ./ControlModes */ \"./src/Controllers/ControlModes.js\");\r\nconst CellStates = __webpack_require__(/*! ../Organism/Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst Directions = __webpack_require__(/*! ../Organism/Directions */ \"./src/Organism/Directions.js\");\r\nconst Hyperparams = __webpack_require__(/*! ../Hyperparameters */ \"./src/Hyperparameters.js\");\r\n\r\nclass EditorController extends CanvasController{\r\n constructor(env, canvas) {\r\n super(env, canvas);\r\n this.mode = Modes.None;\r\n this.edit_cell_type = null;\r\n this.highlight_org = false;\r\n this.defineCellTypeSelection();\r\n this.defineEditorDetails();\r\n }\r\n\r\n mouseMove() {\r\n if (this.right_click || this.left_click)\r\n this.editOrganism();\r\n }\r\n\r\n mouseDown() {\r\n this.editOrganism();\r\n }\r\n\r\n mouseUp(){}\r\n\r\n getCurLocalCell(){\r\n return this.env.organism.anatomy.getLocalCell(this.mouse_c-this.env.organism.c, this.mouse_r-this.env.organism.r);\r\n }\r\n\r\n editOrganism() {\r\n if (this.edit_cell_type == null || this.mode != Modes.Edit)\r\n return;\r\n if (this.left_click){\r\n if(this.edit_cell_type == CellStates.eye && this.cur_cell.state == CellStates.eye) {\r\n var loc_cell = this.getCurLocalCell();\r\n loc_cell.direction = Directions.rotateRight(loc_cell.direction);\r\n this.env.renderFull();\r\n }\r\n else\r\n this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);\r\n }\r\n if (this.right_click)\r\n this.env.removeCellFromOrg(this.mouse_c, this.mouse_r);\r\n this.setBrainPanelVisibility();\r\n this.setMoveRangeVisibility();\r\n this.updateDetails();\r\n }\r\n\r\n updateDetails() {\r\n $('.cell-count').text(\"Cell count: \"+this.env.organism.anatomy.cells.length);\r\n }\r\n\r\n defineCellTypeSelection() {\r\n var self = this;\r\n $('.cell-type').click( function() {\r\n switch(this.id){\r\n case \"mouth\":\r\n self.edit_cell_type = CellStates.mouth;\r\n break;\r\n case \"producer\":\r\n self.edit_cell_type = CellStates.producer;\r\n break;\r\n case \"mover\":\r\n self.edit_cell_type = CellStates.mover;\r\n break;\r\n case \"killer\":\r\n self.edit_cell_type = CellStates.killer;\r\n break;\r\n case \"armor\":\r\n self.edit_cell_type = CellStates.armor;\r\n break;\r\n case \"eye\":\r\n self.edit_cell_type = CellStates.eye;\r\n break;\r\n }\r\n $(\".cell-type\" ).css( \"border-color\", \"black\" );\r\n var selected = '#'+this.id+'.cell-type';\r\n $(selected).css(\"border-color\", \"yellow\");\r\n });\r\n }\r\n\r\n defineEditorDetails() {\r\n this.details_html = $('#organism-details');\r\n this.edit_details_html = $('#edit-organism-details');\r\n\r\n this.decision_names = [\"ignore\", \"move away\", \"move towards\"];\r\n\r\n $('#move-range-edit').change ( function() {\r\n this.env.organism.move_range = parseInt($('#move-range-edit').val());\r\n }.bind(this));\r\n $('#observation-type-edit').change ( function() {\r\n this.setBrainEditorValues($('#observation-type-edit').val());\r\n this.setBrainDetails();\r\n }.bind(this));\r\n $('#reaction-edit').change ( function() {\r\n var obs = $('#observation-type-edit').val();\r\n var decision = parseInt($('#reaction-edit').val());\r\n this.env.organism.brain.decisions[obs] = decision;\r\n this.setBrainDetails();\r\n }.bind(this));\r\n }\r\n\r\n clearDetailsPanel() {\r\n $('#organism-details').css('display', 'none');\r\n $('#edit-organism-details').css('display', 'none');\r\n }\r\n\r\n setDetailsPanel() {\r\n this.clearDetailsPanel();\r\n var org = this.env.organism;\r\n \r\n $('.cell-count').text(\"Cell count: \"+org.anatomy.cells.length);\r\n $('#move-range').text(\"Move Range: \"+org.move_range);\r\n $('#mutation-rate').text(\"Mutation Rate: \"+org.mutability);\r\n if (Hyperparams.useGlobalMutability) {\r\n $('#mutation-rate').css('display', 'none');\r\n }\r\n else {\r\n $('#mutation-rate').css('display', 'block');\r\n }\r\n\r\n this.setMoveRangeVisibility();\r\n\r\n if (this.setBrainPanelVisibility()) {\r\n this.setBrainDetails();\r\n\r\n }\r\n $('#organism-details').css('display', 'block');\r\n }\r\n\r\n setEditorPanel() {\r\n this.clearDetailsPanel();\r\n var org = this.env.organism;\r\n\r\n $('.cell-count').text(\"Cell count: \"+org.anatomy.cells.length);\r\n if (this.setMoveRangeVisibility()){\r\n $('#move-range-edit').val(org.move_range);\r\n }\r\n \r\n if (this.setBrainPanelVisibility()){\r\n this.setBrainEditorValues($('#observation-type-edit').val());\r\n }\r\n\r\n $('#cell-selections').css('display', 'grid');\r\n $('#edit-organism-details').css('display', 'block');\r\n }\r\n\r\n setBrainPanelVisibility() {\r\n var org = this.env.organism;\r\n if (org.anatomy.has_eyes && org.anatomy.is_mover) {\r\n $('.brain-details').css('display', 'block');\r\n return true;\r\n }\r\n $('.brain-details').css('display', 'none');\r\n return false;\r\n }\r\n\r\n setBrainDetails() {\r\n var chase_types = [];\r\n var retreat_types = [];\r\n for(var cell_name in this.env.organism.brain.decisions) {\r\n var decision = this.env.organism.brain.decisions[cell_name];\r\n if (decision == 1) {\r\n retreat_types.push(cell_name)\r\n }\r\n else if (decision == 2) {\r\n chase_types.push(cell_name);\r\n }\r\n }\r\n $('.chase-types').text(\"Move Towards: \" + chase_types);\r\n $('.retreat-types').text(\"Move Away From: \" + retreat_types);\r\n }\r\n\r\n setMoveRangeVisibility() {\r\n var org = this.env.organism;\r\n if (org.anatomy.is_mover) {\r\n $('#move-range-cont').css('display', 'block');\r\n $('#move-range').css('display', 'block');\r\n return true;\r\n }\r\n $('#move-range-cont').css('display', 'none');\r\n $('#move-range').css('display', 'none');\r\n return false;\r\n }\r\n\r\n setBrainEditorValues(name) {\r\n $('#observation-type-edit').val(name);\r\n var reaction = this.env.organism.brain.decisions[name];\r\n $('#reaction-edit').val(reaction);\r\n }\r\n}\r\n\r\nmodule.exports = EditorController;\r\n\n\n//# sourceURL=webpack:///./src/Controllers/EditorController.js?"); /***/ }), /***/ "./src/Controllers/EnvironmentController.js": /*!**************************************************!*\ !*** ./src/Controllers/EnvironmentController.js ***! \**************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const CanvasController = __webpack_require__(/*! ./CanvasController */ \"./src/Controllers/CanvasController.js\");\r\nconst Organism = __webpack_require__(/*! ../Organism/Organism */ \"./src/Organism/Organism.js\");\r\nconst Modes = __webpack_require__(/*! ./ControlModes */ \"./src/Controllers/ControlModes.js\");\r\nconst CellStates = __webpack_require__(/*! ../Organism/Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst Neighbors = __webpack_require__(/*! ../Grid/Neighbors */ \"./src/Grid/Neighbors.js\");\r\nconst FossilRecord = __webpack_require__(/*! ../Stats/FossilRecord */ \"./src/Stats/FossilRecord.js\");\r\n\r\nclass EnvironmentController extends CanvasController{\r\n constructor(env, canvas) {\r\n super(env, canvas);\r\n this.mode = Modes.Drag;\r\n this.org_to_clone = null;\r\n this.species_to_clone = null;\r\n this.make_new_species = false;\r\n this.defineZoomControls();\r\n this.scale = 1;\r\n }\r\n\r\n defineZoomControls() {\r\n var scale = 1;\r\n var zoom_speed = 0.5;\r\n const el = document.querySelector('#env-canvas');\r\n el.onwheel = function zoom(event) {\r\n event.preventDefault();\r\n\r\n var sign = -Math.sign(event.deltaY);\r\n\r\n // Restrict scale\r\n scale = Math.max(0.5, this.scale+(sign*zoom_speed));\r\n\r\n if (scale != 0.5) {\r\n var cur_top = parseInt($('#env-canvas').css('top'));\r\n var cur_left = parseInt($('#env-canvas').css('left'));\r\n if (sign == 1) {\r\n // If we're zooming in, zoom towards wherever the mouse is\r\n var diff_x = ((this.canvas.width/2-cur_left/this.scale) - this.mouse_x)*this.scale/1.5;\r\n var diff_y = ((this.canvas.height/2-cur_top/this.scale) - this.mouse_y)*this.scale/1.5;\r\n }\r\n else {\r\n // If we're zooming out, zoom out towards the center\r\n var diff_x = -cur_left/scale;\r\n var diff_y = -cur_top/scale;\r\n }\r\n $('#env-canvas').css('top', (cur_top+diff_y)+'px');\r\n $('#env-canvas').css('left', (cur_left+diff_x)+'px');\r\n }\r\n \r\n // Apply scale transform\r\n el.style.transform = `scale(${scale})`;\r\n this.scale = scale;\r\n\r\n }.bind(this);\r\n }\r\n\r\n resetView() {\r\n $('#env-canvas').css('transform', 'scale(1)');\r\n $('#env-canvas').css('top', '0px');\r\n $('#env-canvas').css('left', '0px');\r\n this.scale = 1;\r\n }\r\n\r\n updateMouseLocation(offsetX, offsetY){\r\n \r\n super.updateMouseLocation(offsetX, offsetY);\r\n }\r\n\r\n mouseMove() {\r\n this.performModeAction();\r\n }\r\n\r\n mouseDown() {\r\n this.start_x = this.mouse_x;\r\n this.start_y = this.mouse_y;\r\n this.performModeAction();\r\n }\r\n\r\n mouseUp() {\r\n\r\n }\r\n\r\n performModeAction() {\r\n var mode = this.mode;\r\n var right_click = this.right_click;\r\n var left_click = this.left_click;\r\n if (mode != Modes.None && (right_click || left_click)) {\r\n var cell = this.cur_cell;\r\n if (cell == null){\r\n return;\r\n }\r\n switch(mode) {\r\n case Modes.FoodDrop:\r\n if (left_click){\r\n this.dropCellType(cell.col, cell.row, CellStates.food, false);\r\n }\r\n else if (right_click){\r\n this.dropCellType(cell.col, cell.row, CellStates.empty, false);\r\n }\r\n break;\r\n case Modes.WallDrop:\r\n if (left_click){\r\n this.dropCellType(cell.col, cell.row, CellStates.wall, true);\r\n\r\n }\r\n else if (right_click){\r\n this.dropCellType(cell.col, cell.row, CellStates.empty, false);\r\n }\r\n break;\r\n case Modes.ClickKill:\r\n this.killNearOrganisms();\r\n break;\r\n\r\n case Modes.Select:\r\n if (this.cur_org == null) {\r\n this.cur_org = this.findNearOrganism();\r\n }\r\n if (this.cur_org != null){\r\n this.control_panel.setEditorOrganism(this.cur_org);\r\n }\r\n break;\r\n\r\n case Modes.Clone:\r\n if (this.org_to_clone != null){\r\n var new_org = new Organism(this.mouse_c, this.mouse_r, this.env, this.org_to_clone);\r\n if (this.make_new_species){\r\n this.species_to_clone = FossilRecord.addSpecies(new_org, null)\r\n this.make_new_species = false;\r\n }\r\n else {\r\n new_org.species = this.species_to_clone;\r\n this.species_to_clone.addPop();\r\n }\r\n if (new_org.isClear(this.mouse_c, this.mouse_r)){\r\n this.env.addOrganism(new_org)\r\n }\r\n }\r\n break;\r\n case Modes.Drag:\r\n var cur_top = parseInt($('#env-canvas').css('top'), 10);\r\n var cur_left = parseInt($('#env-canvas').css('left'), 10);\r\n var new_top = cur_top + ((this.mouse_y - this.start_y)*this.scale);\r\n var new_left = cur_left + ((this.mouse_x - this.start_x)*this.scale);\r\n $('#env-canvas').css('top', new_top+'px');\r\n $('#env-canvas').css('left', new_left+'px');\r\n break;\r\n }\r\n }\r\n }\r\n\r\n dropCellType(col, row, state, killBlocking=false) {\r\n for (var loc of Neighbors.allSelf){\r\n var c=col + loc[0];\r\n var r=row + loc[1];\r\n var cell = this.env.grid_map.cellAt(c, r);\r\n if (cell == null)\r\n continue;\r\n if (killBlocking && cell.owner != null){\r\n cell.owner.die();\r\n }\r\n else if (cell.owner != null) {\r\n continue;\r\n }\r\n this.env.changeCell(c, r, state, null);\r\n }\r\n }\r\n\r\n findNearOrganism() {\r\n for (var loc of Neighbors.all){\r\n var c = this.cur_cell.col + loc[0];\r\n var r = this.cur_cell.row + loc[1];\r\n var cell = this.env.grid_map.cellAt(c, r);\r\n if (cell != null && cell.owner != null)\r\n return cell.owner;\r\n }\r\n return null;\r\n }\r\n\r\n killNearOrganisms() {\r\n for (var loc of Neighbors.allSelf){\r\n var c = this.cur_cell.col + loc[0];\r\n var r = this.cur_cell.row + loc[1];\r\n var cell = this.env.grid_map.cellAt(c, r);\r\n if (cell != null && cell.owner != null)\r\n cell.owner.die();\r\n }\r\n }\r\n\r\n\r\n}\r\n\r\nmodule.exports = EnvironmentController;\r\n\n\n//# sourceURL=webpack:///./src/Controllers/EnvironmentController.js?"); /***/ }), /***/ "./src/Engine.js": /*!***********************!*\ !*** ./src/Engine.js ***! \***********************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const WorldEnvironment = __webpack_require__(/*! ./Environments/WorldEnvironment */ \"./src/Environments/WorldEnvironment.js\");\r\nconst ControlPanel = __webpack_require__(/*! ./Controllers/ControlPanel */ \"./src/Controllers/ControlPanel.js\");\r\nconst OrganismEditor = __webpack_require__(/*! ./Environments/OrganismEditor */ \"./src/Environments/OrganismEditor.js\");\r\nconst ColorScheme = __webpack_require__(/*! ./Rendering/ColorScheme */ \"./src/Rendering/ColorScheme.js\");\r\n\r\nconst render_speed = 60;\r\n\r\nclass Engine{\r\n constructor(){\r\n this.fps = 60;\r\n this.env = new WorldEnvironment(5);\r\n this.organism_editor = new OrganismEditor();\r\n this.controlpanel = new ControlPanel(this);\r\n this.colorscheme = new ColorScheme(this.env, this.organism_editor);\r\n this.colorscheme.loadColorScheme();\r\n this.env.OriginOfLife();\r\n this.last_update = Date.now();\r\n this.delta_time = 0;\r\n this.actual_fps = 0;\r\n this.running = false;\r\n }\r\n\r\n start(fps=60) {\r\n if (fps <= 0)\r\n fps = 1;\r\n if (fps > 300)\r\n fps = 300;\r\n this.fps = fps;\r\n this.game_loop = setInterval(function(){this.environmentUpdate();}.bind(this), 1000/fps);\r\n this.running = true;\r\n if (this.fps >= render_speed) {\r\n if (this.render_loop != null) {\r\n clearInterval(this.render_loop);\r\n this.render_loop = null;\r\n }\r\n }\r\n else\r\n this.setRenderLoop();\r\n }\r\n \r\n stop() {\r\n clearInterval(this.game_loop);\r\n this.running = false;\r\n this.setRenderLoop();\r\n }\r\n\r\n setRenderLoop() {\r\n if (this.render_loop == null) {\r\n this.render_loop = setInterval(function(){this.necessaryUpdate();}.bind(this), 1000/render_speed);\r\n }\r\n }\r\n\r\n\r\n environmentUpdate() {\r\n this.delta_time = Date.now() - this.last_update;\r\n this.last_update = Date.now();\r\n this.env.update(this.delta_time);\r\n this.actual_fps = 1/this.delta_time*1000;\r\n if(this.render_loop == null){\r\n this.necessaryUpdate();\r\n }\r\n \r\n }\r\n\r\n necessaryUpdate() {\r\n this.env.render();\r\n this.controlpanel.update();\r\n this.organism_editor.update();\r\n }\r\n\r\n}\r\n\r\nmodule.exports = Engine;\r\n\n\n//# sourceURL=webpack:///./src/Engine.js?"); /***/ }), /***/ "./src/Environments/Environment.js": /*!*****************************************!*\ !*** ./src/Environments/Environment.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("\r\n//An evironment has a grid_map, controller, and renderer\r\nclass Environment{\r\n constructor() {\r\n }\r\n\r\n update(){\r\n alert(\"Environment.update() must be overriden\");\r\n }\r\n\r\n changeCell(c, r, state, owner) {\r\n this.grid_map.setCellType(c, r, state);\r\n this.grid_map.setCellOwner(c, r, owner);\r\n }\r\n}\r\n\r\n\r\nmodule.exports = Environment;\n\n//# sourceURL=webpack:///./src/Environments/Environment.js?"); /***/ }), /***/ "./src/Environments/OrganismEditor.js": /*!********************************************!*\ !*** ./src/Environments/OrganismEditor.js ***! \********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const Environment = __webpack_require__(/*! ./Environment */ \"./src/Environments/Environment.js\");\r\nconst Organism = __webpack_require__(/*! ../Organism/Organism */ \"./src/Organism/Organism.js\");\r\nconst GridMap = __webpack_require__(/*! ../Grid/GridMap */ \"./src/Grid/GridMap.js\");\r\nconst Renderer = __webpack_require__(/*! ../Rendering/Renderer */ \"./src/Rendering/Renderer.js\");\r\nconst CellStates = __webpack_require__(/*! ../Organism/Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst EditorController = __webpack_require__(/*! ../Controllers/EditorController */ \"./src/Controllers/EditorController.js\");\r\n\r\nclass OrganismEditor extends Environment{\r\n constructor() {\r\n super();\r\n this.is_active = true;\r\n var cell_size = 13;\r\n this.renderer = new Renderer('editor-canvas', 'editor-env', cell_size);\r\n this.controller = new EditorController(this, this.renderer.canvas);\r\n this.grid_map = new GridMap(15, 15, cell_size);\r\n this.clear();\r\n }\r\n\r\n update() {\r\n if (this.is_active){\r\n this.renderer.renderHighlights();\r\n }\r\n }\r\n\r\n changeCell(c, r, state, owner) {\r\n super.changeCell(c, r, state, owner);\r\n this.renderFull();\r\n }\r\n\r\n renderFull() {\r\n this.renderer.renderFullGrid(this.grid_map.grid);\r\n }\r\n\r\n // absolute c r, not local\r\n addCellToOrg(c, r, state) {\r\n var center = this.grid_map.getCenter();\r\n var loc_c = c - center[0];\r\n var loc_r = r - center[1];\r\n var prev_cell = this.organism.anatomy.getLocalCell(loc_c, loc_r)\r\n if (prev_cell != null) {\r\n var new_cell = this.organism.anatomy.replaceCell(state, prev_cell.loc_col, prev_cell.loc_row, false);\r\n this.changeCell(c, r, state, new_cell);\r\n }\r\n else if (this.organism.anatomy.canAddCellAt(loc_c, loc_r)){\r\n this.changeCell(c, r, state, this.organism.anatomy.addDefaultCell(state, loc_c, loc_r));\r\n }\r\n }\r\n\r\n removeCellFromOrg(c, r) {\r\n var center = this.grid_map.getCenter();\r\n var loc_c = c - center[0];\r\n var loc_r = r - center[1];\r\n if (loc_c == 0 && loc_r == 0){\r\n alert(\"Cannot remove center cell\");\r\n return;\r\n }\r\n var prev_cell = this.organism.anatomy.getLocalCell(loc_c, loc_r)\r\n if (prev_cell != null) {\r\n if (this.organism.anatomy.removeCell(loc_c, loc_r)) {\r\n this.changeCell(c, r, CellStates.empty, null);\r\n }\r\n }\r\n }\r\n\r\n setOrganismToCopyOf(orig_org){\r\n this.grid_map.fillGrid(CellStates.empty);\r\n var center = this.grid_map.getCenter();\r\n this.organism = new Organism(center[0], center[1], this, orig_org);\r\n this.organism.updateGrid();\r\n this.controller.updateDetails();\r\n }\r\n \r\n getCopyOfOrg() {\r\n var new_org = new Organism(0, 0, null, this.organism);\r\n return new_org;\r\n }\r\n\r\n clear() {\r\n this.grid_map.fillGrid(CellStates.empty);\r\n var center = this.grid_map.getCenter();\r\n this.organism = new Organism(center[0], center[1], this, null);\r\n this.organism.anatomy.addDefaultCell(CellStates.mouth, 0, 0);\r\n this.organism.updateGrid();\r\n }\r\n}\r\n\r\nmodule.exports = OrganismEditor;\n\n//# sourceURL=webpack:///./src/Environments/OrganismEditor.js?"); /***/ }), /***/ "./src/Environments/WorldEnvironment.js": /*!**********************************************!*\ !*** ./src/Environments/WorldEnvironment.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const Environment = __webpack_require__(/*! ./Environment */ \"./src/Environments/Environment.js\");\r\nconst Renderer = __webpack_require__(/*! ../Rendering/Renderer */ \"./src/Rendering/Renderer.js\");\r\nconst GridMap = __webpack_require__(/*! ../Grid/GridMap */ \"./src/Grid/GridMap.js\");\r\nconst Organism = __webpack_require__(/*! ../Organism/Organism */ \"./src/Organism/Organism.js\");\r\nconst CellStates = __webpack_require__(/*! ../Organism/Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst EnvironmentController = __webpack_require__(/*! ../Controllers/EnvironmentController */ \"./src/Controllers/EnvironmentController.js\");\r\nconst Hyperparams = __webpack_require__(/*! ../Hyperparameters.js */ \"./src/Hyperparameters.js\");\r\nconst FossilRecord = __webpack_require__(/*! ../Stats/FossilRecord */ \"./src/Stats/FossilRecord.js\");\r\n\r\nclass WorldEnvironment extends Environment{\r\n constructor(cell_size) {\r\n super();\r\n this.renderer = new Renderer('env-canvas', 'env', cell_size);\r\n this.controller = new EnvironmentController(this, this.renderer.canvas);\r\n var grid_rows = Math.floor(this.renderer.height / cell_size);\r\n var grid_cols = Math.floor(this.renderer.width / cell_size);\r\n this.grid_map = new GridMap(grid_cols, grid_rows, cell_size);\r\n this.organisms = [];\r\n this.walls = [];\r\n this.total_mutability = 0;\r\n this.auto_reset = true;\r\n this.largest_cell_count = 0;\r\n this.reset_count = 0;\r\n this.total_ticks = 0;\r\n FossilRecord.setEnv(this);\r\n }\r\n\r\n update(delta_time) {\r\n this.total_ticks ++;\r\n var to_remove = [];\r\n for (var i in this.organisms) {\r\n var org = this.organisms[i];\r\n if (!org.living || !org.update()) {\r\n to_remove.push(i);\r\n }\r\n }\r\n if (Hyperparams.foodDropProb > 0) {\r\n this.generateFood();\r\n }\r\n this.removeOrganisms(to_remove);\r\n }\r\n\r\n render() {\r\n this.renderer.renderCells();\r\n this.renderer.renderHighlights();\r\n }\r\n\r\n removeOrganisms(org_indeces) {\r\n for (var i of org_indeces.reverse()){\r\n this.total_mutability -= this.organisms[i].mutability;\r\n this.organisms.splice(i, 1);\r\n }\r\n if (this.organisms.length == 0 && this.auto_reset){\r\n this.reset_count++;\r\n this.reset();\r\n }\r\n }\r\n\r\n OriginOfLife() {\r\n var center = this.grid_map.getCenter();\r\n var org = new Organism(center[0], center[1], this);\r\n org.anatomy.addDefaultCell(CellStates.mouth, 0, 0);\r\n org.anatomy.addDefaultCell(CellStates.producer, 1, 1);\r\n org.anatomy.addDefaultCell(CellStates.producer, -1, -1);\r\n this.addOrganism(org);\r\n FossilRecord.addSpecies(org, null);\r\n }\r\n\r\n addOrganism(organism) {\r\n organism.updateGrid();\r\n this.total_mutability += organism.mutability;\r\n this.organisms.push(organism);\r\n if (organism.anatomy.cells.length > this.largest_cell_count) \r\n this.largest_cell_count = organism.anatomy.cells.length;\r\n }\r\n\r\n averageMutability() {\r\n if (this.organisms.length < 1)\r\n return 0;\r\n return this.total_mutability / this.organisms.length;\r\n }\r\n\r\n changeCell(c, r, state, owner) {\r\n super.changeCell(c, r, state, owner);\r\n this.renderer.addToRender(this.grid_map.cellAt(c, r));\r\n if(state == CellStates.wall)\r\n this.walls.push(this.grid_map.cellAt(c, r));\r\n }\r\n\r\n clearWalls() {\r\n for(var wall of this.walls){\r\n if (this.grid_map.cellAt(wall.col, wall.row).state == CellStates.wall)\r\n this.changeCell(wall.col, wall.row, CellStates.empty, null);\r\n }\r\n }\r\n\r\n clearOrganisms() {\r\n for (var org of this.organisms)\r\n org.die();\r\n this.organisms = [];\r\n }\r\n\r\n generateFood() {\r\n var num_food = Math.max(Math.floor(this.grid_map.cols*this.grid_map.rows*Hyperparams.foodDropProb/50000), 1)\r\n var prob = Hyperparams.foodDropProb;\r\n for (var i=0; i=0 && row>=0;\r\n }\r\n\r\n getCenter(){\r\n return [Math.floor(this.cols/2), Math.floor(this.rows/2)]\r\n }\r\n\r\n xyToColRow(x, y) {\r\n var c = Math.floor(x/this.cell_size);\r\n var r = Math.floor(y/this.cell_size);\r\n if (c >= this.cols)\r\n c = this.cols-1;\r\n else if (c < 0)\r\n c = 0;\r\n if (r >= this.rows)\r\n r = this.rows-1;\r\n else if (r < 0)\r\n r = 0;\r\n return [c, r];\r\n }\r\n}\r\n\r\nmodule.exports = GridMap;\r\n\n\n//# sourceURL=webpack:///./src/Grid/GridMap.js?"); /***/ }), /***/ "./src/Grid/Neighbors.js": /*!*******************************!*\ !*** ./src/Grid/Neighbors.js ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("// contains local cell values for the following:\r\n\r\n//all ...\r\n// .x.\r\n// ...\r\n\r\n//adjacent .\r\n// .x.\r\n// .\r\n\r\n//corners . .\r\n// x\r\n// . .\r\n\r\n//allSelf ...\r\n// ...\r\n// ...\r\n\r\nconst Neighbors = {\r\n all: [[0, 1],[0, -1],[1, 0],[-1, 0],[-1, -1],[1, 1],[-1, 1],[1, -1]],\r\n adjacent: [[0, 1],[0, -1],[1, 0],[-1, 0]],\r\n corners: [[-1, -1],[1, 1],[-1, 1],[1, -1]],\r\n allSelf: [[0, 0],[0, 1],[0, -1],[1, 0],[-1, 0],[-1, -1],[1, 1],[-1, 1],[1, -1]]\r\n}\r\n\r\nmodule.exports = Neighbors;\n\n//# sourceURL=webpack:///./src/Grid/Neighbors.js?"); /***/ }), /***/ "./src/Hyperparameters.js": /*!********************************!*\ !*** ./src/Hyperparameters.js ***! \********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const Neighbors = __webpack_require__(/*! ./Grid/Neighbors */ \"./src/Grid/Neighbors.js\");\r\n\r\nconst Hyperparams = {\r\n setDefaults: function() {\r\n this.lifespanMultiplier = 100;\r\n this.foodProdProb = 4;\r\n this.foodProdProbScalar = 4;\r\n this.killableNeighbors = Neighbors.adjacent;\r\n this.edibleNeighbors = Neighbors.adjacent;\r\n this.growableNeighbors = Neighbors.adjacent;\r\n\r\n this.useGlobalMutability = false;\r\n this.globalMutability = 5;\r\n this.addProb = 33;\r\n this.changeProb = 33;\r\n this.removeProb = 33;\r\n \r\n this.moversCanRotate = true;\r\n this.offspringRotate = true;\r\n\r\n this.foodBlocksReproduction = true;\r\n this.moversCanProduce = false;\r\n\r\n this.instaKill = false;\r\n\r\n this.lookRange = 20;\r\n\r\n this.foodDropProb = 0;\r\n },\r\n\r\n balanceMutationProbs : function(choice) {\r\n if (choice == 1) {\r\n var remaining = 100 - this.addProb;\r\n this.changeProb = remaining/2;\r\n this.removeProb = remaining/2;\r\n }\r\n else if (choice == 2) {\r\n var remaining = 100 - this.changeProb;\r\n this.addProb = remaining/2;\r\n this.removeProb = remaining/2;\r\n }\r\n else {\r\n var remaining = 100 - this.removeProb;\r\n this.changeProb = remaining/2;\r\n this.addProb = remaining/2;\r\n }\r\n }\r\n}\r\n\r\nHyperparams.setDefaults();\r\n\r\nmodule.exports = Hyperparams;\n\n//# sourceURL=webpack:///./src/Hyperparameters.js?"); /***/ }), /***/ "./src/Organism/Anatomy.js": /*!*********************************!*\ !*** ./src/Organism/Anatomy.js ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const CellStates = __webpack_require__(/*! ./Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst BodyCellFactory = __webpack_require__(/*! ./Cell/BodyCells/BodyCellFactory */ \"./src/Organism/Cell/BodyCells/BodyCellFactory.js\");\r\n\r\nclass Anatomy {\r\n constructor(owner) {\r\n this.owner = owner;\r\n this.cells = [];\r\n this.is_producer = false;\r\n this.is_mover = false;\r\n this.has_eyes = false;\r\n this.birth_distance = 4;\r\n }\r\n\r\n canAddCellAt(c, r) {\r\n for (var cell of this.cells) {\r\n if (cell.loc_col == c && cell.loc_row == r){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n addDefaultCell(state, c, r) {\r\n var new_cell = BodyCellFactory.createDefault(this.owner, state, c, r);\r\n this.cells.push(new_cell);\r\n return new_cell;\r\n }\r\n\r\n addRandomizedCell(state, c, r) {\r\n if (state==CellStates.eye && !this.has_eyes) {\r\n this.owner.brain.randomizeDecisions();\r\n }\r\n var new_cell = BodyCellFactory.createRandom(this.owner, state, c, r);\r\n this.cells.push(new_cell);\r\n return new_cell;\r\n }\r\n\r\n addInheritCell(parent_cell) {\r\n var new_cell = BodyCellFactory.createInherited(this.owner, parent_cell);\r\n this.cells.push(new_cell);\r\n return new_cell;\r\n }\r\n\r\n replaceCell(state, c, r, randomize=true) {\r\n this.removeCell(c, r, true);\r\n if (randomize) {\r\n return this.addRandomizedCell(state, c, r);\r\n }\r\n else {\r\n return this.addDefaultCell(state, c, r);\r\n }\r\n }\r\n\r\n removeCell(c, r, allow_center_removal=false) {\r\n if (c == 0 && r == 0 && !allow_center_removal)\r\n return false;\r\n for (var i=0; i 3)\r\n dir -= 4;\r\n return dir;\r\n }\r\n\r\n performFunction() {\r\n var obs = this.look();\r\n this.org.brain.observe(obs);\r\n }\r\n\r\n look() {\r\n var env = this.org.env;\r\n var direction = this.getAbsoluteDirection();\r\n var addCol = 0;\r\n var addRow = 0;\r\n switch(direction) {\r\n case Directions.up:\r\n addRow = -1;\r\n break;\r\n case Directions.down:\r\n addRow = 1;\r\n break;\r\n case Directions.right:\r\n addCol = 1;\r\n break;\r\n case Directions.left:\r\n addCol = -1;\r\n break;\r\n }\r\n var start_col = this.getRealCol();\r\n var start_row = this.getRealRow();\r\n var col = start_col;\r\n var row = start_row;\r\n var cell = null;\r\n for (var i=0; i 3){\r\n dir = 0;\r\n }\r\n return dir;\r\n }\r\n}\r\n\r\nmodule.exports = Directions;\n\n//# sourceURL=webpack:///./src/Organism/Directions.js?"); /***/ }), /***/ "./src/Organism/Organism.js": /*!**********************************!*\ !*** ./src/Organism/Organism.js ***! \**********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const CellStates = __webpack_require__(/*! ./Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst Neighbors = __webpack_require__(/*! ../Grid/Neighbors */ \"./src/Grid/Neighbors.js\");\r\nconst Hyperparams = __webpack_require__(/*! ../Hyperparameters */ \"./src/Hyperparameters.js\");\r\nconst Directions = __webpack_require__(/*! ./Directions */ \"./src/Organism/Directions.js\");\r\nconst Anatomy = __webpack_require__(/*! ./Anatomy */ \"./src/Organism/Anatomy.js\");\r\nconst Brain = __webpack_require__(/*! ./Perception/Brain */ \"./src/Organism/Perception/Brain.js\");\r\nconst FossilRecord = __webpack_require__(/*! ../Stats/FossilRecord */ \"./src/Stats/FossilRecord.js\");\r\n\r\nclass Organism {\r\n constructor(col, row, env, parent=null) {\r\n this.c = col;\r\n this.r = row;\r\n this.env = env;\r\n this.lifetime = 0;\r\n this.food_collected = 0;\r\n this.living = true;\r\n this.anatomy = new Anatomy(this)\r\n this.direction = Directions.down; // direction of movement\r\n this.rotation = Directions.up; // direction of rotation\r\n this.can_rotate = Hyperparams.moversCanRotate;\r\n this.move_count = 0;\r\n this.move_range = 4;\r\n this.ignore_brain_for = 0;\r\n this.mutability = 5;\r\n this.damage = 0;\r\n this.brain = new Brain(this);\r\n if (parent != null) {\r\n this.inherit(parent);\r\n }\r\n }\r\n\r\n inherit(parent) {\r\n this.move_range = parent.move_range;\r\n this.mutability = parent.mutability;\r\n this.species = parent.species;\r\n // this.birth_distance = parent.birth_distance;\r\n for (var c of parent.anatomy.cells){\r\n //deep copy parent cells\r\n this.anatomy.addInheritCell(c);\r\n }\r\n if(parent.anatomy.is_mover) {\r\n for (var i in parent.brain.decisions) {\r\n this.brain.decisions[i] = parent.brain.decisions[i];\r\n }\r\n }\r\n }\r\n\r\n // amount of food required before it can reproduce\r\n foodNeeded() {\r\n return this.anatomy.cells.length;\r\n }\r\n\r\n lifespan() {\r\n // console.log(Hyperparams.lifespanMultiplier)\r\n return this.anatomy.cells.length * Hyperparams.lifespanMultiplier;\r\n }\r\n\r\n maxHealth() {\r\n return this.anatomy.cells.length;\r\n }\r\n\r\n reproduce() {\r\n //produce mutated child\r\n //check nearby locations (is there room and a direct path)\r\n var org = new Organism(0, 0, this.env, this);\r\n if(Hyperparams.offspringRotate){\r\n org.rotation = Directions.getRandomDirection();\r\n }\r\n var prob = this.mutability;\r\n if (Hyperparams.useGlobalMutability){\r\n prob = Hyperparams.globalMutability;\r\n }\r\n else {\r\n //mutate the mutability\r\n if (Math.random() <= 0.5)\r\n org.mutability++;\r\n else{ \r\n org.mutability--;\r\n if (org.mutability < 1)\r\n org.mutability = 1;\r\n }\r\n } \r\n var mutated = false;\r\n if (Math.random() * 100 <= prob) {\r\n if (org.anatomy.is_mover && Math.random() * 100 <= 10) { \r\n if (org.anatomy.has_eyes) {\r\n org.brain.mutate();\r\n }\r\n org.move_range += Math.floor(Math.random() * 4) - 2;\r\n if (org.move_range <= 0){\r\n org.move_range = 1;\r\n };\r\n \r\n }\r\n else {\r\n mutated = org.mutate();\r\n }\r\n }\r\n\r\n var direction = Directions.getRandomScalar();\r\n var direction_c = direction[0];\r\n var direction_r = direction[1];\r\n var offset = (Math.floor(Math.random() * 3));\r\n var basemovement = this.anatomy.birth_distance;\r\n var new_c = this.c + (direction_c*basemovement) + (direction_c*offset);\r\n var new_r = this.r + (direction_r*basemovement) + (direction_r*offset);\r\n\r\n // console.log(org.isClear(new_c, new_r, org.rotation, true))\r\n if (org.isClear(new_c, new_r, org.rotation, true) && org.isStraightPath(new_c, new_r, this.c, this.r, this)){\r\n org.c = new_c;\r\n org.r = new_r;\r\n this.env.addOrganism(org);\r\n org.updateGrid();\r\n if (mutated) {\r\n FossilRecord.addSpecies(org, this.species);\r\n }\r\n else {\r\n org.species.addPop();\r\n }\r\n }\r\n this.food_collected -= this.foodNeeded();\r\n\r\n }\r\n\r\n mutate() {\r\n var choice = Math.floor(Math.random() * 100);\r\n var mutated = false;\r\n if (choice <= Hyperparams.addProb) {\r\n // add cell\r\n // console.log(\"add cell\")\r\n\r\n var branch = this.anatomy.getRandomCell();\r\n var state = CellStates.getRandomLivingType();//branch.state;\r\n var growth_direction = Neighbors.all[Math.floor(Math.random() * Neighbors.all.length)]\r\n var c = branch.loc_col+growth_direction[0];\r\n var r = branch.loc_row+growth_direction[1];\r\n if (this.anatomy.canAddCellAt(c, r)){\r\n mutated = true;\r\n this.anatomy.addRandomizedCell(state, c, r);\r\n }\r\n }\r\n else if (choice <= Hyperparams.addProb + Hyperparams.changeProb){\r\n // change cell\r\n var cell = this.anatomy.getRandomCell();\r\n var state = CellStates.getRandomLivingType();\r\n // console.log(\"change cell\", state)\r\n this.anatomy.replaceCell(state, cell.loc_col, cell.loc_row);\r\n mutated = true;\r\n }\r\n else if (choice <= Hyperparams.addProb + Hyperparams.changeProb + Hyperparams.removeProb){\r\n // remove cell\r\n // console.log(\"remove cell\")\r\n\r\n if(this.anatomy.cells.length > 1) {\r\n var cell = this.anatomy.getRandomCell();\r\n mutated = this.anatomy.removeCell(cell.loc_col, cell.loc_row);\r\n }\r\n }\r\n return mutated;\r\n }\r\n\r\n attemptMove() {\r\n var direction = Directions.scalars[this.direction];\r\n var direction_c = direction[0];\r\n var direction_r = direction[1];\r\n var new_c = this.c + direction_c;\r\n var new_r = this.r + direction_r;\r\n if (this.isClear(new_c, new_r)) {\r\n for (var cell of this.anatomy.cells) {\r\n var real_c = this.c + cell.rotatedCol(this.rotation);\r\n var real_r = this.r + cell.rotatedRow(this.rotation);\r\n this.env.changeCell(real_c, real_r, CellStates.empty, null);\r\n }\r\n this.c = new_c;\r\n this.r = new_r;\r\n this.updateGrid();\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n attemptRotate() {\r\n if(!this.can_rotate){\r\n this.direction = Directions.getRandomDirection();\r\n this.move_count = 0;\r\n return true;\r\n }\r\n var new_rotation = Directions.getRandomDirection();\r\n if(this.isClear(this.c, this.r, new_rotation)){\r\n for (var cell of this.anatomy.cells) {\r\n var real_c = this.c + cell.rotatedCol(this.rotation);\r\n var real_r = this.r + cell.rotatedRow(this.rotation);\r\n this.env.changeCell(real_c, real_r, CellStates.empty, null);\r\n }\r\n this.rotation = new_rotation;\r\n this.direction = Directions.getRandomDirection();\r\n this.updateGrid();\r\n this.move_count = 0;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n changeDirection(dir) {\r\n this.direction = dir;\r\n this.move_count = 0;\r\n }\r\n\r\n // assumes either c1==c2 or r1==r2, returns true if there is a clear path from point 1 to 2\r\n isStraightPath(c1, r1, c2, r2, parent){\r\n if (c1 == c2) {\r\n if (r1 > r2){\r\n var temp = r2;\r\n r2 = r1;\r\n r1 = temp;\r\n }\r\n for (var i=r1; i!=r2; i++) {\r\n var cell = this.env.grid_map.cellAt(c1, i)\r\n if (!this.isPassableCell(cell, parent)){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n else {\r\n if (c1 > c2){\r\n var temp = c2;\r\n c2 = c1;\r\n c1 = temp;\r\n }\r\n for (var i=c1; i!=c2; i++) {\r\n var cell = this.env.grid_map.cellAt(i, r1);\r\n if (!this.isPassableCell(cell, parent)){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n }\r\n\r\n isPassableCell(cell, parent){\r\n return cell != null && (cell.state == CellStates.empty || cell.owner == this || cell.owner == parent || cell.state == CellStates.food);\r\n }\r\n\r\n isClear(col, row, rotation=this.rotation, ignore_armor=false) {\r\n for(var loccell of this.anatomy.cells) {\r\n var cell = this.getRealCell(loccell, col, row, rotation);\r\n if (cell==null) {\r\n return false;\r\n }\r\n // console.log(cell.owner == this)\r\n if (cell.owner==this || cell.state==CellStates.empty || (!Hyperparams.foodBlocksReproduction && cell.state==CellStates.food) || (ignore_armor && loccell.state==CellStates.armor && cell.state==CellStates.food)){\r\n continue;\r\n }\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n harm() {\r\n this.damage++;\r\n if (this.damage >= this.maxHealth() || Hyperparams.instaKill) {\r\n this.die();\r\n }\r\n }\r\n\r\n die() {\r\n for (var cell of this.anatomy.cells) {\r\n var real_c = this.c + cell.rotatedCol(this.rotation);\r\n var real_r = this.r + cell.rotatedRow(this.rotation);\r\n this.env.changeCell(real_c, real_r, CellStates.food, null);\r\n }\r\n this.species.decreasePop();\r\n this.living = false;\r\n }\r\n\r\n updateGrid() {\r\n for (var cell of this.anatomy.cells) {\r\n var real_c = this.c + cell.rotatedCol(this.rotation);\r\n var real_r = this.r + cell.rotatedRow(this.rotation);\r\n this.env.changeCell(real_c, real_r, cell.state, cell);\r\n }\r\n }\r\n\r\n update() {\r\n this.lifetime++;\r\n if (this.lifetime > this.lifespan()) {\r\n this.die();\r\n return this.living;\r\n }\r\n if (this.food_collected >= this.foodNeeded()) {\r\n this.reproduce();\r\n }\r\n for (var cell of this.anatomy.cells) {\r\n cell.performFunction();\r\n if (!this.living)\r\n return this.living\r\n }\r\n \r\n if (this.anatomy.is_mover) {\r\n this.move_count++;\r\n var changed_dir = false;\r\n if (this.ignore_brain_for == 0){\r\n changed_dir = this.brain.decide();\r\n } \r\n else{\r\n this.ignore_brain_for --;\r\n }\r\n var moved = this.attemptMove();\r\n if ((this.move_count > this.move_range && !changed_dir) || !moved){\r\n var rotated = this.attemptRotate();\r\n if (!rotated) {\r\n this.changeDirection(Directions.getRandomDirection());\r\n if (changed_dir)\r\n this.ignore_brain_for = this.move_range + 1;\r\n }\r\n }\r\n }\r\n\r\n return this.living;\r\n }\r\n\r\n getRealCell(local_cell, c=this.c, r=this.r, rotation=this.rotation){\r\n var real_c = c + local_cell.rotatedCol(rotation);\r\n var real_r = r + local_cell.rotatedRow(rotation);\r\n return this.env.grid_map.cellAt(real_c, real_r);\r\n }\r\n\r\n}\r\n\r\nmodule.exports = Organism;\r\n\n\n//# sourceURL=webpack:///./src/Organism/Organism.js?"); /***/ }), /***/ "./src/Organism/Perception/Brain.js": /*!******************************************!*\ !*** ./src/Organism/Perception/Brain.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const Hyperparams = __webpack_require__(/*! ../../Hyperparameters */ \"./src/Hyperparameters.js\");\r\nconst Directions = __webpack_require__(/*! ../Directions */ \"./src/Organism/Directions.js\");\r\nconst CellStates = __webpack_require__(/*! ../Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\n\r\nconst Decision = {\r\n neutral: 0,\r\n retreat: 1,\r\n chase: 2,\r\n getRandom: function(){\r\n return Math.floor(Math.random() * 3);\r\n },\r\n getRandomNonNeutral: function() {\r\n return Math.floor(Math.random() * 2)+1;\r\n }\r\n}\r\n\r\nclass Brain {\r\n constructor(owner){\r\n this.owner = owner;\r\n this.observations = [];\r\n\r\n // corresponds to CellTypes\r\n this.decisions = [];\r\n this.decisions[CellStates.empty.name] = Decision.neutral;\r\n this.decisions[CellStates.food.name] = Decision.chase;\r\n this.decisions[CellStates.wall.name] = Decision.neutral;\r\n this.decisions[CellStates.mouth.name] = Decision.neutral;\r\n this.decisions[CellStates.producer.name] = Decision.neutral;\r\n this.decisions[CellStates.mover.name] = Decision.neutral;\r\n this.decisions[CellStates.killer.name] = Decision.retreat;\r\n this.decisions[CellStates.armor.name] = Decision.neutral;\r\n this.decisions[CellStates.eye.name] = Decision.neutral;\r\n }\r\n\r\n randomizeDecisions() {\r\n // randomize the non obvious decisions\r\n this.decisions[CellStates.mouth.name] = Decision.getRandom();\r\n this.decisions[CellStates.producer.name] = Decision.getRandom();\r\n this.decisions[CellStates.mover.name] = Decision.getRandom();\r\n this.decisions[CellStates.armor.name] = Decision.getRandom();\r\n this.decisions[CellStates.eye.name] = Decision.getRandom();\r\n }\r\n\r\n observe(observation) {\r\n this.observations.push(observation);\r\n }\r\n\r\n decide() {\r\n var decision = Decision.neutral;\r\n var closest = Hyperparams.lookRange + 1;\r\n var move_direction = 0;\r\n for (var obs of this.observations) {\r\n if (obs.cell == null || obs.cell.owner == this.owner) {\r\n continue;\r\n }\r\n if (obs.distance < closest) {\r\n // console.log(obs.cell.state)\r\n decision = this.decisions[obs.cell.state.name];\r\n // console.log(decision)\r\n move_direction = obs.direction;\r\n closest = obs.distance;\r\n }\r\n }\r\n this.observations = [];\r\n if (decision == Decision.chase) {\r\n this.owner.changeDirection(move_direction);\r\n return true;\r\n }\r\n else if (decision == Decision.retreat) {\r\n this.owner.changeDirection(Directions.getOppositeDirection(move_direction));\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n mutate() {\r\n this.decisions[CellStates.getRandomName()] = Decision.getRandom();\r\n this.decisions[CellStates.empty.name] = Decision.neutral; // if the empty cell has a decision it gets weird\r\n }\r\n}\r\n\r\nmodule.exports = Brain;\n\n//# sourceURL=webpack:///./src/Organism/Perception/Brain.js?"); /***/ }), /***/ "./src/Organism/Perception/Observation.js": /*!************************************************!*\ !*** ./src/Organism/Perception/Observation.js ***! \************************************************/ /*! no static exports found */ /***/ (function(module, exports) { eval("class Observation {\r\n constructor(cell, distance, direction){\r\n this.cell = cell;\r\n this.distance = distance;\r\n this.direction = direction;\r\n }\r\n}\r\n\r\nmodule.exports = Observation;\n\n//# sourceURL=webpack:///./src/Organism/Perception/Observation.js?"); /***/ }), /***/ "./src/Rendering/ColorScheme.js": /*!**************************************!*\ !*** ./src/Rendering/ColorScheme.js ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const CellStates = __webpack_require__(/*! ../Organism/Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\n\r\nvar color_scheme = {\r\n \"empty\":\"#0E1318\",\r\n \"food\":\"#2F7AB7\",\r\n \"wall\":\"gray\",\r\n \"mouth\":\"#DEB14D\",\r\n \"producer\":\"#15DE59\",\r\n \"mover\":\"#60D4FF\",\r\n \"killer\":\"#F82380\",\r\n \"armor\":\"#7230DB\",\r\n \"eye\":\"#B6C1EA\",\r\n \"eye-slit\": \"#0E1318\"\r\n}\r\n\r\n// Renderer controls access to a canvas. There is one renderer for each canvas\r\nclass ColorScheme {\r\n constructor(world_env, editor_env) {\r\n this.world_env = world_env;\r\n this.editor_env = editor_env;\r\n }\r\n\r\n loadColorScheme() {\r\n for (var state of CellStates.all) {\r\n state.color = color_scheme[state.name];\r\n }\r\n CellStates.eye.slit_color=color_scheme['eye-slit']\r\n for (var cell_type in color_scheme) {\r\n $('#'+cell_type+'.cell-type ').css('background-color', color_scheme[cell_type]);\r\n $('#'+cell_type+'.cell-legend-type').css('background-color', color_scheme[cell_type]);\r\n \r\n }\r\n this.world_env.renderer.renderFullGrid(this.world_env.grid_map.grid);\r\n this.editor_env.renderer.renderFullGrid(this.editor_env.grid_map.grid);\r\n }\r\n}\r\n\r\nmodule.exports = ColorScheme;\n\n//# sourceURL=webpack:///./src/Rendering/ColorScheme.js?"); /***/ }), /***/ "./src/Rendering/Renderer.js": /*!***********************************!*\ !*** ./src/Rendering/Renderer.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("// const CellTypes = require(\"../Organism/Cell/CellTypes\");\r\nconst CellStates = __webpack_require__(/*! ../Organism/Cell/CellStates */ \"./src/Organism/Cell/CellStates.js\");\r\nconst Directions = __webpack_require__(/*! ../Organism/Directions */ \"./src/Organism/Directions.js\");\r\n\r\n// Renderer controls access to a canvas. There is one renderer for each canvas\r\nclass Renderer {\r\n constructor(canvas_id, container_id, cell_size) {\r\n this.cell_size = cell_size;\r\n this.canvas = document.getElementById(canvas_id);\r\n this.ctx = this.canvas.getContext(\"2d\");\r\n this.fillWindow(container_id)\r\n\t\tthis.height = this.canvas.height;\r\n this.width = this.canvas.width;\r\n this.cells_to_render = new Set();\r\n this.cells_to_highlight = new Set();\r\n this.highlighted_cells = new Set();\r\n }\r\n\r\n fillWindow(container_id) {\r\n this.fillShape($('#'+container_id).height(), $('#'+container_id).width());\r\n }\r\n\r\n fillShape(height, width) {\r\n this.canvas.width = width;\r\n this.canvas.height = height;\r\n this.height = this.canvas.height;\r\n this.width = this.canvas.width;\r\n }\r\n\r\n clear() {\r\n this.ctx.fillStyle = 'white';\r\n this.ctx.fillRect(0, 0, this.height, this.width);\r\n }\r\n\r\n renderFullGrid(grid) {\r\n for (var col of grid) {\r\n for (var cell of col){\r\n this.renderCell(cell);\r\n }\r\n }\r\n }\r\n\r\n renderCells() {\r\n for (var cell of this.cells_to_render) {\r\n this.renderCell(cell);\r\n }\r\n this.cells_to_render.clear();\r\n }\r\n\r\n renderCell(cell) {\r\n cell.state.render(this.ctx, cell, this.cell_size);\r\n }\r\n\r\n renderOrganism(org) {\r\n for(var org_cell of org.anatomy.cells) {\r\n var cell = org.getRealCell(org_cell);\r\n this.renderCell(cell);\r\n }\r\n }\r\n\r\n addToRender(cell) {\r\n if (this.highlighted_cells.has(cell)){\r\n this.cells_to_highlight.add(cell);\r\n }\r\n this.cells_to_render.add(cell);\r\n }\r\n\r\n renderHighlights() {\r\n for (var cell of this.cells_to_highlight) {\r\n this.renderCellHighlight(cell);\r\n this.highlighted_cells.add(cell);\r\n }\r\n this.cells_to_highlight.clear();\r\n \r\n }\r\n\r\n highlightOrganism(org) {\r\n for(var org_cell of org.anatomy.cells) {\r\n var cell = org.getRealCell(org_cell);\r\n this.cells_to_highlight.add(cell);\r\n }\r\n }\r\n\r\n highlightCell(cell) {\r\n this.cells_to_highlight.add(cell);\r\n }\r\n\r\n renderCellHighlight(cell, color=\"yellow\") {\r\n this.renderCell(cell);\r\n this.ctx.fillStyle = color;\r\n this.ctx.globalAlpha = 0.5;\r\n this.ctx.fillRect(cell.x, cell.y, this.cell_size, this.cell_size);\r\n this.ctx.globalAlpha = 1;\r\n this.highlighted_cells.add(cell);\r\n }\r\n\r\n clearAllHighlights(clear_to_highlight=false) {\r\n for (var cell of this.highlighted_cells) {\r\n this.renderCell(cell);\r\n }\r\n this.highlighted_cells.clear();\r\n if (clear_to_highlight) {\r\n this.cells_to_highlight.clear();\r\n }\r\n }\r\n}\r\n\r\n// $(\"body\").mousemove(function(e) {\r\n// console.log(\"hello\");\r\n// });\r\n\r\nmodule.exports = Renderer;\r\n\n\n//# sourceURL=webpack:///./src/Rendering/Renderer.js?"); /***/ }), /***/ "./src/Stats/FossilRecord.js": /*!***********************************!*\ !*** ./src/Stats/FossilRecord.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("const Species = __webpack_require__(/*! ./Species */ \"./src/Stats/Species.js\");\r\n\r\nconst FossilRecord = {\r\n init: function(){\r\n this.extant_species = [];\r\n this.extinct_species = [];\r\n\r\n // if an organism has fewer than this cumulative pop, discard them\r\n this.discard_pop = 5;\r\n },\r\n\r\n setEnv: function(env) {\r\n this.env = env;\r\n },\r\n\r\n addSpecies: function(org, ancestor) {\r\n console.log(\"Adding Species\")\r\n var new_species = new Species(org.anatomy, ancestor, this.env.total_ticks)\r\n this.extant_species.push(new_species);\r\n org.species = new_species;\r\n return new_species;\r\n },\r\n\r\n fossilize: function(species) {\r\n species.end_tick = this.env.total_ticks;\r\n for (i in this.extant_species) {\r\n var s = this.extant_species[i];\r\n if (s == species) {\r\n this.extant_species.splice(i, 1);\r\n if (species.cumulative_pop <= this.discard_pop) {\r\n return false;\r\n }\r\n this.extinct_species.push(s);\r\n console.log(\"Extant:\", this.extant_species.length)\r\n console.log(\"Extinct:\", this.extinct_species.length)\r\n return true;\r\n }\r\n }\r\n },\r\n\r\n clear_record: function() {\r\n this.species = [];\r\n },\r\n\r\n}\r\n\r\nFossilRecord.init();\r\n\r\nmodule.exports = FossilRecord;\n\n//# sourceURL=webpack:///./src/Stats/FossilRecord.js?"); /***/ }), /***/ "./src/Stats/Species.js": /*!******************************!*\ !*** ./src/Stats/Species.js ***! \******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { eval("class Species {\r\n constructor(anatomy, ancestor, start_tick) {\r\n this.anatomy = anatomy;\r\n this.ancestor = ancestor;\r\n this.population = 1;\r\n this.cumulative_pop = 1;\r\n this.start_tick = start_tick;\r\n this.end_tick = -1;\r\n this.color = '#asdfasdf';\r\n this.name = \"crabuloid\";\r\n this.extinct = false;\r\n }\r\n\r\n addPop() {\r\n this.population++;\r\n this.cumulative_pop++;\r\n }\r\n\r\n decreasePop() {\r\n this.population--;\r\n if (this.population <= 0) {\r\n this.extinct = true;\r\n console.log(\"Extinction\");\r\n const FossilRecord = __webpack_require__(/*! ./FossilRecord */ \"./src/Stats/FossilRecord.js\");\r\n FossilRecord.fossilize(this);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = Species;\n\n//# sourceURL=webpack:///./src/Stats/Species.js?"); /***/ }), /***/ "./src/index.js": /*!**********************!*\ !*** ./src/index.js ***! \**********************/ /*! no exports provided */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Engine */ \"./src/Engine.js\");\n/* harmony import */ var _Engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_Engine__WEBPACK_IMPORTED_MODULE_0__);\n\r\n\r\n\r\n\r\n$('document').ready(function(){\r\n let isMobile = mobileCheck();\r\n if (isMobile) {\r\n alert(\"Though the simulation still works on mobile, most features are disabled. Try it on desktop for the full experience!\");\r\n $('.control-panel').css('display', 'none');\r\n }\r\n var engine = new _Engine__WEBPACK_IMPORTED_MODULE_0___default.a();\r\n engine.start(60);\r\n});\r\n\r\nfunction mobileCheck() {\r\n let check = false;\r\n (function(a){if(/(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(a)||/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(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);\r\n return check;\r\n};\n\n//# sourceURL=webpack:///./src/index.js?"); /***/ }) /******/ });