Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ac4d17a
Each cell cost can be adjusted individually!
theomgdev Jan 14, 2022
6c0d3a3
Encourage the user to use floating point numbers
theomgdev Jan 14, 2022
ca4a940
Revert useless changes
theomgdev Jan 14, 2022
5b0ba20
Bug Fix: Food(carrion) has food_value = cell cost
theomgdev Jan 14, 2022
bd8651c
Read comment of previous commit to see fixed bug
theomgdev Jan 14, 2022
0755792
typo fix
theomgdev Jan 14, 2022
07ca949
Don't create food for costless cells.
theomgdev Jan 14, 2022
7a88d6c
Ups, bug fix :) It should be empty
theomgdev Jan 14, 2022
cef45ef
Zero is not a good idea (one cell invading orgs)
theomgdev Jan 14, 2022
75760ee
CSS cursor: pointer, clickable
theomgdev Jan 14, 2022
aa1f19e
Don't make non-living(food,wall) clickable
theomgdev Jan 15, 2022
7525bc8
CSS small bug fix
theomgdev Jan 15, 2022
b430275
Important performance fix
theomgdev Jan 16, 2022
784efd7
Discord link added and fix to run links in new tab
theomgdev Jan 16, 2022
d20f4a1
One click discord emoji code copy to clipboard!
theomgdev Jan 16, 2022
2551229
Include organism data (brain, move range etc.)
theomgdev Jan 16, 2022
d4c3090
Hotkey to copy org discord code to clipboard
theomgdev Jan 17, 2022
39fbc56
Render full speed without performance issues!
theomgdev Jan 17, 2022
9a070f7
Better let the user set frames to skip
theomgdev Jan 17, 2022
4035d2f
small fix
theomgdev Jan 17, 2022
8fd1064
better skipped fps calculation
theomgdev Jan 17, 2022
5ab9e02
:__: fits better with discord instead :vd:
theomgdev Jan 18, 2022
fa104e3
I have changed my mind. :vd: emoji feels better
theomgdev Jan 18, 2022
2ba7ef4
Merge pull request #6 from M4YX0R/org-discord-code
theomgdev Jan 18, 2022
be47469
Merge pull request #5 from M4YX0R/skip-frames
theomgdev Jan 18, 2022
8466ff2
Mutability of mutation type probabilities and typo
theomgdev Jan 20, 2022
8f5698c
floats and better random mechanism
theomgdev Jan 20, 2022
87c15d8
better calculation
theomgdev Jan 20, 2022
8fa9d30
ups fix :)
theomgdev Jan 20, 2022
7f68eb1
I hate 99.99
theomgdev Jan 20, 2022
aa4f55a
fit to range
theomgdev Jan 20, 2022
6b551b4
error fix (last i hope :D )
theomgdev Jan 20, 2022
0fa323a
stats, edits, better formulas, tweaks and more
theomgdev Jan 20, 2022
23a6a3b
better 5 is good
theomgdev Jan 20, 2022
44f2293
safe ranges
theomgdev Jan 20, 2022
8ca2f6c
Merge branch 'experiments' into mutations-overhaul
theomgdev Jan 20, 2022
25f35d9
UPS!!! I forget to change branch name on vs code :D
theomgdev Jan 21, 2022
40561c0
fixed wrong merge. now only mutations-overhaul :)
theomgdev Jan 21, 2022
c84097a
Merge branch 'master' into mutations-overhaul
theomgdev Jan 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dist/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,7 @@ input:hover,input:active {
#reset-with-editor-org{
margin-top: 5px;
}

input[type=number]{
max-width: 47px;
}
25 changes: 13 additions & 12 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ <h3>Simulation Speed</h3>
</div>

<div id='tab-container' class='control-set'>

<div class="tabnav">
<p class='tabnav-item open-tab' id='about'>About</p>
<p class='tabnav-item' id='editor'>Editor</p>
Expand Down Expand Up @@ -105,8 +104,9 @@ <h3>The Life Engine</h3>
<h3>Organism Details</h3>
<p class='cell-count'>Cell count: </p>
<p id='move-range'>Move Range: </p>
<p id='mutation-rate'>Mutation Rate: </p>
<br>
<p>
<span id='mutation-rate'>Mutation Rate: </span><span id='mutation-probs'> (Add: 33, Change: 33, Remove: 33)</span>
</p>

<div class='brain-details'>
<h4>Brain</h4>
Expand All @@ -125,6 +125,15 @@ <h3>Edit Organism</h3>
<div id='mutation-rate-cont'>
<label for="mutation-rate-edit" title='Probability that offspring of this organism will mutate'>Mutation Rate:</label>
<input type="number" id="mutation-rate-edit" min="1" max="100" value=3 step="1">
<span> (</span>
<label for="mutation-add-edit" title='Probability that offspring of this organism will add a cell'>Add:</label>
<input type="number" id="mutation-add-edit" min="1" max="100" value=33 step="1">
<label for="mutation-change-edit" title='Probability that offspring of this organism will change a cell'>Change:</label>
<input type="number" id="mutation-change-edit" min="1" max="100" value=33 step="1">
<label for="mutation-remove-edit" title='Probability that offspring of this organism will remove a cell'>Remove:</label>
<input type="number" id="mutation-remove-edit" min="1" max="100" value=33 step="1">
<span> )</span>

</div>
<!-- <br> -->
<div class='brain-details'>
Expand Down Expand Up @@ -221,14 +230,6 @@ <h4>Mutation Rate</h4>
<input type="checkbox" id="evolved-mutation" checked> </br>
<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 title='When an organism mutates, it can choose from one of the following mutation types.'>Mutation Type Probabilities</h4>
<label for="add-prob" title='A new cell will stem from an existing one'>Add Cell:</label>
<input class="mut-prob" type="number" id="add-prob" min="0" max="100" value=33>
<label for="change-prob" title='A currently existing cell will change its color.'>Change Cell:</label>
<input class="mut-prob" type="number" id="change-prob" min="0" max="100" value=33>
<label for="remove-prob" title='An existing cell will be removed.'>Remove Cell:</label>
<input class="mut-prob" type="number" id="remove-prob" min="0" max="100" value=33>
<br/>
<label for="movers-produce" title='When on, movers can produce food from producer cells. When off, producer cells are disabled on mover organisms.'>Movers can produce food</label>
<input type="checkbox" id="movers-produce">
<br/>
Expand All @@ -252,7 +253,7 @@ <h2>Statistics</h2>
<select name="chart-option" id="chart-option">
<option value="population">Population</option>
<option value="species">Species</option>
<option value="mut-rate">Organism Structure</option>
<option value="org-structure">Organism Structure</option>
<option value="mut-rate">Mutation Rate</option>
</select>
<p id='chart-note'></p>
Expand Down
19 changes: 0 additions & 19 deletions src/Controllers/ControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,6 @@ class ControlPanel {
$('#global-mutation').change( function() {
Hyperparams.globalMutability = parseInt($('#global-mutation').val());
});
$('.mut-prob').change( function() {
switch(this.id){
case "add-prob":
Hyperparams.addProb = this.value;
break;
case "change-prob":
Hyperparams.changeProb = this.value;
break;
case "remove-prob":
Hyperparams.removeProb = this.value;
break;
}
$('#add-prob').val(Math.floor(Hyperparams.addProb));
$('#change-prob').val(Math.floor(Hyperparams.changeProb));
$('#remove-prob').val(Math.floor(Hyperparams.removeProb));
});
$('#movers-produce').change( function() {
Hyperparams.moversCanProduce = this.checked;
});
Expand Down Expand Up @@ -307,9 +291,6 @@ class ControlPanel {
$('#rot-enabled').prop('checked', Hyperparams.rotationEnabled);
$('#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);
$('#food-drop-rate').val(Hyperparams.foodDropProb);
Expand Down
20 changes: 19 additions & 1 deletion src/Controllers/EditorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ class EditorController extends CanvasController{
$('#mutation-rate-edit').change ( function() {
this.env.organism.mutability = parseInt($('#mutation-rate-edit').val());
}.bind(this));

$('#mutation-add-edit').change ( function() {
this.env.organism.addProb = parseFloat($('#mutation-add-edit').val());
}.bind(this));

$('#mutation-change-edit').change ( function() {
this.env.organism.changeProb = parseFloat($('#mutation-change-edit').val());
}.bind(this));

$('#mutation-remove-edit').change ( function() {
this.env.organism.removeProb = parseFloat($('#mutation-remove-edit').val());
}.bind(this));

$('#observation-type-edit').change ( function() {
this.setBrainEditorValues($('#observation-type-edit').val());
this.setBrainDetails();
Expand Down Expand Up @@ -129,12 +142,13 @@ class EditorController extends CanvasController{
$('.cell-count').text("Cell count: "+org.anatomy.cells.length);
$('#move-range').text("Move Range: "+org.move_range);
$('#mutation-rate').text("Mutation Rate: "+org.mutability);
$('#mutation-probs').text(" (Add: "+org.addProb.toFixed(2)+", Change: "+org.changeProb.toFixed(2)+", Remove: "+org.removeProb.toFixed(2)+")");

if (Hyperparams.useGlobalMutability) {
$('#mutation-rate').css('display', 'none');
}
else {
$('#mutation-rate').css('display', 'block');
$('#mutation-rate').css('display', 'inline');
}

this.setMoveRangeVisibility();
Expand All @@ -156,6 +170,10 @@ class EditorController extends CanvasController{
}

$('#mutation-rate-edit').val(org.mutability);
$('#mutation-add-edit').val(org.addProb);
$('#mutation-change-edit').val(org.changeProb);
$('#mutation-remove-edit').val(org.removeProb);

if (Hyperparams.useGlobalMutability) {
$('#mutation-rate-cont').css('display', 'none');
}
Expand Down
30 changes: 30 additions & 0 deletions src/Environments/WorldEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class WorldEnvironment extends Environment{
this.organisms = [];
this.walls = [];
this.total_mutability = 0;
this.total_add_mutability = 0;
this.total_change_mutability = 0;
this.total_remove_mutability = 0;
this.largest_cell_count = 0;
this.reset_count = 0;
this.total_ticks = 0;
Expand Down Expand Up @@ -61,6 +64,9 @@ class WorldEnvironment extends Environment{
let start_pop = this.organisms.length;
for (var i of org_indeces.reverse()){
this.total_mutability -= this.organisms[i].mutability;
this.total_add_mutability -= this.organisms[i].addProb;
this.total_change_mutability -= this.organisms[i].changeProb;
this.total_remove_mutability -= this.organisms[i].removeProb;
this.organisms.splice(i, 1);
}
if (this.organisms.length === 0 && start_pop > 0) {
Expand All @@ -86,6 +92,9 @@ class WorldEnvironment extends Environment{
addOrganism(organism) {
organism.updateGrid();
this.total_mutability += organism.mutability;
this.total_add_mutability += organism.addProb;
this.total_change_mutability += organism.changeProb;
this.total_remove_mutability += organism.removeProb;
this.organisms.push(organism);
if (organism.anatomy.cells.length > this.largest_cell_count)
this.largest_cell_count = organism.anatomy.cells.length;
Expand All @@ -100,6 +109,24 @@ class WorldEnvironment extends Environment{
return this.total_mutability / this.organisms.length;
}

avarageAddMutability() {
if (this.organisms.length < 1)
return 0;
return this.total_add_mutability / this.organisms.length;
}

avarageChangeMutability() {
if (this.organisms.length < 1)
return 0;
return this.total_change_mutability / this.organisms.length;
}

avarageRemoveMutability() {
if (this.organisms.length < 1)
return 0;
return this.total_remove_mutability / this.organisms.length;
}

changeCell(c, r, state, owner) {
super.changeCell(c, r, state, owner);
this.renderer.addToRender(this.grid_map.cellAt(c, r));
Expand Down Expand Up @@ -144,6 +171,9 @@ class WorldEnvironment extends Environment{
this.grid_map.fillGrid(CellStates.empty, !WorldConfig.clear_walls_on_reset);
this.renderer.renderFullGrid(this.grid_map.grid);
this.total_mutability = 0;
this.total_add_mutability = 0;
this.total_change_mutability = 0;
this.total_remove_mutability = 0;
this.total_ticks = 0;
FossilRecord.clear_record();
if (reset_life)
Expand Down
3 changes: 0 additions & 3 deletions src/Hyperparameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const Hyperparams = {

this.useGlobalMutability = false;
this.globalMutability = 5;
this.addProb = 33;
this.changeProb = 33;
this.removeProb = 33;

this.rotationEnabled = true;

Expand Down
41 changes: 38 additions & 3 deletions src/Organism/Organism.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Organism {
this.move_range = 4;
this.ignore_brain_for = 0;
this.mutability = 5;
this.addProb = 33;
this.changeProb = 33;
this.removeProb = 33;
this.damage = 0;
this.brain = new Brain(this);
if (parent != null) {
Expand All @@ -32,6 +35,9 @@ class Organism {
inherit(parent) {
this.move_range = parent.move_range;
this.mutability = parent.mutability;
this.addProb = parent.addProb;
this.changeProb = parent.changeProb;
this.removeProb = parent.removeProb;
this.species = parent.species;
// this.birth_distance = parent.birth_distance;
for (var c of parent.anatomy.cells){
Expand Down Expand Up @@ -78,6 +84,35 @@ class Organism {
if (org.mutability < 1)
org.mutability = 1;
}
var amount;
var mutation_type_mutability = 5;
//mutate the add probability
amount = Math.random()*mutation_type_mutability - mutation_type_mutability/2;
org.addProb += amount;
org.addProb = Math.min(Math.max(org.addProb, 0), 100);
org.changeProb -= amount/2;
org.removeProb -= amount/2;
//fix the probabilities (floating point errors)
org.changeProb = Math.min(Math.max(100 - org.addProb - org.removeProb, 0), 100);
org.removeProb = Math.min(Math.max(100 - org.addProb - org.changeProb, 0), 100);
//mutate the change probability
amount = Math.random()*mutation_type_mutability - mutation_type_mutability/2;
org.changeProb += amount;
org.changeProb = Math.min(Math.max(org.changeProb, 0), 100);
org.addProb -= amount/2;
org.removeProb -= amount/2;
//fix the probabilities (floating point errors)
org.addProb = Math.min(Math.max(100 - org.changeProb - org.removeProb, 0), 100);
org.removeProb = Math.min(Math.max(100 - org.changeProb - org.addProb, 0), 100);
//mutate the remove probability
amount = Math.random()*mutation_type_mutability - mutation_type_mutability/2;
org.removeProb += amount;
org.removeProb = Math.min(Math.max(org.removeProb, 0), 100);
org.addProb -= amount/2;
org.changeProb -= amount/2;
//fix the probabilities (floating point errors)
org.addProb = Math.min(Math.max(100 - org.removeProb - org.changeProb, 0), 100);
org.changeProb = Math.min(Math.max(100 - org.removeProb - org.addProb, 0), 100);
}
var mutated = false;
if (Math.random() * 100 <= prob) {
Expand Down Expand Up @@ -123,7 +158,7 @@ class Organism {

mutate() {
let mutated = false;
if (this.calcRandomChance(Hyperparams.addProb)) {
if (this.calcRandomChance(this.addProb)) {
let branch = this.anatomy.getRandomCell();
let state = CellStates.getRandomLivingType();//branch.state;
let growth_direction = Neighbors.all[Math.floor(Math.random() * Neighbors.all.length)]
Expand All @@ -134,13 +169,13 @@ class Organism {
this.anatomy.addRandomizedCell(state, c, r);
}
}
if (this.calcRandomChance(Hyperparams.changeProb)){
if (this.calcRandomChance(this.changeProb)){
let cell = this.anatomy.getRandomCell();
let state = CellStates.getRandomLivingType();
this.anatomy.replaceCell(state, cell.loc_col, cell.loc_row);
mutated = true;
}
if (this.calcRandomChance(Hyperparams.removeProb)){
if (this.calcRandomChance(this.removeProb)){
if(this.anatomy.cells.length > 1) {
let cell = this.anatomy.getRandomCell();
mutated = this.anatomy.removeCell(cell.loc_col, cell.loc_row);
Expand Down
8 changes: 7 additions & 1 deletion src/Stats/StatsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ class StatsPanel {
$('#org-count').text("Total Population: " + org_count);
$('#species-count').text("Number of Species: " + FossilRecord.extant_species.length);
$('#largest-org').text("Largest Organism Ever: " + this.env.largest_cell_count + " cells");
$('#avg-mut').text("Average Mutation Rate: " + Math.round(this.env.averageMutability() * 100) / 100);
var mutation_info = "Average Mutation Rate: " + this.env.averageMutability().toFixed(2);

mutation_info += " (Add: " + this.env.avarageAddMutability().toFixed(2) ;
mutation_info += ", Change: " + this.env.avarageChangeMutability().toFixed(2);
mutation_info += ", Remove: " + this.env.avarageRemoveMutability().toFixed(2) + ")";

$('#avg-mut').text(mutation_info);


}
Expand Down