private void writeStuff(Bibit mother, NeuralNetwork myBrain) { StreamWriter writer = new StreamWriter("Assets/Resources/test.txt", true); String printString = ""; printString += myBrain.outputNeurons[0].connections[0].weight + ""; Debug.Log(printString); writer.WriteLine(printString); writer.Close(); }
public void pseudoConstructor2(Bibit mother) { transform.position = mother.transform.position; brain = mother.brain.cloneFullMesh(); energy = 150; displayName = mother.displayName; generation = mother.getGeneration() + 1; inBias = brain.getInputNeuronFromName(NAME_IN_BIAS); inEnergy = brain.getInputNeuronFromName(NAME_IN_ENERGY); inAge = brain.getInputNeuronFromName(NAME_IN_AGE); inMemory = brain.getInputNeuronFromName(NAME_IN_MEMORY); inDistToNearestPoison = brain.getInputNeuronFromName(NAME_IN_DISTTONEARESTPOISON); inAngleToNearestPoison = brain.getInputNeuronFromName(NAME_IN_ANGLETONEARESTPOISON); inFoodAmountAtCurrentBlock = brain.getInputNeuronFromName(NAME_IN_FOODAMOUNTATCURRENTBLOCK); inFoodAmountInSightRadius = brain.getInputNeuronFromName(NAME_IN_FOODAMOUNTINSIGHTRADIUS); inDistToMaxFoodBlockAround = brain.getInputNeuronFromName(NAME_IN_DISTTOMAXFOODBLOCKAROUND); inAngleToMaxFoodBlockAround = brain.getInputNeuronFromName(NAME_IN_ANGLETOMAXFOODBLOCKAROUND); inFoodAmountOfMaxFoodBlockAround = brain.getInputNeuronFromName(NAME_IN_FOODAMOUNTOFMAXFOODBLOCKAROUND); inNumberOfBibitsNear = brain.getInputNeuronFromName(NAME_IN_NUMBEROFBIBITSNEAR); inDistToNearestBibit = brain.getInputNeuronFromName(NAME_IN_DISTTONEARESTBIBIT); inAngleToNearestBibit = brain.getInputNeuronFromName(NAME_IN_ANGLETONEARESTBIBIT); inGeneticDifferenceToNearestBibit = brain.getInputNeuronFromName(NAME_IN_GENETICDIFFERENCETONEARESTBIBIT); inCenterPosition = brain.getInputNeuronFromName(NAME_IN_CENTERPOSITION); outBirth = brain.getOutputNeuronFromName(NAME_OUT_BIRTH); outRotate = brain.getOutputNeuronFromName(NAME_OUT_ROTATE); outForward = brain.getOutputNeuronFromName(NAME_OUT_FORWARD); outEat = brain.getOutputNeuronFromName(NAME_OUT_EAT); outMemory = brain.getOutputNeuronFromName(NAME_OUT_MEMORY); outAttack = brain.getOutputNeuronFromName(NAME_OUT_ATTACK); BibitProducer.updateGeneration(generation); // CalculateFeelerPos(); for (int i = 0; i < 10; i++) { brain.RandomMutation(0.2f); } float r = mother.color.r; float g = mother.color.g; float b = mother.color.b; r += Random.value * 0.1f - 0.05f; g += Random.value * 0.1f - 0.05f; b += Random.value * 0.1f - 0.05f; r = math.clamp(r, 0, 1); g = math.clamp(g, 0, 1); b = math.clamp(b, 0, 1); color = new Color(r, g, b); // writeStuff(mother, brain); }
public static void updateMaxGeneration(int generation, Bibit bibit) { if (generation > 0) { if (generation >= maxCurrentGeneration) { maxCurrentGeneration = generation; bibit.transform.localScale = bigBibit; maxGenBibitName = bibit.name; maxGenBibitName = maxGenBibitName.Substring(0, maxGenBibitName.IndexOf(",")); } else { bibit.transform.localScale = smallBibit; } } }