consolidated rotation control

This commit is contained in:
MaxRobinsonTheGreat
2021-12-18 13:37:15 -06:00
parent f6db669adb
commit 653a6c3f31
4 changed files with 9 additions and 17 deletions

9
dist/index.html vendored
View File

@@ -43,7 +43,7 @@
<p class='tabnav-item' id='editor'>Editor</p>
<p class='tabnav-item' id='world-controls'>World Controls</p>
<p class='tabnav-item' id='hyperparameters'>Simulation Controls</p>
<p class='tabnav-item' id='stats'>Stats</p>
<p class='tabnav-item' id='stats'>Statistics</p>
<!-- <p class='tabnav-item' id='challenges'>Challenges</p> -->
<button id="minimize" title="Minimze Control Panel."><i class="fa fa-minus-square"></i></button>
</div>
@@ -199,11 +199,8 @@
<label for="lifespan-multiplier" title='An organism lives for this many ticks per cell in its body.'>Lifespan multiplier:</label>
<input type="number" id="lifespan-multiplier" min="1" max="10000" value=100 step="1">
<br>
<label for="mover-rot" title='Movers rotate randomly when they change directions.'>Movers can rotate</label>
<input type="checkbox" id="mover-rot" checked>
<br>
<label for="offspring-rot" title='Offspring will randomly rotate'>Offspring rotate</label>
<input type="checkbox" id="offspring-rot" checked>
<label for="rot-enabled" title='Organisms rotate when born and while moving.'>Rotation Enabled</label>
<input type="checkbox" id="rot-enabled" checked>
<br>
<label for="insta-kill" title='When on, killer cells immediatly kill organisms they touch. When off, organisms have as much health as they have cells and only take 1 damage from killer cells.'>One touch kill</label>
<input type="checkbox" id="insta-kill">

View File

@@ -217,11 +217,8 @@ class ControlPanel {
Hyperparams.lifespanMultiplier = $('#lifespan-multiplier').val();
}.bind(this));
$('#mover-rot').change(function() {
Hyperparams.moversCanRotate = this.checked;
});
$('#offspring-rot').change(function() {
Hyperparams.offspringRotate = this.checked;
$('#rot-enabled').change(function() {
Hyperparams.rotationEnabled = this.checked;
});
$('#insta-kill').change(function() {
Hyperparams.instaKill = this.checked;
@@ -278,8 +275,7 @@ class ControlPanel {
Hyperparams.setDefaults();
$('#food-prod-prob').val(Hyperparams.foodProdProb);
$('#lifespan-multiplier').val(Hyperparams.lifespanMultiplier);
$('#mover-rot').prop('checked', Hyperparams.moversCanRotate);
$('#offspring-rot').prop('checked', Hyperparams.offspringRotate);
$('#rot-enabled').prop('checked', Hyperparams.rotationEnabled);
$('#insta-kill').prop('checked', Hyperparams.instaKill);
$('#evolved-mutation').prop('checked', !Hyperparams.useGlobalMutability);
$('#add-prob').val(Hyperparams.addProb);

View File

@@ -16,8 +16,7 @@ const Hyperparams = {
this.changeProb = 33;
this.removeProb = 33;
this.moversCanRotate = true;
this.offspringRotate = true;
this.rotationEnabled = true;
this.foodBlocksReproduction = true;
this.moversCanProduce = false;

View File

@@ -17,7 +17,7 @@ class Organism {
this.anatomy = new Anatomy(this)
this.direction = Directions.down; // direction of movement
this.rotation = Directions.up; // direction of rotation
this.can_rotate = Hyperparams.moversCanRotate;
this.can_rotate = Hyperparams.rotationEnabled;
this.move_count = 0;
this.move_range = 4;
this.ignore_brain_for = 0;
@@ -63,7 +63,7 @@ class Organism {
//produce mutated child
//check nearby locations (is there room and a direct path)
var org = new Organism(0, 0, this.env, this);
if(Hyperparams.offspringRotate){
if(Hyperparams.rotationEnabled){
org.rotation = Directions.getRandomDirection();
}
var prob = this.mutability;