More hyperparameters!
This commit is contained in:
289
dist/bundle.js
vendored
289
dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
4
dist/css/style.css
vendored
4
dist/css/style.css
vendored
@@ -102,6 +102,10 @@ canvas {
|
|||||||
background-color: gray;
|
background-color: gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.global-mutation-in {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#editor-env {
|
#editor-env {
|
||||||
|
|||||||
41
dist/html/index.html
vendored
41
dist/html/index.html
vendored
@@ -105,20 +105,6 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<label for="fixed-ratio">Use fixed ratio</label>
|
<label for="fixed-ratio">Use fixed ratio</label>
|
||||||
<input type="checkbox" id="fixed-ratio" checked>
|
<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>
|
<h4>Organism Rotation</h4>
|
||||||
<label for="mover-rot">Movers can rotate</label>
|
<label for="mover-rot">Movers can rotate</label>
|
||||||
<input type="checkbox" id="mover-rot" checked>
|
<input type="checkbox" id="mover-rot" checked>
|
||||||
@@ -128,7 +114,32 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<h4>Killer Cell Effects</h4>
|
<h4>Killer Cell Effects</h4>
|
||||||
<label for="insta-kill">One touch kill</label>
|
<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>
|
</div>
|
||||||
<div id='stats' class='tab'>
|
<div id='stats' class='tab'>
|
||||||
|
|||||||
@@ -96,6 +96,31 @@ class ControlPanel {
|
|||||||
Hyperparams.lifespanMultiplier = lifespan;
|
Hyperparams.lifespanMultiplier = lifespan;
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.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() {
|
$('.mut-prob').change( function() {
|
||||||
switch(this.id){
|
switch(this.id){
|
||||||
case "add-prob":
|
case "add-prob":
|
||||||
@@ -115,15 +140,11 @@ class ControlPanel {
|
|||||||
$('#change-prob').val(Math.floor(Hyperparams.changeProb));
|
$('#change-prob').val(Math.floor(Hyperparams.changeProb));
|
||||||
$('#remove-prob').val(Math.floor(Hyperparams.removeProb));
|
$('#remove-prob').val(Math.floor(Hyperparams.removeProb));
|
||||||
});
|
});
|
||||||
|
$('#movers-produce').change( function() {
|
||||||
$('#mover-rot').change(function() {
|
Hyperparams.moversCanProduce = this.checked;
|
||||||
Hyperparams.moversCanRotate = this.checked;
|
|
||||||
});
|
});
|
||||||
$('#offspring-rot').change(function() {
|
$('#food-blocks').change( function() {
|
||||||
Hyperparams.offspringRotate = this.checked;
|
Hyperparams.foodBlocksReproduction = this.checked;
|
||||||
});
|
|
||||||
$('#insta-kill').change(function() {
|
|
||||||
Hyperparams.instaKill = this.checked;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,14 @@ class EnvironmentController extends CanvasController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dropWall(cell) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dropFood(cell) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const Hyperparams = {
|
|||||||
growableNeighbors: Neighbors.adjacent,
|
growableNeighbors: Neighbors.adjacent,
|
||||||
|
|
||||||
useGlobalMutability: false,
|
useGlobalMutability: false,
|
||||||
globalMutability: 0,
|
globalMutability: 5,
|
||||||
|
|
||||||
addProb: 33,
|
addProb: 33,
|
||||||
changeProb: 33,
|
changeProb: 33,
|
||||||
@@ -18,6 +18,9 @@ const Hyperparams = {
|
|||||||
moversCanRotate: true,
|
moversCanRotate: true,
|
||||||
offspringRotate: true,
|
offspringRotate: true,
|
||||||
|
|
||||||
|
foodBlocksReproduction: true,
|
||||||
|
moversCanProduce: false,
|
||||||
|
|
||||||
instaKill: 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 :)
|
// calculates the optimal ratio where a producer cell is most likely to produce 1 food in its lifespan * a scalar of my choice :)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function eatNeighborFood(self, n_cell, env){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function growFood(self, env){
|
function growFood(self, env){
|
||||||
if (self.owner.is_mover)
|
if (self.owner.is_mover && !Hyperparams.moversCanProduce)
|
||||||
return;
|
return;
|
||||||
var prob = Hyperparams.foodProdProb;
|
var prob = Hyperparams.foodProdProb;
|
||||||
if (Math.random() * 100 <= prob){
|
if (Math.random() * 100 <= prob){
|
||||||
|
|||||||
@@ -134,13 +134,11 @@ class Organism {
|
|||||||
var direction = Directions.getRandomScalar();
|
var direction = Directions.getRandomScalar();
|
||||||
var direction_c = direction[0];
|
var direction_c = direction[0];
|
||||||
var direction_r = direction[1];
|
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)){
|
if (org.isClear(new_c, new_r) && org.isStraightPath(new_c, new_r, this.c, this.r, this)){
|
||||||
org.c = new_c;
|
org.c = new_c;
|
||||||
org.r = new_r;
|
org.r = new_r;
|
||||||
@@ -149,8 +147,6 @@ class Organism {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.food_collected -= this.foodNeeded();
|
this.food_collected -= this.foodNeeded();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutate() {
|
mutate() {
|
||||||
@@ -271,9 +267,13 @@ class Organism {
|
|||||||
isClear(col, row, rotation=this.rotation) {
|
isClear(col, row, rotation=this.rotation) {
|
||||||
for(var loccell of this.cells) {
|
for(var loccell of this.cells) {
|
||||||
var cell = this.getRealCell(loccell, col, row, rotation);
|
var cell = this.getRealCell(loccell, col, row, rotation);
|
||||||
if(cell == null || cell.type != CellTypes.empty && cell.owner != this) {
|
if(cell==null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (cell.owner==this || cell.type==CellTypes.empty || (!Hyperparams.foodBlocksReproduction && cell.type==CellTypes.food)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user