Randomized Creature Generation
Adds a random organism generator that is accessible through the editor control panel. This generator gives the user to generate an entire world of random organisms for selection to act upon.
This commit is contained in:
@@ -5,6 +5,7 @@ const Renderer = require('../Rendering/Renderer');
|
||||
const CellStates = require('../Organism/Cell/CellStates');
|
||||
const EditorController = require("../Controllers/EditorController");
|
||||
const Species = require('../Stats/Species');
|
||||
const RandomOrganismGenerator = require('../Organism/RandomOrganismGenerator')
|
||||
|
||||
class OrganismEditor extends Environment{
|
||||
constructor() {
|
||||
@@ -87,6 +88,38 @@ class OrganismEditor extends Environment{
|
||||
this.organism.updateGrid();
|
||||
this.organism.species = new Species(this.organism.anatomy, null, 0);
|
||||
}
|
||||
|
||||
createRandom() {
|
||||
|
||||
this.grid_map.fillGrid(CellStates.empty);
|
||||
|
||||
this.organism = RandomOrganismGenerator.generate(this);
|
||||
this.organism.updateGrid();
|
||||
this.organism.species = new Species(this.organism.anatomy, null, 0);
|
||||
}
|
||||
|
||||
createRandomWorld(worldEnvironment) {
|
||||
|
||||
worldEnvironment.clear();
|
||||
|
||||
var numOrganismCols = Math.floor(worldEnvironment.grid_map.cols / this.grid_map.cols);
|
||||
var numOrganismRows = Math.floor(worldEnvironment.grid_map.rows / this.grid_map.rows);
|
||||
var center = this.grid_map.getCenter();
|
||||
|
||||
for (var x = 0; x < numOrganismCols; x++) {
|
||||
for (var y = 0; y < numOrganismRows; y++) {
|
||||
|
||||
var newOrganism = RandomOrganismGenerator.generate(this);
|
||||
//newOrganism.updateGrid();
|
||||
newOrganism.species = new Species(newOrganism.anatomy, null, 0);
|
||||
|
||||
var col = x * this.grid_map.cols + center[0];
|
||||
var row = y * this.grid_map.rows + center[1];
|
||||
worldEnvironment.controller.add_new_species = true;
|
||||
worldEnvironment.controller.dropOrganism(newOrganism, col, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OrganismEditor;
|
||||
@@ -131,13 +131,17 @@ class WorldEnvironment extends Environment{
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.clear();
|
||||
this.OriginOfLife();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.organisms = [];
|
||||
this.grid_map.fillGrid(CellStates.empty);
|
||||
this.renderer.renderFullGrid(this.grid_map.grid);
|
||||
this.total_mutability = 0;
|
||||
this.total_ticks = 0;
|
||||
FossilRecord.clear_record();
|
||||
this.OriginOfLife();
|
||||
}
|
||||
|
||||
resizeGridColRow(cell_size, cols, rows) {
|
||||
|
||||
Reference in New Issue
Block a user