fixed walls, species names, added max org
This commit is contained in:
4
dist/assets/worlds/_list.json
vendored
4
dist/assets/worlds/_list.json
vendored
@@ -1,4 +1,8 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"name": "⚔️Battle Royale (upcoming competition!)",
|
||||||
|
"value": "battle_royale"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Colony",
|
"name": "Colony",
|
||||||
"value": "colony"
|
"value": "colony"
|
||||||
|
|||||||
1
dist/assets/worlds/battle_royale.json
vendored
Normal file
1
dist/assets/worlds/battle_royale.json
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/css/style.css
vendored
2
dist/css/style.css
vendored
@@ -193,7 +193,7 @@ input:hover,input:active {
|
|||||||
grid-column: 2;
|
grid-column: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.global-mutation-in {
|
.global-mutation-container {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
dist/index.html
vendored
10
dist/index.html
vendored
@@ -110,6 +110,7 @@
|
|||||||
<div class='right-half'>
|
<div class='right-half'>
|
||||||
<div id='organism-details' style="display:none;">
|
<div id='organism-details' style="display:none;">
|
||||||
<h3>Organism Details</h3>
|
<h3>Organism Details</h3>
|
||||||
|
<p class='species-name'>Species Name: </p>
|
||||||
<p class='cell-count'>Cell count: </p>
|
<p class='cell-count'>Cell count: </p>
|
||||||
<p id='move-range'>Move Range: </p>
|
<p id='move-range'>Move Range: </p>
|
||||||
<p id='mutation-rate'>Mutation Rate: </p>
|
<p id='mutation-rate'>Mutation Rate: </p>
|
||||||
@@ -234,12 +235,15 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class='right-half'>
|
<div class='right-half'>
|
||||||
<button id='reset-rules'>Reset all controls</button>
|
<button id='reset-rules'>Reset all controls</button><br>
|
||||||
<h4>Mutation Rate</h4>
|
<label for="org-limit" title='Maximum number of organisms (-1 is unlimited)'>Maximum Organisms:</label>
|
||||||
|
<input type="number" id="org-limit" min="-1" value=-1 step="1"><br>
|
||||||
<label for="evolved-mutation" title='When on, each organism has its own mutation rate that can increase or decrease. When off, all organisms have the same mutation rate.'>Use evolved mutation rate</label>
|
<label for="evolved-mutation" title='When on, each organism has its own mutation rate that can increase or decrease. When off, all organisms have the same mutation rate.'>Use evolved mutation rate</label>
|
||||||
<input type="checkbox" id="evolved-mutation" checked> </br>
|
<input type="checkbox" id="evolved-mutation" checked>
|
||||||
|
<div class="global-mutation-container">
|
||||||
<label class="global-mutation-in" for="global-mutation">Global mutation rate: </label>
|
<label class="global-mutation-in" for="global-mutation">Global mutation rate: </label>
|
||||||
<input class="global-mutation-in" type="number" id="global-mutation" min="0" max="100" value=5 step="1">
|
<input class="global-mutation-in" type="number" id="global-mutation" min="0" max="100" value=5 step="1">
|
||||||
|
</div>
|
||||||
<h4 title='When an organism mutates, it can choose from one of the following mutation types.'>Mutation Type Probabilities</h4>
|
<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>
|
<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>
|
<input class="mut-prob" type="number" id="add-prob" min="0" max="100" value=33>
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class ControlPanel {
|
|||||||
this.slider = document.getElementById("slider");
|
this.slider = document.getElementById("slider");
|
||||||
this.slider.oninput = function() {
|
this.slider.oninput = function() {
|
||||||
const max_fps = 300;
|
const max_fps = 300;
|
||||||
this.fps = this.slider.value;
|
this.fps = parseInt(this.slider.value);
|
||||||
if (this.fps>=max_fps) this.fps = 1000;
|
if (this.fps>=max_fps) this.fps = 1000;
|
||||||
if (this.engine.running) {
|
if (this.engine.running) {
|
||||||
this.changeEngineSpeed(this.fps);
|
this.changeEngineSpeed(this.fps);
|
||||||
@@ -180,6 +180,8 @@ class ControlPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#resize').click(function() {
|
$('#resize').click(function() {
|
||||||
|
if (!confirm('The current environment will be lost. Proceed?'))
|
||||||
|
return;
|
||||||
var cell_size = $('#cell-size').val();
|
var cell_size = $('#cell-size').val();
|
||||||
var fill_window = $('#fill-window').is(":checked");
|
var fill_window = $('#fill-window').is(":checked");
|
||||||
if (fill_window) {
|
if (fill_window) {
|
||||||
@@ -190,7 +192,7 @@ class ControlPanel {
|
|||||||
var rows = $('#row-input').val();
|
var rows = $('#row-input').val();
|
||||||
this.engine.env.resizeGridColRow(cell_size, cols, rows);
|
this.engine.env.resizeGridColRow(cell_size, cols, rows);
|
||||||
}
|
}
|
||||||
this.engine.env.reset();
|
this.engine.env.reset(false);
|
||||||
this.stats_panel.reset();
|
this.stats_panel.reset();
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@@ -286,14 +288,17 @@ class ControlPanel {
|
|||||||
$('#extra-mover-cost').change(function() {
|
$('#extra-mover-cost').change(function() {
|
||||||
Hyperparams.extraMoverFoodCost = parseInt($('#extra-mover-cost').val());
|
Hyperparams.extraMoverFoodCost = parseInt($('#extra-mover-cost').val());
|
||||||
});
|
});
|
||||||
|
$('#org-limit').change(function() {
|
||||||
|
Hyperparams.maxOrganisms = parseInt($('#org-limit').val());
|
||||||
|
});
|
||||||
|
|
||||||
$('#evolved-mutation').change( function() {
|
$('#evolved-mutation').change( function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
$('.global-mutation-in').css('display', 'none');
|
$('.global-mutation-container').css('display', 'none');
|
||||||
$('#avg-mut').css('display', 'block');
|
$('#avg-mut').css('display', 'block');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('.global-mutation-in').css('display', 'block');
|
$('.global-mutation-container').css('display', 'block');
|
||||||
$('#avg-mut').css('display', 'none');
|
$('#avg-mut').css('display', 'none');
|
||||||
}
|
}
|
||||||
Hyperparams.useGlobalMutability = !this.checked;
|
Hyperparams.useGlobalMutability = !this.checked;
|
||||||
@@ -369,16 +374,17 @@ class ControlPanel {
|
|||||||
$('#food-blocks').prop('checked', Hyperparams.foodBlocksReproduction);
|
$('#food-blocks').prop('checked', Hyperparams.foodBlocksReproduction);
|
||||||
$('#food-drop-rate').val(Hyperparams.foodDropProb);
|
$('#food-drop-rate').val(Hyperparams.foodDropProb);
|
||||||
$('#extra-mover-cost').val(Hyperparams.extraMoverFoodCost);
|
$('#extra-mover-cost').val(Hyperparams.extraMoverFoodCost);
|
||||||
|
$('#org-limit').val(Hyperparams.maxOrganisms);
|
||||||
$('#look-range').val(Hyperparams.lookRange);
|
$('#look-range').val(Hyperparams.lookRange);
|
||||||
$('#see-through-self').prop('checked', Hyperparams.seeThroughSelf);
|
$('#see-through-self').prop('checked', Hyperparams.seeThroughSelf);
|
||||||
$('#global-mutation').val(Hyperparams.globalMutability);
|
$('#global-mutation').val(Hyperparams.globalMutability);
|
||||||
|
|
||||||
if (!Hyperparams.useGlobalMutability) {
|
if (!Hyperparams.useGlobalMutability) {
|
||||||
$('.global-mutation-in').css('display', 'none');
|
$('.global-mutation-container').css('display', 'none');
|
||||||
$('#avg-mut').css('display', 'block');
|
$('#avg-mut').css('display', 'block');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('.global-mutation-in').css('display', 'block');
|
$('.global-mutation-container').css('display', 'block');
|
||||||
$('#avg-mut').css('display', 'none');
|
$('#avg-mut').css('display', 'none');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class EditorController extends CanvasController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateDetails() {
|
updateDetails() {
|
||||||
|
$('.species-name').text("Species name: "+this.env.organism.species.name);
|
||||||
$('.cell-count').text("Cell count: "+this.env.organism.anatomy.cells.length);
|
$('.cell-count').text("Cell count: "+this.env.organism.anatomy.cells.length);
|
||||||
if (this.env.organism.isNatural()){
|
if (this.env.organism.isNatural()){
|
||||||
$('#unnatural-org-warning').css('display', 'none');
|
$('#unnatural-org-warning').css('display', 'none');
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ class WorldEnvironment extends Environment{
|
|||||||
this.largest_cell_count = organism.anatomy.cells.length;
|
this.largest_cell_count = organism.anatomy.cells.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canAddOrganism() {
|
||||||
|
return this.organisms.length < Hyperparams.maxOrganisms || Hyperparams.maxOrganisms < 0;
|
||||||
|
}
|
||||||
|
|
||||||
averageMutability() {
|
averageMutability() {
|
||||||
if (this.organisms.length < 1)
|
if (this.organisms.length < 1)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -195,6 +199,9 @@ class WorldEnvironment extends Environment{
|
|||||||
FossilRecord.clear_record();
|
FossilRecord.clear_record();
|
||||||
this.resizeGridColRow(this.grid_map.cell_size, env.grid.cols, env.grid.rows)
|
this.resizeGridColRow(this.grid_map.cell_size, env.grid.cols, env.grid.rows)
|
||||||
this.grid_map.loadRaw(env.grid);
|
this.grid_map.loadRaw(env.grid);
|
||||||
|
for (let wall of env.grid.walls) {
|
||||||
|
this.walls.push(this.grid_map.cellAt(wall.c, wall.r));
|
||||||
|
}
|
||||||
|
|
||||||
// create species map
|
// create species map
|
||||||
let species = {};
|
let species = {};
|
||||||
@@ -218,6 +225,7 @@ class WorldEnvironment extends Environment{
|
|||||||
s.anatomy = org.anatomy;
|
s.anatomy = org.anatomy;
|
||||||
s.calcAnatomyDetails();
|
s.calcAnatomyDetails();
|
||||||
}
|
}
|
||||||
|
s.name = orgRaw.species_name;
|
||||||
org.species = s;
|
org.species = s;
|
||||||
}
|
}
|
||||||
for (let name in species)
|
for (let name in species)
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ const Hyperparams = {
|
|||||||
this.foodDropProb = 0;
|
this.foodDropProb = 0;
|
||||||
|
|
||||||
this.extraMoverFoodCost = 0;
|
this.extraMoverFoodCost = 0;
|
||||||
|
|
||||||
|
this.maxOrganisms = -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
loadJsonObj(obj) {
|
loadJsonObj(obj) {
|
||||||
|
|||||||
@@ -102,7 +102,10 @@ class Organism {
|
|||||||
var new_c = this.c + (direction_c*basemovement) + (direction_c*offset);
|
var new_c = this.c + (direction_c*basemovement) + (direction_c*offset);
|
||||||
var new_r = this.r + (direction_r*basemovement) + (direction_r*offset);
|
var new_r = this.r + (direction_r*basemovement) + (direction_r*offset);
|
||||||
|
|
||||||
if (org.isClear(new_c, new_r, org.rotation, true) && org.isStraightPath(new_c, new_r, this.c, this.r, this)){
|
if (org.isClear(new_c, new_r, org.rotation, true) &&
|
||||||
|
org.isStraightPath(new_c, new_r, this.c, this.r, this) &&
|
||||||
|
this.env.canAddOrganism())
|
||||||
|
{
|
||||||
org.c = new_c;
|
org.c = new_c;
|
||||||
org.r = new_r;
|
org.r = new_r;
|
||||||
this.env.addOrganism(org);
|
this.env.addOrganism(org);
|
||||||
|
|||||||
Reference in New Issue
Block a user