Removed cruft

This commit is contained in:
MaxRobinsonTheGreat
2020-08-18 11:40:46 -06:00
parent 3f05fbe7f9
commit 3aa0aae4e2
8 changed files with 7 additions and 148 deletions

2
dist/js/bundle.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -28,10 +28,6 @@ class EditorController extends CanvasController{
return this.env.organism.getLocalCell(this.mouse_c-this.env.organism.c, this.mouse_r-this.env.organism.r);
}
setEyeDirection(){
}
editOrganism() {
if (this.edit_cell_type == null || this.mode != Modes.Edit)
return;

View File

@@ -4,8 +4,6 @@ const GridMap = require('../Grid/GridMap');
const Renderer = require('../Rendering/Renderer');
const CellStates = require('../Organism/Cell/CellStates');
const EditorController = require("../Controllers/EditorController");
const Cell = require("../Organism/Cell/GridCell");
const Eye = require('../Organism/Perception/Eye');
const Directions = require('../Organism/Directions');
class OrganismEditor extends Environment{

View File

@@ -1,10 +1,8 @@
const Environment = require('./Environment');
const Grid = require('../Grid/GridMap');
const Renderer = require('../Rendering/Renderer');
const GridMap = require('../Grid/GridMap');
const Organism = require('../Organism/Organism');
const CellStates = require('../Organism/Cell/CellStates');
const Cell = require('../Organism/Cell/GridCell');
const EnvironmentController = require('../Controllers/EnvironmentController');
class WorldEnvironment extends Environment{
@@ -54,12 +52,12 @@ class WorldEnvironment extends Environment{
OriginOfLife() {
var center = this.grid_map.getCenter();
var org = new Organism(center[0], center[1], this);
org.addDefaultCell(CellStates.eye, 0, 0);
org.addDefaultCell(CellStates.mouth, 1, 1);
org.addDefaultCell(CellStates.mover, 1, -1);
// org.addDefaultCell(CellStates.mouth, 0, 0);
// org.addDefaultCell(CellStates.producer, 1, 1);
// org.addDefaultCell(CellStates.producer, -1, -1);
// org.addDefaultCell(CellStates.eye, 0, 0);
// org.addDefaultCell(CellStates.mouth, 1, 1);
// org.addDefaultCell(CellStates.mover, 1, -1);
org.addDefaultCell(CellStates.mouth, 0, 0);
org.addDefaultCell(CellStates.producer, 1, 1);
org.addDefaultCell(CellStates.producer, -1, -1);
this.addOrganism(org);
}

View File

@@ -1,18 +0,0 @@
const CellTypes = {
empty: 0,
food: 1,
wall: 2,
mouth: 3,
producer: 4,
mover: 5,
killer: 6,
armor: 7,
eye: 8,
colors: ['#121D29', 'green', 'gray', 'orange', 'white', '#3493EB', 'red', 'purple', '#d4bb3f'],
names: ['Empty', 'Food', 'Wall', 'Mouth', 'Producer', 'Mover', 'Killer', 'Armor', 'Eye'],
getRandomLivingType: function() {
return Math.floor(Math.random() * 6) + 3;
}
}
module.exports = CellTypes;

View File

@@ -1,46 +0,0 @@
const CellStates = require("./CellStates");
const Directions = require("../Directions");;
const Eye = require("../Perception/Eye.js");
// A body cell defines the relative location of the cell in it's parent organism. It also defines their functional behavior.
class LocalCell{
constructor(state, loc_col, loc_row, eye=null){
this.state = state;
this.loc_col = loc_col;
this.loc_row = loc_row;
if (this.state == CellStates.eye){
this.eye = new Eye();
if (eye != null) {
this.eye.direction = eye.direction;
}
}
}
rotatedCol(dir){
switch(dir){
case Directions.up:
return this.loc_col;
case Directions.down:
return this.loc_col * -1;
case Directions.left:
return this.loc_row;
case Directions.right:
return this.loc_row * -1;
}
}
rotatedRow(dir){
switch(dir){
case Directions.up:
return this.loc_row;
case Directions.down:
return this.loc_row * -1;
case Directions.left:
return this.loc_col * -1;
case Directions.right:
return this.loc_col;
}
}
}
module.exports = LocalCell;

View File

@@ -1,13 +1,9 @@
// const CellTypes = require("./Cell/CellTypes");
const CellStates = require("../Organism/Cell/CellStates");
const Cell = require("./Cell/GridCell");
const GridMap = require("../Grid/GridMap");
const LocalCell = require("./Cell/LocalCell");
const BodyCellFactory = require("./Cell/BodyCells/BodyCellFactory");
const Neighbors = require("../Grid/Neighbors");
const Hyperparams = require("../Hyperparameters");
const Directions = require("./Directions");
const Eye = require("./Perception/Eye");
const Brain = require("./Perception/Brain");
const directions = [[0,1],[0,-1],[1,0],[-1,0]]
@@ -393,13 +389,6 @@ class Organism {
return this.env.grid_map.cellAt(real_c, real_r);
}
getRealCol(local_cell) {
return this.c + local_cell.rotatedCol(this.rotation);
}
getRealRow(local_cell) {
return this.r + local_cell.rotatedRow(this.rotation);
}
}
module.exports = Organism;

View File

@@ -1,58 +0,0 @@
const Directions = require("../Directions");
const Hyperparams = require("../../Hyperparameters");
const CellStates = require("../Cell/CellStates");
const Observation = require("./Observation")
class Eye {
constructor(direction=-1) {
this.direction = direction;
if (direction == -1){
this.direction = Directions.getRandomDirection();
}
}
getAbsoluteDirection(parent_dir) {
var dir = parent_dir + this.direction;
if (dir > 3)
dir -= 4;
return dir;
}
look(start_col, start_row, rotation, env) {
var direction = this.getAbsoluteDirection(rotation);
var addCol = 0;
var addRow = 0;
switch(direction) {
case Directions.up:
addRow = -1;
break;
case Directions.down:
addRow = 1;
break;
case Directions.right:
addCol = 1;
break;
case Directions.left:
addCol = -1;
break;
}
var col=start_col;
var row=start_row;
var cell = null;
for (var i=0; i<Hyperparams.lookRange; i++){
col+=addCol;
row+=addRow;
cell = env.grid_map.cellAt(col, row);
if (cell == null) {
break;
}
if (cell.state != CellStates.empty){
var distance = Math.abs(start_col-col) + Math.abs(start_row-row);
return new Observation(cell, distance, direction);
}
}
return new Observation(cell, Hyperparams.lookRange, direction);
}
}
module.exports = Eye;