More hyperparameters!

This commit is contained in:
MaxRobinsonTheGreat
2020-07-20 14:03:16 -06:00
parent 3e137499f7
commit c94e137ae4
8 changed files with 369 additions and 35 deletions

289
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

4
dist/css/style.css vendored
View File

@@ -102,6 +102,10 @@ canvas {
background-color: gray;
}
.global-mutation-in {
display: none;
}
#editor-env {

41
dist/html/index.html vendored
View File

@@ -105,20 +105,6 @@
<br/>
<label for="fixed-ratio">Use fixed ratio</label>
<input type="checkbox" id="fixed-ratio" checked>
<br><br/>
<h4>Mutation Probabilities</h4>
<label for="add-prob">Add Cell:</label>
<input class="mut-prob" type="number" id="add-prob" min="0" max="100" value=33>
<br/>
<label for="change-prob">Change Cell:</label>
<input class="mut-prob" type="number" id="change-prob" min="0" max="100" value=33>
<br/>
<label for="remove-prob">Remove Cell:</label>
<input class="mut-prob" type="number" id="remove-prob" min="0" max="100" value=33>
<br/>
</div>
<div class='right-half'>
<h4>Organism Rotation</h4>
<label for="mover-rot">Movers can rotate</label>
<input type="checkbox" id="mover-rot" checked>
@@ -128,7 +114,32 @@
<br/>
<h4>Killer Cell Effects</h4>
<label for="insta-kill">One touch kill</label>
<input type="checkbox" id="insta-kill" >
<input type="checkbox" id="insta-kill">
</div>
<div class='right-half'>
<br><br/>
<h4>Mutation Rate</h4>
<label for="evolved-mutation">Use evolved mutation rate</label>
<input type="checkbox" id="evolved-mutation" checked>
<label class="global-mutation-in" for="global-mutation">Global mutation rate</label>
<input class="global-mutation-in" type="number" id="global-mutation" min="1" max="100" value=5 step="1">
<h4>Mutation Type Probabilities</h4>
<label for="add-prob">Add Cell:</label>
<input class="mut-prob" type="number" id="add-prob" min="0" max="100" value=33>
<br/>
<label for="change-prob">Change Cell:</label>
<input class="mut-prob" type="number" id="change-prob" min="0" max="100" value=33>
<br/>
<label for="remove-prob">Remove Cell:</label>
<input class="mut-prob" type="number" id="remove-prob" min="0" max="100" value=33>
<br/>
<label for="movers-produce">Movers can produce food</label>
<input type="checkbox" id="movers-produce">
<br/>
<label for="food-blocks">Food blocks reproduction</label>
<input type="checkbox" id="food-blocks" checked>
</div>
</div>
<div id='stats' class='tab'>

View File

@@ -96,6 +96,31 @@ class ControlPanel {
Hyperparams.lifespanMultiplier = lifespan;
}
}.bind(this));
$('#mover-rot').change(function() {
Hyperparams.moversCanRotate = this.checked;
});
$('#offspring-rot').change(function() {
Hyperparams.offspringRotate = this.checked;
});
$('#insta-kill').change(function() {
Hyperparams.instaKill = this.checked;
});
$('#evolved-mutation').change( function() {
if (this.checked) {
$('.global-mutation-in').css('display', 'none');
$('#avg-mut').css('display', 'block');
}
else {
$('.global-mutation-in').css('display', 'block');
$('#avg-mut').css('display', 'none');
}
Hyperparams.useGlobalMutability = !this.checked;
});
$('#global-mutation').change( function() {
Hyperparams.globalMutability = $('#global-mutation').val();
});
$('.mut-prob').change( function() {
switch(this.id){
case "add-prob":
@@ -115,15 +140,11 @@ class ControlPanel {
$('#change-prob').val(Math.floor(Hyperparams.changeProb));
$('#remove-prob').val(Math.floor(Hyperparams.removeProb));
});
$('#mover-rot').change(function() {
Hyperparams.moversCanRotate = this.checked;
$('#movers-produce').change( function() {
Hyperparams.moversCanProduce = this.checked;
});
$('#offspring-rot').change(function() {
Hyperparams.offspringRotate = this.checked;
});
$('#insta-kill').change(function() {
Hyperparams.instaKill = this.checked;
$('#food-blocks').change( function() {
Hyperparams.foodBlocksReproduction = this.checked;
});
}

View File

@@ -67,6 +67,14 @@ class EnvironmentController extends CanvasController{
}
}
dropWall(cell) {
}
dropFood(cell) {
}
}

View File

@@ -9,7 +9,7 @@ const Hyperparams = {
growableNeighbors: Neighbors.adjacent,
useGlobalMutability: false,
globalMutability: 0,
globalMutability: 5,
addProb: 33,
changeProb: 33,
@@ -18,6 +18,9 @@ const Hyperparams = {
moversCanRotate: true,
offspringRotate: true,
foodBlocksReproduction: true,
moversCanProduce: false,
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 :)

View File

@@ -58,7 +58,7 @@ function eatNeighborFood(self, n_cell, env){
}
function growFood(self, env){
if (self.owner.is_mover)
if (self.owner.is_mover && !Hyperparams.moversCanProduce)
return;
var prob = Hyperparams.foodProdProb;
if (Math.random() * 100 <= prob){

View File

@@ -134,13 +134,11 @@ class Organism {
var direction = Directions.getRandomScalar();
var direction_c = direction[0];
var direction_r = direction[1];
var offset = (Math.floor(Math.random() * 2)) * 2;
var offset = (Math.floor(Math.random() * 3)) * 1;
var basemovement = (Math.min(2+this.cells.length, 15));
var new_c = this.c + (direction_c*basemovement) + (direction_c*offset);
var new_r = this.r + (direction_r*basemovement) + (direction_r*offset);
var new_c = this.c + (direction_c*Math.min(this.cells.length*2, 15)) + (direction_c*offset);
var new_r = this.r + (direction_r*Math.min(this.cells.length*2, 15)) + (direction_r*offset);
// var new_c = Math.min(this.cells.length*2, 10);
// var new_r = Math.min(this.cells.length*2, 10);
if (org.isClear(new_c, new_r) && org.isStraightPath(new_c, new_r, this.c, this.r, this)){
org.c = new_c;
org.r = new_r;
@@ -149,8 +147,6 @@ class Organism {
}
this.food_collected -= this.foodNeeded();
}
mutate() {
@@ -271,9 +267,13 @@ class Organism {
isClear(col, row, rotation=this.rotation) {
for(var loccell of this.cells) {
var cell = this.getRealCell(loccell, col, row, rotation);
if(cell == null || cell.type != CellTypes.empty && cell.owner != this) {
if(cell==null) {
return false;
}
if (cell.owner==this || cell.type==CellTypes.empty || (!Hyperparams.foodBlocksReproduction && cell.type==CellTypes.food)){
continue;
}
return false;
}
return true;
}