Esempio n. 1
0
    void Start()
    {
        startingAge     = Map.minutes;
        _tracker        = chromosome.MutationTracker;
        _viewChromosome = chromosome.ToString();
        cells           = new CellsStructure();

        bodyEnergy = OrganismSetter.BodyEnergy(chromosome);

        orderOfGrowth = CellsCreator.GetOrderOfGrowth(this);

        OrganismSetter.SetNeuralNetwork(this);
        OrganismSetter.SetDrag(this);
        OrganismSetter.SetName(this);

        OrganismCellsGrowth.GrowCell(this, false);

        if (fullyGrow)
        {
            OrganismCellsGrowth.FullyGrow(this);
        }

        InvokeRepeating("Routine", 2f, 5f);

        InvokeRepeating("Think", 2f, SimulationParameters.brainTick);

        InvokeRepeating("Physics", 2f, SimulationParameters.physics);
    }
    void Spawn()
    {
        GenesManager.mutationRate       = _mutationRate;
        GenesManager.neuralMutationRate = _neuralMutationRate;
        GameObject[] organisms = GameObject.FindGameObjectsWithTag("organism");

        _organismNumber = organisms.Length;
        OrganismSpawn.organismNumber = organisms.Length;
        if (organisms.Length < STOP_SPAWNING_AT)
        {
            float      x = (float)((r.NextDouble() * 0.8 + 0.1) * (Convert.ToDouble(Hyperparameters.MAP_SIZE)));
            float      y = (float)((r.NextDouble() * 0.8 + 0.1) * (Convert.ToDouble(Hyperparameters.MAP_SIZE))); //PROBLEMA DI SPAWN SUI BORDI??
            Chromosome chromosome;
            //    if (organisms.Length == 0)
            //     {
            chromosome = MakeChromosome();
            //       }
            //       else
            //       {

            //       chromosome = organisms[r.Next(organisms.Length)].GetComponent<Organism>().chromosome;

            //        }
            OrganismSpawn.SpawnOrganism(chromosome, new Vector3(x, y), OrganismSetter.BodyEnergy(chromosome) * 3 / 2);
        }
    }
Esempio n. 3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(2))
     {
         Chromosome chromosome = new Chromosome(MakeGenes(), MakeNeuralChromosome(), new ChromosomeParameters.ChromosomeParametersBuilder().SetAltruismEnergy(0.5).Build());
         OrganismSpawn.SpawnOrganism(chromosome, Camera.main.ScreenToWorldPoint(Input.mousePosition), OrganismSetter.BodyEnergy(chromosome) * 3 / 2);
     }
 }