Merge pull request #84 from MaxRobinsonTheGreat/mover-cost
added extra mover food cost
This commit is contained in:
3
dist/index.html
vendored
3
dist/index.html
vendored
@@ -210,6 +210,9 @@
|
|||||||
<br>
|
<br>
|
||||||
<label for="food-drop-rate" title='Rate at which food is automatically generated and dropped in the world'>Auto food drop rate:</label>
|
<label for="food-drop-rate" title='Rate at which food is automatically generated and dropped in the world'>Auto food drop rate:</label>
|
||||||
<input type="number" id="food-drop-rate" value=0 max="1000">
|
<input type="number" id="food-drop-rate" value=0 max="1000">
|
||||||
|
<br>
|
||||||
|
<label for="extra-mover-cost" title='Additional food cost for movers to reproduce'>Extra mover reproduction cost:</label>
|
||||||
|
<input type="number" id="extra-mover-cost" value=0 max="1000" step="1">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class='right-half'>
|
<div class='right-half'>
|
||||||
|
|||||||
@@ -229,6 +229,10 @@ class ControlPanel {
|
|||||||
$('#food-drop-rate').change(function() {
|
$('#food-drop-rate').change(function() {
|
||||||
Hyperparams.foodDropProb = $('#food-drop-rate').val();
|
Hyperparams.foodDropProb = $('#food-drop-rate').val();
|
||||||
});
|
});
|
||||||
|
$('#extra-mover-cost').change(function() {
|
||||||
|
console.log(parseInt($('#extra-mover-cost').val()))
|
||||||
|
Hyperparams.extraMoverFoodCost = parseInt($('#extra-mover-cost').val());
|
||||||
|
});
|
||||||
|
|
||||||
$('#evolved-mutation').change( function() {
|
$('#evolved-mutation').change( function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
@@ -311,6 +315,7 @@ class ControlPanel {
|
|||||||
$('#movers-produce').prop('checked', Hyperparams.moversCanProduce);
|
$('#movers-produce').prop('checked', Hyperparams.moversCanProduce);
|
||||||
$('#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);
|
||||||
$('#look-range').val(Hyperparams.lookRange);
|
$('#look-range').val(Hyperparams.lookRange);
|
||||||
|
|
||||||
if (!Hyperparams.useGlobalMutability) {
|
if (!Hyperparams.useGlobalMutability) {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ const Hyperparams = {
|
|||||||
this.lookRange = 20;
|
this.lookRange = 20;
|
||||||
|
|
||||||
this.foodDropProb = 0;
|
this.foodDropProb = 0;
|
||||||
|
|
||||||
|
this.extraMoverFoodCost = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
loadJsonObj(obj) {
|
loadJsonObj(obj) {
|
||||||
|
|||||||
@@ -47,11 +47,10 @@ class Organism {
|
|||||||
|
|
||||||
// amount of food required before it can reproduce
|
// amount of food required before it can reproduce
|
||||||
foodNeeded() {
|
foodNeeded() {
|
||||||
return this.anatomy.cells.length;
|
return this.anatomy.is_mover ? this.anatomy.cells.length + Hyperparams.extraMoverFoodCost : this.anatomy.cells.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
lifespan() {
|
lifespan() {
|
||||||
// console.log(Hyperparams.lifespanMultiplier)
|
|
||||||
return this.anatomy.cells.length * Hyperparams.lifespanMultiplier;
|
return this.anatomy.cells.length * Hyperparams.lifespanMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +117,7 @@ class Organism {
|
|||||||
org.species.addPop();
|
org.species.addPop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.food_collected -= this.foodNeeded();
|
Math.max(this.food_collected -= this.foodNeeded(), 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user