From 24aa954c32163ddddc573b7703a18abe79ea9aa6 Mon Sep 17 00:00:00 2001 From: Untrustedlife Date: Sat, 11 May 2019 12:32:25 -0500 Subject: [PATCH] added a bunch of const and const & in in various places especially in getStringCodePosition and isValidPlacement Added another const, got rid of a log --- scripts/microbe_stage/procedural_microbes.as | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/microbe_stage/procedural_microbes.as b/scripts/microbe_stage/procedural_microbes.as index 7a5e26bf76e..2f90cccfe29 100644 --- a/scripts/microbe_stage/procedural_microbes.as +++ b/scripts/microbe_stage/procedural_microbes.as @@ -78,11 +78,11 @@ string getRandomLetter(bool isBacteria){ // Checks whether an organelle in a certain position would fit within a list of other organelles. bool isValidPlacement(const string &in organelleName, int q, int r, int rotation, - array@ organelleList + const array@ &in organelleList ) { // this is now slightly less hacky but it could be btter - auto organelleHexes = getOrganelleDefinition(organelleName).getRotatedHexes(rotation); + const auto organelleHexes = getOrganelleDefinition(organelleName).getRotatedHexes(rotation); for(uint i = 0; i < organelleList.length(); ++i){ @@ -119,7 +119,7 @@ OrganelleTemplatePlaced@ getRealisticPosition(const string &in organelleName, int q = 0; int r = 0; - auto organelleShuffledArray = organelleList; + array@ organelleShuffledArray = organelleList; // Shuffle the Array to make sure its not always placing at the same part of the cell organelleShuffledArray.sort( function(a,b) { @@ -173,7 +173,7 @@ OrganelleTemplatePlaced@ getRealisticPosition(const string &in organelleName, // This function takes in a positioning block from the string code and a name // and returns an organelle with the correct position info -OrganelleTemplatePlaced@ getStringCodePosition(const string &in organelleName, string code){ +OrganelleTemplatePlaced@ getStringCodePosition(const string &in organelleName, const string &in code){ //LOG_INFO(code); array@ chromArray = code.split(","); @@ -202,7 +202,7 @@ array@ positionOrganelles(const string &in stringCode){ //LOG_INFO("DEBUG: positionOrganelles stringCode: " + stringCode); array@ result = array(); - array@ chromArray = stringCode.split("|"); + const array@ chromArray = stringCode.split("|"); for(uint i = 0; i < chromArray.length(); ++i){ OrganelleTemplatePlaced@ pos; string geneCode = chromArray[i]; @@ -244,8 +244,8 @@ string translateOrganelleToGene(OrganelleTemplatePlaced@ ourOrganelle){ string mutateMicrobe(const string &in stringCode, bool isBacteria) { array@ chromArray = stringCode.split("|"); - array@ modifiedArray = chromArray; - LOG_INFO(chromArray[0]); + auto modifiedArray = chromArray; + //LOG_INFO(chromArray[0]); string completeString = ""; // Delete or replace an organelle randomly @@ -284,10 +284,10 @@ string mutateMicrobe(const string &in stringCode, bool isBacteria) // 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); + const auto organelleList = positionOrganelles(completeString); const auto letter = getRandomLetter(isBacteria); string name = string(organelleLetters[letter]); - string returnedGenome = translateOrganelleToGene(getRealisticPosition(name,organelleList)); + const string returnedGenome = translateOrganelleToGene(getRealisticPosition(name,organelleList)); //LOG_INFO("Adding"); //LOG_INFO("chromosomes:"+returnedGenome); completeString+="|"+returnedGenome; @@ -302,10 +302,10 @@ string mutateMicrobe(const string &in stringCode, bool isBacteria) 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 organelleList = positionOrganelles(completeString); const auto letter = getRandomLetter(isBacteria); string name = string(organelleLetters[letter]); - string returnedGenome = translateOrganelleToGene(getRealisticPosition(name,organelleList)); + const string returnedGenome = translateOrganelleToGene(getRealisticPosition(name,organelleList)); //LOG_INFO("Adding"); //LOG_INFO("chromosomes:"+returnedGenome); completeString+="|"+returnedGenome;