beautification, title, reset hyperparams

This commit is contained in:
MaxRobinsonTheGreat
2020-07-22 16:10:39 -06:00
parent b0292ae0e6
commit f0e725a8fa
7 changed files with 153 additions and 81 deletions

View File

@@ -29,12 +29,12 @@ class ControlPanel {
$('#fps').text("Target FPS: "+this.fps);
}.bind(this);
$('#pause-button').click(function() {
$('#pause-button').find("i").toggleClass("fa fa-pause");
$('#pause-button').find("i").toggleClass("fa fa-play");
if (this.engine.running) {
$('#pause-button').text("Play");
this.engine.stop();
}
else if (!this.engine.running){
$('#pause-button').text("Pause");
this.engine.start(this.fps);
}
}.bind(this));
@@ -146,6 +146,29 @@ class ControlPanel {
$('#food-blocks').change( function() {
Hyperparams.foodBlocksReproduction = this.checked;
});
$('#reset-rules').click( function() {
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);
$('#evolved-mutation').prop('checked', !Hyperparams.useGlobalMutability);
$('#add-prob').val(Hyperparams.addProb);
$('#change-prob').val(Hyperparams.changeProb);
$('#remove-prob').val(Hyperparams.removeProb);
$('#movers-produce').prop('checked', Hyperparams.moversCanProduce);
$('#food-blocks').prop('checked', Hyperparams.foodBlocksReproduction);
if (!Hyperparams.useGlobalMutability) {
$('.global-mutation-in').css('display', 'none');
$('#avg-mut').css('display', 'block');
}
else {
$('.global-mutation-in').css('display', 'block');
$('#avg-mut').css('display', 'none');
}
});
}
defineModeControls() {
@@ -154,13 +177,13 @@ class ControlPanel {
var prev_mode = self.env_controller.mode;
$('#cell-selections').css('display', 'none');
switch(this.id){
case "food":
case "food-drop":
self.setMode(Modes.FoodDrop);
break;
case "wall":
case "wall-drop":
self.setMode(Modes.WallDrop);
break;
case "kill":
case "click-kill":
self.setMode(Modes.ClickKill);
break;
case "select":
@@ -175,8 +198,8 @@ class ControlPanel {
self.env_controller.org_to_clone = self.engine.organism_editor.getCopyOfOrg();
break;
}
$('.edit-mode-btn').css('background-color', 'white');
$('#'+this.id).css('background-color', 'lightblue');
$('.edit-mode-btn').css('background-color', '#9099c2');
$('#'+this.id).css('background-color', '#81d2c7');
});

View File

@@ -7,7 +7,7 @@ const render_speed = 60;
class Engine{
constructor(){
this.fps = 60;
this.env = new Environment(5);
this.env = new Environment(3);
this.organism_editor = new OrganismEditor();
this.controlpanel = new ControlPanel(this);
this.env.OriginOfLife();

View File

@@ -1,27 +1,28 @@
const Neighbors = require("./Grid/Neighbors");
const Hyperparams = {
lifespanMultiplier: 100,
foodProdProb: 4,
foodProdProbScalar: 4,
killableNeighbors: Neighbors.adjacent,
edibleNeighbors: Neighbors.adjacent,
growableNeighbors: Neighbors.adjacent,
useGlobalMutability: false,
globalMutability: 5,
setDefaults: function() {
this.lifespanMultiplier= 100;
this.foodProdProb= 4;
this.foodProdProbScalar= 4;
this.killableNeighbors= Neighbors.adjacent;
this.edibleNeighbors= Neighbors.adjacent;
this.growableNeighbors= Neighbors.adjacent;
addProb: 33,
changeProb: 33,
removeProb: 33,
this.useGlobalMutability= false;
this.globalMutability= 5;
this.addProb= 33;
this.changeProb= 33;
this.removeProb= 33;
this.moversCanRotate= true;
this.offspringRotate= true;
moversCanRotate: true,
offspringRotate: true,
this.foodBlocksReproduction= true;
this.moversCanProduce= false;
foodBlocksReproduction: true,
moversCanProduce: false,
instaKill: false,
this.instaKill= false;
},
// calculates the optimal ratio where a producer cell is most likely to produce 1 food in its lifespan * a scalar of my choice :)
calcProducerFoodRatio : function(lifespan_fixed=true) {
@@ -54,4 +55,6 @@ const Hyperparams = {
}
}
Hyperparams.setDefaults();
module.exports = Hyperparams;