Added color scheme/better brain
This commit is contained in:
@@ -173,9 +173,9 @@ class ControlPanel {
|
||||
defineModeControls() {
|
||||
var self = this;
|
||||
$('.edit-mode-btn').click( function() {
|
||||
var prev_mode = self.env_controller.mode;
|
||||
$('#cell-selections').css('display', 'none');
|
||||
$('#organism-options').css('display', 'none');
|
||||
self.editor_controller.clearDetailsPanel();
|
||||
switch(this.id){
|
||||
case "food-drop":
|
||||
self.setMode(Modes.FoodDrop);
|
||||
@@ -191,8 +191,7 @@ class ControlPanel {
|
||||
break;
|
||||
case "edit":
|
||||
self.setMode(Modes.Edit);
|
||||
$('#cell-selections').css('display', 'block');
|
||||
$('#organism-options').css('display', 'block');
|
||||
self.editor_controller.setEditorPanel();
|
||||
break;
|
||||
case "drop-org":
|
||||
self.setMode(Modes.Clone);
|
||||
@@ -203,7 +202,6 @@ class ControlPanel {
|
||||
}
|
||||
$('.edit-mode-btn').css('background-color', '#9099c2');
|
||||
$('#'+this.id).css('background-color', '#81d2c7');
|
||||
|
||||
});
|
||||
|
||||
$('.reset-view').click( function(){
|
||||
@@ -224,6 +222,7 @@ class ControlPanel {
|
||||
}.bind(this));
|
||||
$('#clear-editor').click( function() {
|
||||
this.engine.organism_editor.clear();
|
||||
this.editor_controller.setEditorPanel();
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
@@ -241,6 +240,8 @@ class ControlPanel {
|
||||
|
||||
setEditorOrganism(org) {
|
||||
this.engine.organism_editor.setOrganismToCopyOf(org);
|
||||
this.editor_controller.clearDetailsPanel();
|
||||
this.editor_controller.setDetailsPanel();
|
||||
}
|
||||
|
||||
changeEngineSpeed(change_val) {
|
||||
@@ -259,10 +260,6 @@ class ControlPanel {
|
||||
$('#avg-mut').text("Average Mutation Rate: " + Math.round(this.engine.env.averageMutability() * 100) / 100);
|
||||
$('#largest-org').text("Largest Organism: " + this.engine.env.largest_cell_count + " cells");
|
||||
$('#reset-count').text("Auto reset count: " + this.engine.env.reset_count);
|
||||
if (this.editor_controller.env.organism.cells.length > 1)
|
||||
$('#editor-cell-count').text(this.editor_controller.env.organism.cells.length+' cells');
|
||||
else
|
||||
$('#editor-cell-count').text('1 cell');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ const CanvasController = require("./CanvasController");
|
||||
const Modes = require("./ControlModes");
|
||||
const CellStates = require("../Organism/Cell/CellStates");
|
||||
const Directions = require("../Organism/Directions");
|
||||
const Hyperparams = require("../Hyperparameters");
|
||||
|
||||
class EditorController extends CanvasController{
|
||||
constructor(env, canvas) {
|
||||
@@ -10,7 +11,7 @@ class EditorController extends CanvasController{
|
||||
this.edit_cell_type = null;
|
||||
this.highlight_org = false;
|
||||
this.defineCellTypeSelection();
|
||||
this.defineEditorOptions();
|
||||
this.defineEditorDetails();
|
||||
}
|
||||
|
||||
mouseMove() {
|
||||
@@ -42,10 +43,13 @@ class EditorController extends CanvasController{
|
||||
}
|
||||
if (this.right_click)
|
||||
this.env.removeCellFromOrg(this.mouse_c, this.mouse_r);
|
||||
this.setBrainPanelVisibility();
|
||||
this.setMoveRangeVisibility();
|
||||
}
|
||||
|
||||
updateDetails() {
|
||||
$('#birth-distance').val(this.env.organism.birth_distance);
|
||||
$('.cell-count').text("Cell count: "+this.env.organism.cells.length);
|
||||
}
|
||||
|
||||
defineCellTypeSelection() {
|
||||
@@ -77,11 +81,112 @@ class EditorController extends CanvasController{
|
||||
});
|
||||
}
|
||||
|
||||
defineEditorOptions() {
|
||||
$('#birth-distance').change ( function() {
|
||||
this.env.organism.birth_distance = parseInt($('#birth-distance').val());
|
||||
defineEditorDetails() {
|
||||
this.details_html = $('#organism-details');
|
||||
this.edit_details_html = $('#edit-organism-details');
|
||||
|
||||
this.decision_names = ["ignore", "move away", "move towards"];
|
||||
|
||||
$('#birth-distance-edit').change ( function() {
|
||||
this.env.organism.birth_distance = parseInt($('#birth-distance-edit').val());
|
||||
}.bind(this));
|
||||
$('#move-range-edit').change ( function() {
|
||||
this.env.organism.move_range = parseInt($('#move-range-edit').val());
|
||||
}.bind(this));
|
||||
$('#observation-type-edit').change ( function() {
|
||||
this.setBrainEditorValues($('#observation-type-edit').val());
|
||||
}.bind(this));
|
||||
$('#reaction-edit').change ( function() {
|
||||
var obs = $('#observation-type-edit').val();
|
||||
var decision = parseInt($('#reaction-edit').val());
|
||||
this.env.organism.brain.decisions[obs] = decision;
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
clearDetailsPanel() {
|
||||
$('#organism-details').css('display', 'none');
|
||||
$('#edit-organism-details').css('display', 'none');
|
||||
}
|
||||
|
||||
setDetailsPanel() {
|
||||
var org = this.env.organism;
|
||||
|
||||
$('.cell-count').text("Cell count: "+org.cells.length);
|
||||
$('#birth-distance').text("Reproduction Distance: "+org.birth_distance);
|
||||
$('#move-range').text("Move Range: "+org.move_range);
|
||||
$('#mutation-rate').text("Mutation Rate: "+org.mutability);
|
||||
if (Hyperparams.useGlobalMutability) {
|
||||
$('#mutation-rate').css('display', 'none');
|
||||
}
|
||||
else {
|
||||
$('#mutation-rate').css('display', 'block');
|
||||
}
|
||||
|
||||
this.setMoveRangeVisibility();
|
||||
|
||||
if (this.setBrainPanelVisibility()) {
|
||||
var chase_types = [];
|
||||
var retreat_types = [];
|
||||
for(var cell_name in org.brain.decisions) {
|
||||
var decision = org.brain.decisions[cell_name];
|
||||
if (decision == 1) {
|
||||
retreat_types.push(cell_name)
|
||||
}
|
||||
else if (decision == 2) {
|
||||
chase_types.push(cell_name);
|
||||
}
|
||||
}
|
||||
$('#chase-types').text("Move Towards: " + chase_types);
|
||||
$('#retreat-types').text("Move Away From: " + retreat_types);
|
||||
|
||||
}
|
||||
$('#organism-details').css('display', 'block');
|
||||
}
|
||||
|
||||
setEditorPanel() {
|
||||
this.clearDetailsPanel();
|
||||
var org = this.env.organism;
|
||||
|
||||
$('.cell-count').text("Cell count: "+org.cells.length);
|
||||
$('#birth-distance-edit').val(org.birth_distance);
|
||||
if (this.setMoveRangeVisibility()){
|
||||
$('#move-range-edit').val(org.move_range);
|
||||
}
|
||||
|
||||
if (this.setBrainPanelVisibility()){
|
||||
this.setBrainEditorValues($('#observation-type-edit').val());
|
||||
}
|
||||
|
||||
$('#cell-selections').css('display', 'grid');
|
||||
$('#edit-organism-details').css('display', 'block');
|
||||
}
|
||||
|
||||
setBrainPanelVisibility() {
|
||||
var org = this.env.organism;
|
||||
if (org.has_eyes && org.is_mover) {
|
||||
$('.brain-details').css('display', 'block');
|
||||
return true;
|
||||
}
|
||||
$('.brain-details').css('display', 'none');
|
||||
return false;
|
||||
}
|
||||
|
||||
setMoveRangeVisibility() {
|
||||
var org = this.env.organism;
|
||||
if (org.is_mover) {
|
||||
$('#move-range-cont').css('display', 'block');
|
||||
$('#move-range').css('display', 'block');
|
||||
return true;
|
||||
}
|
||||
$('#move-range-cont').css('display', 'none');
|
||||
$('#move-range').css('display', 'none');
|
||||
return false;
|
||||
}
|
||||
|
||||
setBrainEditorValues(name) {
|
||||
$('#observation-type-edit').val(name);
|
||||
var reaction = this.env.organism.brain.decisions[name];
|
||||
$('#reaction-edit').val(reaction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ class EnvironmentController extends CanvasController{
|
||||
}
|
||||
if (this.cur_org != null){
|
||||
this.control_panel.setEditorOrganism(this.cur_org);
|
||||
console.log(this.cur_org)
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user