Added eye editing stuff
This commit is contained in:
@@ -28,7 +28,6 @@ class ControlPanel {
|
||||
$('#maximize').click ( function() {
|
||||
$('.control-panel').css('display', 'grid');
|
||||
$('.hot-controls').css('display', 'none');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,26 +88,11 @@ class ControlPanel {
|
||||
|
||||
defineHyperparameterControls() {
|
||||
$('#food-prod-prob').change(function() {
|
||||
var food_prob = $('#food-prod-prob').val();
|
||||
if ($('#fixed-ratio').is(":checked")) {
|
||||
Hyperparams.foodProdProb = food_prob;
|
||||
Hyperparams.calcProducerFoodRatio(false);
|
||||
$('#lifespan-multiplier').val(Hyperparams.lifespanMultiplier);
|
||||
}
|
||||
else{
|
||||
Hyperparams.foodProdProb = food_prob;
|
||||
}
|
||||
var food_prob =
|
||||
Hyperparams.foodProdProb = $('#food-prod-prob').val();;
|
||||
}.bind(this));
|
||||
$('#lifespan-multiplier').change(function() {
|
||||
var lifespan = $('#lifespan-multiplier').val();
|
||||
if ($('#fixed-ratio').is(":checked")) {
|
||||
Hyperparams.lifespanMultiplier = lifespan;
|
||||
Hyperparams.calcProducerFoodRatio(true);
|
||||
$('#food-prod-prob').val(Hyperparams.foodProdProb);
|
||||
}
|
||||
else {
|
||||
Hyperparams.lifespanMultiplier = lifespan;
|
||||
}
|
||||
Hyperparams.lifespanMultiplier = $('#lifespan-multiplier').val();
|
||||
}.bind(this));
|
||||
|
||||
$('#mover-rot').change(function() {
|
||||
@@ -120,6 +104,9 @@ class ControlPanel {
|
||||
$('#insta-kill').change(function() {
|
||||
Hyperparams.instaKill = this.checked;
|
||||
});
|
||||
$('#look-range').change(function() {
|
||||
Hyperparams.lookRange = $('#look-range').val();
|
||||
});
|
||||
|
||||
$('#evolved-mutation').change( function() {
|
||||
if (this.checked) {
|
||||
@@ -164,7 +151,6 @@ class ControlPanel {
|
||||
Hyperparams.setDefaults();
|
||||
$('#food-prod-prob').val(Hyperparams.foodProdProb);
|
||||
$('#lifespan-multiplier').val(Hyperparams.lifespanMultiplier);
|
||||
$('#fixed-ratio').prop('checked', true);
|
||||
$('#mover-rot').prop('checked', Hyperparams.moversCanRotate);
|
||||
$('#offspring-rot').prop('checked', Hyperparams.offspringRotate);
|
||||
$('#insta-kill').prop('checked', Hyperparams.instaKill);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const CanvasController = require("./CanvasController");
|
||||
const Modes = require("./ControlModes");
|
||||
const CellTypes = require("../Organism/Cell/CellTypes");
|
||||
const Directions = require("../Organism/Directions");
|
||||
|
||||
class EditorController extends CanvasController{
|
||||
constructor(env, canvas) {
|
||||
@@ -23,11 +24,39 @@ class EditorController extends CanvasController{
|
||||
|
||||
mouseUp(){}
|
||||
|
||||
getCurLocalCell(){
|
||||
console.log(this.env.organism.getLocalCell(this.mouse_c-this.env.organism.c, this.mouse_r-this.env.organism.r))
|
||||
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;
|
||||
if (this.left_click)
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
if (this.left_click){
|
||||
if(this.edit_cell_type == CellTypes.eye) {
|
||||
if (this.cur_cell.type == CellTypes.eye){
|
||||
var loc_cell = this.getCurLocalCell();
|
||||
var dir = loc_cell.eye.direction;
|
||||
dir = Directions.rotateRight(dir);
|
||||
loc_cell.eye.direction = dir;
|
||||
this.cur_cell.direction = dir;
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
}
|
||||
else {
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
var loc_cell = this.getCurLocalCell();
|
||||
loc_cell.eye.direction = Directions.up;
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.env.addCellToOrg(this.mouse_c, this.mouse_r, this.edit_cell_type);
|
||||
}
|
||||
}
|
||||
if (this.right_click)
|
||||
this.env.removeCellFromOrg(this.mouse_c, this.mouse_r);
|
||||
}
|
||||
@@ -55,6 +84,9 @@ class EditorController extends CanvasController{
|
||||
case "armor":
|
||||
self.edit_cell_type = CellTypes.armor;
|
||||
break;
|
||||
case "eye":
|
||||
self.edit_cell_type = CellTypes.eye;
|
||||
break;
|
||||
}
|
||||
$(".cell-type" ).css( "border-color", "black" );
|
||||
var selected = '#'+this.id+'.cell-type';
|
||||
|
||||
@@ -94,6 +94,7 @@ class EnvironmentController extends CanvasController{
|
||||
}
|
||||
if (this.cur_org != null){
|
||||
this.control_panel.setEditorOrganism(this.cur_org);
|
||||
console.log(this.cur_org)
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -139,7 +140,7 @@ class EnvironmentController extends CanvasController{
|
||||
var c = this.cur_cell.col + loc[0];
|
||||
var r = this.cur_cell.row + loc[1];
|
||||
var cell = this.env.grid_map.cellAt(c, r);
|
||||
if (cell.owner != null)
|
||||
if (cell != null && cell.owner != null)
|
||||
return cell.owner;
|
||||
}
|
||||
return null;
|
||||
@@ -150,7 +151,7 @@ class EnvironmentController extends CanvasController{
|
||||
var c = this.cur_cell.col + loc[0];
|
||||
var r = this.cur_cell.row + loc[1];
|
||||
var cell = this.env.grid_map.cellAt(c, r);
|
||||
if (cell.owner != null)
|
||||
if (cell != null && cell.owner != null)
|
||||
cell.owner.die();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user