Exemple #1
0
        /*Main simulation processes: removal of bids
         * and genertaion of news ones*/
        public static Population Step(SimParams par, Population pop)
        {
            int[]      Vacant;
            List <int> NotVacant = Enumerable.Range(0, par.NumBirds).ToList();

            //Chose birds to die, mark ones still alive
            if (par.AgeDeath)
            {
                Vacant = AgeDeath(par, pop);
            }
            else
            {
                Vacant = RandomDeath(par, pop);
            }
            for (int i = 0; i < Vacant.Length; i++)
            {
                NotVacant.Remove(Vacant[i]);
            }
            //Allow for oblique learning and age up
            if (par.ObliqueLearning)
            {
                Learning.ObliqueLearning(par, pop, Vacant, NotVacant);
            }
            for (int i = 0; i < NotVacant.Count; i++)
            {
                pop.Age[NotVacant[i]] += 1;
            }

            //Pick new mates
            if (par.ChooseMate)
            {
                Songs.ChooseMates(par, pop);
            }

            //Determine fathers and generate chicks
            int[] FatherInd = ChooseMaleFathers(par, pop, Vacant, NotVacant);
            for (int i = 0; i < FatherInd.Length; i++)
            {
                pop.ReplaceBird(par, FatherInd[i], Vacant[i]);
            }

            //allow for chicks to overlearn, update match and sylrep
            if (par.OverLearn == true)
            {
                Learning.OverLearn(par, pop, Vacant, NotVacant);
            }

            /*Allow the females to die and be replaced */
            if (par.FemaleEvolution)
            {
                int[] FemaleFathers = ChooseFemaleFathers(par, pop,
                                                          Vacant, NotVacant, FatherInd);
                for (int i = 0; i < Vacant.Length; i++)
                {
                    pop.FemaleSong[Vacant[i]] = pop.MaleSong[FatherInd[i]];
                }
            }

            if (par.SocialCues || par.SocialPreference > 0)
            {
                HashSet <int> Fathers = FatherInd.ToHashSet();
                for (int i = 0; i < par.NumBirds; i++)
                {
                    if (Fathers.Contains(i))
                    {
                        pop.Bred[i] = par.SocialBred;
                    }
                    else
                    {
                        pop.Bred[i] = par.SocialNotBred;
                    }
                }
            }
            //update survival probability
            if (par.AgeDeath)
            {
                UpdateDeathProbabilities(par, pop, FatherInd);
            }
            return(pop);
        }