Added evolved birth distance
This commit is contained in:
6
dist/css/style.css
vendored
6
dist/css/style.css
vendored
@@ -163,9 +163,9 @@ button:hover{
|
||||
}
|
||||
#editor-env {
|
||||
image-rendering: -moz-crisp-edges;
|
||||
image-rendering: -webkit-crisp-edges;
|
||||
image-rendering: pixelated;
|
||||
image-rendering: crisp-edges;
|
||||
image-rendering: -webkit-crisp-edges;
|
||||
image-rendering: pixelated;
|
||||
image-rendering: crisp-edges;
|
||||
height: 195px;
|
||||
width: 195px;
|
||||
}
|
||||
|
||||
10
dist/index.html
vendored
10
dist/index.html
vendored
@@ -115,7 +115,15 @@
|
||||
<div class='cell-type' id='armor' title="Armor: Negates affects of killer cell."></div>
|
||||
<button id='clear-editor'>Clear</button>
|
||||
</div>
|
||||
<p id='editor-cell-count'>1 cell</p>
|
||||
<div id='editor-details'>
|
||||
<div id='organism-details'>
|
||||
<p id='editor-cell-count'>1 cell</p>
|
||||
</div>
|
||||
<div id='organism-options'>
|
||||
<label for="birth-distance" title='The number of cells away offspring will spawn.'>Reproduction Distance:</label>
|
||||
<input type="number" id="birth-distance" min="1" max="100" value=3 step="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id='hyperparameters' class='tab'>
|
||||
|
||||
300
dist/js/bundle.js
vendored
300
dist/js/bundle.js
vendored
File diff suppressed because one or more lines are too long
@@ -190,6 +190,7 @@ class ControlPanel {
|
||||
$('.edit-mode-btn').click( function() {
|
||||
var prev_mode = self.env_controller.mode;
|
||||
$('#cell-selections').css('display', 'none');
|
||||
$('#organism-options').css('display', 'none');
|
||||
switch(this.id){
|
||||
case "food-drop":
|
||||
self.setMode(Modes.FoodDrop);
|
||||
@@ -206,6 +207,7 @@ class ControlPanel {
|
||||
case "edit":
|
||||
self.setMode(Modes.Edit);
|
||||
$('#cell-selections').css('display', 'block');
|
||||
$('#organism-options').css('display', 'block');
|
||||
break;
|
||||
case "drop-org":
|
||||
self.setMode(Modes.Clone);
|
||||
|
||||
@@ -9,6 +9,7 @@ class EditorController extends CanvasController{
|
||||
this.edit_cell_type = null;
|
||||
this.highlight_org = false;
|
||||
this.defineCellTypeSelection();
|
||||
this.defineEditorOptions();
|
||||
}
|
||||
|
||||
mouseMove() {
|
||||
@@ -56,6 +57,13 @@ class EditorController extends CanvasController{
|
||||
$(selected).css("border-color", "yellow");
|
||||
});
|
||||
}
|
||||
|
||||
defineEditorOptions() {
|
||||
$('#birth-distance').change ( function() {
|
||||
this.env.organism.birth_distance = $('#birth-distance').val();
|
||||
}.bind(this));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = EditorController;
|
||||
|
||||
@@ -26,6 +26,7 @@ class Organism {
|
||||
this.move_range = 4;
|
||||
this.mutability = 5;
|
||||
this.damage = 0;
|
||||
this.birth_distance = 4;
|
||||
if (parent != null) {
|
||||
this.inherit(parent);
|
||||
}
|
||||
@@ -86,6 +87,7 @@ class Organism {
|
||||
inherit(parent) {
|
||||
this.move_range = parent.move_range;
|
||||
this.mutability = parent.mutability;
|
||||
this.birth_distance = parent.birth_distance;
|
||||
for (var c of parent.cells){
|
||||
//deep copy parent cells
|
||||
this.addCell(c.type, c.loc_col, c.loc_row);
|
||||
@@ -130,12 +132,13 @@ class Organism {
|
||||
if (Math.random() * 100 <= prob) {
|
||||
org.mutate();
|
||||
}
|
||||
|
||||
|
||||
var direction = Directions.getRandomScalar();
|
||||
var direction_c = direction[0];
|
||||
var direction_r = direction[1];
|
||||
var offset = (Math.floor(Math.random() * 3));
|
||||
var basemovement = Math.min(2+this.cells.length, 25);
|
||||
var basemovement = this.birth_distance;//Math.min(2+this.cells.length, 25);
|
||||
var new_c = this.c + (direction_c*basemovement) + (direction_c*offset);
|
||||
var new_r = this.r + (direction_r*basemovement) + (direction_r*offset);
|
||||
|
||||
@@ -161,6 +164,7 @@ class Organism {
|
||||
var c = branch.loc_col+growth_direction[0];
|
||||
var r = branch.loc_row+growth_direction[1];
|
||||
mutated = this.addCell(type, c, r);
|
||||
this.birth_distance++;
|
||||
}
|
||||
else if (choice <= Hyperparams.addProb + Hyperparams.changeProb){
|
||||
// change cell
|
||||
@@ -177,11 +181,14 @@ class Organism {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.is_mover) {
|
||||
if (this.is_mover && Math.random() * 100 <= 10) {
|
||||
this.move_range += Math.floor(Math.random() * 4) - 2;
|
||||
if (this.move_range <= 0){
|
||||
this.move_range = 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (Math.random() * 100 <= 10) {
|
||||
this.birth_distance += Math.floor(Math.random() * 4) - 2;
|
||||
}
|
||||
return mutated;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user