Added eye cell

This commit is contained in:
MaxRobinsonTheGreat
2020-08-10 19:19:52 -06:00
parent a6cfc916c2
commit 6003686a13
8 changed files with 107 additions and 17 deletions

View File

@@ -7,9 +7,10 @@ const CellTypes = {
mover: 5,
killer: 6,
armor: 7,
colors: ['#121D29', 'green', 'gray', 'orange', 'white', '#3493eb', 'red', 'purple'],
eye: 8,
colors: ['#121D29', 'green', 'gray', 'orange', 'white', '#3493EB', 'red', 'purple', '#8D73A3'],
getRandomLivingType: function() {
return Math.floor(Math.random() * 5) + 3;
return Math.floor(Math.random() * 6) + 3;
}
}

View File

@@ -1,15 +1,24 @@
const CellTypes = require("./CellTypes");
const Directions = require("../Directions");
const Hyperparams = require("../../Hyperparameters");
const Eye = require("../Eye.js");
// A local cell is a lightweight container for a cell in an organism. It does not directly exist in the grid
class LocalCell{
constructor(type, loc_col, loc_row){
constructor(type, loc_col, loc_row, eye=null){
this.type = type;
this.loc_col = loc_col;
this.loc_row = loc_row;
if (this.type == CellTypes.eye){
this.eye = new Eye(this);
if (eye != null) {
this.eye.direction = eye.direction;
}
}
}
rotatedCol(dir){
switch(dir){
case Directions.up: