basic start state and auto reset/pause
This commit is contained in:
10
dist/index.html
vendored
10
dist/index.html
vendored
@@ -33,7 +33,7 @@
|
||||
<p id='fps'>Target FPS: 60</p>
|
||||
<p id='fps-actual'></p>
|
||||
<button id='reset-env' title='Restarts simulation with default organism.'>Reset</button>
|
||||
<button id='clear-env' title="Removes all organisms. Will disable 'reset on extinction'"">Clear</button>
|
||||
<button id='clear-env' title="Removes all organisms.">Clear</button>
|
||||
</div>
|
||||
|
||||
<div id='tab-container' class='control-set'>
|
||||
@@ -169,16 +169,18 @@
|
||||
<br>
|
||||
<button id='resize'>Resize and Reset</button>
|
||||
<h3>Reset Options</h3>
|
||||
<label for="reset-options">Starting state:</label>
|
||||
<select name="reset-options" id="reset-options">
|
||||
<label for="start-state">Starting state:</label>
|
||||
<select name="start-state" id="start-state">
|
||||
<option value="simple-prod">Simple producer</option>
|
||||
<option value="rand-orgs">Random organisms</option>
|
||||
<option value="no-orgs">No organisms</option>
|
||||
</select> <br>
|
||||
<label for="auto-reset">Reset on total extinction</label>
|
||||
<input type="checkbox" id="auto-reset" checked>
|
||||
<br>
|
||||
<p id='reset-count'>Auto reset count: </p>
|
||||
<label for="auto-pause" title='Will override reset on extinction'>Pause on total extinction</label>
|
||||
<input type="checkbox" id="auto-pause">
|
||||
<br>
|
||||
</div>
|
||||
<div class='right-half'>
|
||||
<button id='random-walls' title="Generates random walls.">Generate random walls</button> <br>
|
||||
|
||||
@@ -195,12 +195,18 @@ class ControlPanel {
|
||||
}.bind(this));
|
||||
|
||||
$('#auto-reset').change(function() {
|
||||
env.auto_reset = this.checked;
|
||||
WorldConfig.auto_reset = this.checked;
|
||||
});
|
||||
$('#auto-pause').change(function() {
|
||||
WorldConfig.auto_pause = this.checked;
|
||||
});
|
||||
|
||||
$('#clear-walls-reset').change(function() {
|
||||
WorldConfig.clear_walls_on_reset = this.checked;
|
||||
})
|
||||
|
||||
$('#start-state').change ( function() {
|
||||
WorldConfig.start_state = $("#start-state").val();
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
defineHyperparameterControls() {
|
||||
@@ -338,8 +344,6 @@ class ControlPanel {
|
||||
$('#clear-env').click( () => {
|
||||
env.reset(true, false);
|
||||
this.stats_panel.reset();
|
||||
env.auto_reset = false;
|
||||
$('#auto-reset').prop('checked', false);;
|
||||
});
|
||||
$('#random-walls').click( function() {
|
||||
this.env_controller.randomizeWalls();
|
||||
|
||||
@@ -19,7 +19,6 @@ class WorldEnvironment extends Environment{
|
||||
this.organisms = [];
|
||||
this.walls = [];
|
||||
this.total_mutability = 0;
|
||||
this.auto_reset = true;
|
||||
this.largest_cell_count = 0;
|
||||
this.reset_count = 0;
|
||||
this.total_ticks = 0;
|
||||
@@ -59,24 +58,37 @@ class WorldEnvironment extends Environment{
|
||||
}
|
||||
|
||||
removeOrganisms(org_indeces) {
|
||||
let start_pop = this.organisms.length;
|
||||
for (var i of org_indeces.reverse()){
|
||||
this.total_mutability -= this.organisms[i].mutability;
|
||||
this.organisms.splice(i, 1);
|
||||
}
|
||||
if (this.organisms.length == 0 && this.auto_reset){
|
||||
if (this.organisms.length === 0 && start_pop > 0) {
|
||||
if (WorldConfig.auto_pause)
|
||||
$('.pause-button')[0].click();
|
||||
else if(WorldConfig.auto_reset) {
|
||||
this.reset_count++;
|
||||
this.reset(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OriginOfLife() {
|
||||
var center = this.grid_map.getCenter();
|
||||
switch (WorldConfig.start_state){
|
||||
case 'simple-prod':
|
||||
var org = new Organism(center[0], center[1], this);
|
||||
org.anatomy.addDefaultCell(CellStates.mouth, 0, 0);
|
||||
org.anatomy.addDefaultCell(CellStates.producer, 1, 1);
|
||||
org.anatomy.addDefaultCell(CellStates.producer, -1, -1);
|
||||
this.addOrganism(org);
|
||||
FossilRecord.addSpecies(org, null);
|
||||
break;
|
||||
case 'random-orgs':
|
||||
break;
|
||||
case 'no-orgs':
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addOrganism(organism) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const WorldConfig = {
|
||||
headless: false,
|
||||
clear_walls_on_reset: false,
|
||||
start_state: 'simple-prod',
|
||||
auto_reset: true,
|
||||
auto_pause: false,
|
||||
}
|
||||
|
||||
module.exports = WorldConfig;
|
||||
Reference in New Issue
Block a user