Skip to content

Commit

Permalink
Species can now add up to 6 new organelles when they evolve
Browse files Browse the repository at this point in the history
(Though usually they add from 0-2, i listed the probabilities)
increased chance of new organelles increased chance of organelles being replaced.
Changed max pop size so species split and go extinct more frequently
Cleaned up name gen code to make more sense and to creat emor epronouncable names
higher chance of new genus's emerging
Auto evo steps now happen outside of editor at double the frequncy so if the player is going slow they may in fact become prey. This encourage sthe player to actually compete.

In my test game almost every single species had its own genus so this creates proper geneological lines aswell.

changed name mutator to avoid ridiculousness even more (Changing Th to stuff like Tb(which is unprouncable)), changed new name chances, etc.

commented out logs

400 pop to win now

Got rid of species level processor component replaced with rebuildProcessList

fixed bug where cells could engulf each other from a mile away.
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed May 9, 2019
1 parent 66b5bf0 commit 47be487
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 182 deletions.
2 changes: 1 addition & 1 deletion scripts/gui/microbe_hud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function checkExtinction(population){
}

function checkGeneration (generation, population){
if(generation >= 20 && population >= 500 && wonOnce == false){
if(generation >= 20 && population >= 400 && wonOnce == false){
document.getElementById("winTitle").style.display = "inline-block";
document.getElementById("winBody").style.display = "inline-block";
document.getElementById("winContainer").style.display = "inline-block";
Expand Down
2 changes: 1 addition & 1 deletion scripts/gui/thrive_gui.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
<br><br>
For this Release if your population (top tab) drops to zero you go extinct.
<br>
But if you survive for twenty generations with 500 population, you are considered to have won, after winning you get a popup and can continue playing as you wish.
But if you survive for twenty generations with 400 population, you are considered to have won, after winning you get a popup and can continue playing as you wish.
<br><br>
Be wary because your competitors are evolving alongside you. Every time you enter the editor they evolve as well.
<br><br>
Expand Down
9 changes: 7 additions & 2 deletions scripts/microbe_stage/configs.as
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ const auto MAX_OPACITY_MUTATION = 0.01f;

// Mutation Variables
const auto MUTATION_BACTERIA_TO_EUKARYOTE = 1;
const auto MUTATION_CREATION_RATE = 0.1f;
const auto MUTATION_CREATION_RATE = 0.5f;
const auto MUTATION_EXTRA_CREATION_RATE = 0.1f;
const auto MUTATION_DELETION_RATE = 0.1f;
const auto MUTATION_REPLACEMENT_RATE = 0.1f;
const auto MUTATION_REPLACEMENT_RATE = 0.3f;

// Genus splitting and name mutation
const auto MUTATION_CHANGE_GENUS = 33;
const auto MUTATION_WORD_EDIT = 75;

//Removal cost
const auto ORGANELLE_REMOVE_COST = 10;
Expand Down
9 changes: 7 additions & 2 deletions scripts/microbe_stage/microbe.as
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,16 @@ class MicrobeSystem : ScriptSystem{
if (microbeComponent.hostileEngulfer != NULL_OBJECT){
auto predatorPosition = world.GetComponent_Position(microbeComponent.hostileEngulfer);
auto ourPosition = world.GetComponent_Position(microbeEntity);
auto predatorMembraneComponent = world.GetComponent_MembraneComponent(microbeComponent.hostileEngulfer);
auto circleRad = predatorMembraneComponent.calculateEncompassingCircleRadius();
MicrobeComponent@ hostileMicrobeComponent = cast<MicrobeComponent>(
world.GetScriptComponentHolder("MicrobeComponent").Find(microbeComponent.hostileEngulfer));
if (hostileMicrobeComponent.isBacteria){
circleRad = circleRad/2;
}
if ((hostileMicrobeComponent is null) || (!hostileMicrobeComponent.engulfMode) ||
(hostileMicrobeComponent.dead) || (ourPosition._Position - predatorPosition._Position).LengthSquared() >=
((hostileMicrobeComponent.totalHexCountCache+3)*HEX_SIZE)+50){
circleRad){
microbeComponent.hostileEngulfer = NULL_OBJECT;
microbeComponent.isBeingEngulfed = false;
}
Expand Down Expand Up @@ -802,7 +807,7 @@ class MicrobeSystem : ScriptSystem{
if(organellesToAdd.length() > 0){
// Redo the cell membrane.
membraneComponent.clear();
MicrobeOperations::rebuildProcessList(world, microbeEntity);
MicrobeOperations::rebuildProcessList(world, microbeEntity);
}

if(reproductionStageComplete && microbeComponent.reproductionStage < 2){
Expand Down
31 changes: 2 additions & 29 deletions scripts/microbe_stage/microbe_operations.as
Original file line number Diff line number Diff line change
Expand Up @@ -906,14 +906,6 @@ ObjectID spawnMicrobe(CellStageWorld@ world, Float3 pos, const string &in specie
if(pos.Y != 0)
LOG_WARNING("spawnMicrobe: spawning at y-coordinate: " + pos.Y);

auto processor = getProcessorComponent(world, speciesName);

if(processor is null){
LOG_ERROR("Skipping microbe spawn because species '" + speciesName +
"' doesn't have a processor component");

return NULL_OBJECT;
}

// Create microbeEntity with correct template, physics and species name
auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName,
Expand Down Expand Up @@ -958,16 +950,6 @@ ObjectID spawnBacteria(CellStageWorld@ world, Float3 pos, const string &in speci
if(pos.Y != 0)
LOG_WARNING("spawnBacteria: spawning at y-coordinate: " + pos.Y);

auto processor = getProcessorComponent(world, speciesName);

if(processor is null){

LOG_ERROR("Skipping microbe spawn because species '" + speciesName +
"' doesn't have a processor component");

return NULL_OBJECT;
}

// Create microbeEntity with correct template, physics and species name
auto microbeEntity = _createMicrobeEntity(world, aiControlled, speciesName,
// in_editor
Expand Down Expand Up @@ -1087,17 +1069,6 @@ ObjectID _createMicrobeEntity(CellStageWorld@ world, bool aiControlled,
return entity;
}

auto processor = world.GetComponent_ProcessorComponent(speciesEntity);

if(processor is null){
LOG_ERROR("Microbe species '" + microbeComponent.speciesName +
"' doesn't have a processor component");
} else {
// Each microbe now has their own processor component to allow
// the process system to run safely while species are deleted
Species::copyProcessesFromSpecies(world, species, entity);
}

if(microbeComponent.organelles.length() > 0)
assert(false, "Freshly created microbe has organelles in it");

Expand All @@ -1108,13 +1079,15 @@ ObjectID _createMicrobeEntity(CellStageWorld@ world, bool aiControlled,
// up to date with the species so either this should apply the species processes OR
// there should be a ProcessConfiguration object that would be shared between the
// ProcessorComponent both in the species and individual cells
// this also sets up the processor component
Species::applyTemplate(world, entity, species, shape);

// ------------------------------------ //
// Initialization logic taken from MicrobeSystem and put here now
assert(microbeComponent.organelles.length() > 0, "Microbe has no "
"organelles in initializeMicrobe");


auto rigidBody = world.Create_Physics(entity, position);

_applyMicrobeCollisionShape(world, rigidBody, microbeComponent, shape);
Expand Down
20 changes: 20 additions & 0 deletions scripts/microbe_stage/procedural_microbes.as
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ string mutateMicrobe(const string &in stringCode, bool isBacteria)

completeString = join(modifiedArray,"|");

// Can add up to 6 new organelles (Which should allow AI to catch up to player more
// We can insert new organelles at the end of the list
if(GetEngine().GetRandom().GetNumber(0.f, 1.f) < MUTATION_CREATION_RATE){
auto organelleList = positionOrganelles(completeString);
Expand All @@ -292,6 +293,25 @@ string mutateMicrobe(const string &in stringCode, bool isBacteria)
completeString+="|"+returnedGenome;
}

/*
Probability of mutation occuring 5 time(s) = 0.15 = 1.0E-5
Probability of mutation NOT occuring = (1 - 0.1)5 = 0.59049
Probability of mutation occuring = 1 - (1 - 0.1)5 = 0.40951
*/
// We can insert new organelles at the end of the list
for(int n = 0; n < 5; n++ ){
// We can insert new organelles at the end of the list
if(GetEngine().GetRandom().GetNumber(0.f, 1.f) < MUTATION_EXTRA_CREATION_RATE){
auto organelleList = positionOrganelles(completeString);
const auto letter = getRandomLetter(isBacteria);
string name = string(organelleLetters[letter]);
string returnedGenome = translateOrganelleToGene(getRealisticPosition(name,organelleList));
//LOG_INFO("Adding");
//LOG_INFO("chromosomes:"+returnedGenome);
completeString+="|"+returnedGenome;
}
}

LOG_INFO("Mutated: "+completeString);
return completeString;
}
5 changes: 1 addition & 4 deletions scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,7 @@ void onReturnFromEditor(CellStageWorld@ world)
SpeciesComponent@ ourActualSpecies = MicrobeOperations::getSpeciesComponent(world, player);
auto membraneComponent = world.GetComponent_MembraneComponent(player);

// Call this before creating the clone.
Species::initProcessorComponent(world, player, ourActualSpecies);
// Can probabbly wrap this into the usual init to keep things clean
// This makes sure that the player's processer are up to date with their species
Species::copyProcessesFromSpecies(world, ourActualSpecies, player);

PlayerSpeciesSpawner factory("Default");

Expand All @@ -256,6 +252,7 @@ void onReturnFromEditor(CellStageWorld@ world)
world.GetScriptComponentHolder("MicrobeComponent").Find(player));

// Reset the player cell to be the same as the species template
// This also sets the processor component
Species::restoreOrganelleLayout(world, player, microbeComponent, playerSpecies);

// Reset Players reproduction
Expand Down
Loading

0 comments on commit 47be487

Please sign in to comment.