public static SpeciesStability[] ComputeSpeciesStability(PopulationManager populationManager, LevelObjectiveData objective)
    {
        // Project the minimums of the species out several days
        SpeciesCount[] speciesCounts = ProjectNextSpeciesCount(populationManager);
        // Create the array to return
        SpeciesStability[] speciesStabilities = new SpeciesStability[speciesCounts.Length];

        // Compute the stability of each species based on the projected minimum
        for (int i = 0; i < speciesCounts.Length; i++)
        {
            SpeciesType species = speciesCounts[i].species;

            // Add up the target population for every data that has the same species
            int targetAmount = objective.survivalObjectiveDatas
                               .Where(data => data.targetSpecies.Species == species)
                               .Sum(data => data.targetPopulationSize);

            // Species is stable if the projected minimum
            // is bigger than or equal to the target amount
            speciesStabilities[i] = new SpeciesStability()
            {
                species  = species,
                isStable = speciesCounts[i].count >= targetAmount
            };
        }

        return(speciesStabilities);
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     resources  = GameObject.FindGameObjectWithTag("Game Control").GetComponent <PlayerResources>();
     eTime      = GameObject.FindGameObjectWithTag("Game Control").GetComponent <ElapsedTime>();
     PopManager = GameObject.FindGameObjectWithTag("Game Control").GetComponent <PopulationManager>();
     pause      = GameObject.FindGameObjectWithTag("Game Control").GetComponent <PauseGame>();
 }
    public static SpeciesCount[] ProjectNextSpeciesCount(PopulationManager populationManager)
    {
        // Use a dictionary to easily store and look up the counts
        Dictionary <SpeciesType, SpeciesCount> counts = new Dictionary <SpeciesType, SpeciesCount>();

        // Update the counts for each population in the population manager
        foreach (Population population in populationManager.Populations)
        {
            // Assign the species for convenience
            SpeciesType species = population.species.Species;

            // If the dictionary does not yet contain the key
            // then add the key to the dictionary
            if (!counts.ContainsKey(species))
            {
                counts.Add(species, new SpeciesCount()
                {
                    species = population.species.Species,
                    count   = 0
                });
            }

            // Calculate the population's next size
            GrowthCalculator calculator = population.GrowthCalculator;
            counts[species].count += calculator.CalculateNextPopulationSize();
        }

        return(counts.Values.ToArray());
    }
Beispiel #4
0
 // Use this for initialization
 void Start()
 {
     population   = FindObjectOfType <PopulationManager>().GetComponent <PopulationManager>();
     inventory    = GetComponent <PlayerInventory>();
     foods        = FindObjectOfType <FoodManager>().GetComponent <FoodManager>();
     audioManager = FindObjectOfType <AudioManager>().GetComponent <AudioManager>();
 }
Beispiel #5
0
 private void Awake()
 {
     collectdatarendertexture = FindObjectOfType <CollectDataRenderTexture>();
     scoreCalculator          = FindObjectOfType <ScoreCalculator>();
     populationmanager        = FindObjectOfType <PopulationManager>();
     gamePopulationController = FindObjectOfType <GamePopulationController>();
 }
        private void NextGen(PopulationManager populationManager, Func <List <Route>, Route> selectionMethode, double mutateFactor)
        {
            //Generate the next generation
            Population nextPopulation = populationManager.NextGen(population, selectionMethode, mutateFactor);

            //store it in the population variable
            population = nextPopulation;
        }
Beispiel #7
0
    public AgentObject InitNewAgent(PopulationManager populationManager, Genome genome)
    {
        GameObject obj = Instantiate(_playerPrefab, _spawnPosition.position, Quaternion.identity);

        obj.GetComponent <Player>()._customAgent = new Player.CustomAgent(genome, populationManager);

        return(obj.GetComponent <Player>()._customAgent);
    }
        private App(MySqlConnection dbConn, Dictionary <string, string> cities)
        {
            //1. init the populationManager with connection to the database
            populationManager = new PopulationManager(cities);

            //2. Generate the first population
            population = populationManager.GeneratePopulation();
        }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     added          = false;
     statisticAdded = false;
     popc           = FindObjectOfType <PopulationManager>();
     oog            = gameObject.GetComponent <ObjectOnGrid>();
     rm             = gameObject.GetComponent <ResourceManager>();
 }
Beispiel #10
0
 void Awake()
 {
     PhraseHelper.Init();
     ReproductionHelper.Init();
     MutationHelper.Init();
     UIManager.Init();
     PopulationManager.Init();
 }
Beispiel #11
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More than one PopulationManager in scene !"); return;
     }
     instance = this;
 }
Beispiel #12
0
 // Use this for initialization
 void Start()
 {
     rm           = FindObjectOfType <ResourceManager>();
     popm         = FindObjectOfType <PopulationManager>();
     ScoreCurrent = 0;
     TimeCurrent  = 0;
     //timemin = 0;
 }
Beispiel #13
0
        //public IEnumerable<IJobProvider> AllIJobProviders { get { return MapStructManager.AllMapStructs.Where(x => x is IJobProvider).Select(x => x as IJobProvider); } }
        //public IEnumerable<IJobWorker> AllIJobWorkers { get { return MapStructManager.AllMapStructs.Where(x => x is IJobWorker).Select(x => x as IJobWorker); } }

        public VillageManager()
        {
            this.Map          = new VillageMap(20, 20);
            PopulationManager = new PopulationManager();
            //MapStructManager = new MapStructManager(Map);
            JobManager = new JobManager <JobDef>();
            //this.ResourceManager = new ResourceMaster();
        }
Beispiel #14
0
    public static Worker Instantiate(Housing house, Vector3 position, Quaternion rotation)
    {
        var result = Instantiate(ResourceLoader.GetInstance().WorkerPrefab, position + Vector3.Scale(Random.insideUnitSphere, new Vector3(3f, 0, 3f)), rotation);

        result.House            = house;
        result.createdFromScene = false;
        PopulationManager.GetInstance().AddToWorkforce(result);
        return(result);
    }
Beispiel #15
0
 public void SpawnUnit(GameObject _Unit)
 {
     if (PopulationManager.IncPop())
     {
         Vector2    spawnPos = (Random.insideUnitCircle.normalized * transform.localScale.x);
         GameObject newUnit  = Instantiate(_Unit, new Vector3(spawnPos.x + transform.position.x, _Unit.transform.position.y, spawnPos.y + transform.position.z), _Unit.transform.rotation) as GameObject;
         newUnit.GetComponent <Unit>().Destination = SpawnLocation;
     }
 }
Beispiel #16
0
 public void Init(int dnaLength, PopulationManager manager)
 {
     populationManager = manager;
     dna       = new DNA(dnaLength, Enum.GetValues(typeof(Movement)).Length);
     character = GetComponent <ThirdPersonCharacter>();
     alive     = true;
     timeAlive = 0;
     startPos  = transform.position;
 }
Beispiel #17
0
 public void evaluateShip(PopulationManager populationManager)
 {
     if (lastShip != null)
     {
         ShipArchive shipArchive = new ShipArchive(lastShip.rootNode, lastShip.getFitness());
         populationManager.shipEvaluated(shipArchive);
         GameObject.Destroy(lastShip.gameObject);
     }
 }
Beispiel #18
0
 // Use this for initialization
 void Start()
 {
     c_Stats          = GetComponent <HumanCurrentStats>();
     agent            = GetComponent <NavMeshAgent>();
     shop             = FindObjectOfType <ShopManager>().GetComponent <ShopManager>();
     audioManager     = FindObjectOfType <AudioManager>().GetComponent <AudioManager>();
     population       = FindObjectOfType <PopulationManager>().GetComponent <PopulationManager>();
     r_SightDistance += shop.s_r_sightRangeIncrease;
 }
Beispiel #19
0
 public void SetUp(GameObject ground, ScenarioData scenario, IntPoint2D tileLoc)
 {
     scenarioInfo = scenario;
     centerTile   = tileLoc;
     popMgr       = ground.GetComponent("PopulationManager") as PopulationManager;
     numWorkers   = 0;
     amountStored = 0;
     StartCoroutine("GetWorkers");
 }
Beispiel #20
0
 // Use this for initialization
 void Start()
 {
     oog              = GetComponent <ObjectOnGrid>();
     rm               = FindObjectOfType <ResourceManager>();
     PopManager       = FindObjectOfType <PopulationManager>();
     HappinessManager = FindObjectOfType <HappinessManager>();
     spawnTime        = baseSpawnTime;
     message          = "Fortress Upgrade\n" + upcostwood + " Wood " + upcoststone + " Stone";
 }
 public void Initialize()
 {
     Manager = new PopulationManager(
         Mock.Of <IReadOnlyRepository <string> >(),
         Mock.Of <IMapper>(),
         Mock.Of <ILogger>(),
         Mock.Of <IAuthManager <V_MyView, string> >(),
         Mock.Of <IPopulationSpecificationProvider>()
         );
 }
Beispiel #22
0
 protected virtual void Start()
 {
     this.enabled     = false;
     regroupPositions = new Vector3[RegroupPoints.Length];
     for (int i = 0; i < RegroupPoints.Length; i++)
     {
         regroupPositions[i] = RegroupPoints[i].position;
     }
     populationManager = this.GetComponentInChildren <PopulationManager>();
 }
Beispiel #23
0
    public void SetUp(GameObject ground, ScenarioData scenInfo, IntPoint2D loc)
    {
//		scenario = ground.GetComponent("ScenarioMgr") as ScenarioMgr;
        walkerPool   = ground.GetComponent("WalkerPool") as WalkerPool;
        popMgr       = ground.GetComponent("PopulationManager") as PopulationManager;
        scenarioInfo = scenInfo;
        buildingTile = loc;
        numWorkers   = 0;
        StartCoroutine("GetWorkers");
        StartCoroutine("Distribute");
    }
Beispiel #24
0
    public void ResetAndLogCarTermination(bool usurped = false)
    {
        if (!isDemo)
        {
            GameObject        car    = this.gameObject;
            PopulationManager popMan = evolutionManager.GetComponent <PopulationManager>();
            car.GetComponent <NeuralNetwork>().Sleep();
            CalculateTheIndividualsFitness();
            popMan.PositionCarAtStartLine(car);
            lastPosition = transform.position;
            isDriving    = false;
            culled       = false;
        }
        else
        {
            GameObject        car    = this.gameObject;
            PopulationManager popMan = evolutionManager.GetComponent <PopulationManager>();
            // Stop

            // Meant to be a check to penalize the known best if it crashes - but not working right
            if (!culled && NumberCarsFinished > 15 && !usurped)
            {
                float distCovered = Vector3.Distance(StartPos, this.gameObject.transform.position);
                if (distanceTravelled != 0)
                {
                    tempStoreOfDistTravelled = distanceTravelled;
                }
                float latestFitness = CalculateTheIndividualsFitness();
                if (latestFitness < 0.9f * popMan.GlobalBestNN_Fitness && tempStoreOfDistTravelled > 100 && isDriving)
                {
                    this.gameObject.transform.position = StartPos;
                    // need to get the corresponding Personal-Best and adjust by same amount
                    for (int x = 0; x < popMan.PersonalBestNN_Fitness.Count; x++)
                    {
                        if (popMan.PersonalBestNN_Fitness[x] == popMan.GlobalBestNN_Fitness)
                        {
                            popMan.PersonalBestNN_Fitness[x] = latestFitness;
                            popMan.GlobalBestNN_Fitness      = latestFitness;
                        }
                    }
                }
            }

            popMan.PositionCarAtStartLine(car);
            lastPosition      = transform.position;
            distanceTravelled = 0;
            finishingBonus    = 1;
            car.GetComponent <NeuralNetwork>().Sleep();
            isDriving = false;
            culled    = false;

            popMan.ResetDemoCar();
        }
    }
 void CheckReferences()
 {
     if (!itemManager)
     {
         itemManager = ReferenceManager.instance.itemManager;
     }
     if (!populationManager)
     {
         populationManager = ReferenceManager.instance.populationManager;
     }
 }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #27
0
 // Use this for initialization
 void Start()
 {
     daycount  = FindObjectOfType <Daycount>();
     gluttony  = Random.Range(5, 10);
     age       = 0;
     hunger    = 0;
     popc      = FindObjectOfType <PopulationManager>();
     rm        = FindObjectOfType <ResourceManager>();
     available = true;
     popc.IncreasePopulation(1);
 }
Beispiel #28
0
    public void Start()
    {
        if (instance != null)
        {
            Debug.Log("Hey bro, you tried to have 2 population managerinstances or something. f**k you.");
            Destroy(this);
        }
        instance = this;

        UpdateTextDisplay();
    }
        public AgentObject InitNewAgent(PopulationManager populationManager, Genome genome)
        {
            float xPos = Random.Range(-20f, 20f);
            float yPos = Random.Range(-20f, 20f);

            GameObject obj = Instantiate(_xorPrefab, new Vector3(xPos, yPos, 0), Quaternion.identity);

            obj.GetComponent <XOR_Agent>()._xorAgent = new XOR_Agent.XOR(genome, populationManager);

            return(obj.GetComponent <XOR_Agent>()._xorAgent);
        }
        public void GeneratePopulation_Should_Create_Given_Number_Of_Individuals_With_Given_Number_Of_Genes_Each_Between_One_And_Minus_One()
        {
            int individuals = 10;
            int genesEach   = 200;
            PopulationManager populationManagerTested = GetPopulationManager();

            populationManagerTested.GeneratePopulation(individuals, genesEach);

            populationManagerTested.Population.Should().HaveCount(individuals);
            populationManagerTested.Population.ForEach(p => p.Genes.Should().HaveCount(genesEach));
            populationManagerTested.Population.ForEach(p => p.Genes.ForEach(g => g.Should().BeInRange(-1, 1)));
        }
 /**
  * A public method to create the population manager if it does not exist
  * returns the same instance if the singleton already exists
  */
 public static PopulationManager createPopulationManager()
 {
     if (!alreadyExists)
     {
         Debug.Log("*** Population manager singleton created ***");
         GameObject go = new GameObject();
         populationManager = go.AddComponent<PopulationManager>();
         ///populationManager = new PopulationManager();
         alreadyExists = true;
         ///return populationManager;
     }
     Debug.Log("* * reference to singleton returned * *");
     return populationManager;
 }
 // Use this for initialization
 /**
  * Geta reference to the population manager
  */
 void Start()
 {
     popManager = PopulationManager.createPopulationManager();
 }
Beispiel #33
0
    /*
     * Initialization
     */
    void Start()
    {
        popManager = PopulationManager.createPopulationManager();

        startTime = (int) Time.time;
        //position of the npc spawnGO
        pos = this.transform.position;
    }