Пример #1
0
        //Constructor
        public Songs(SimParams par)
        {
            Match       = new float[par.NumBirds];
            MaleSongs   = new List <int> [par.NumBirds];
            FemaleSongs = new List <int> [par.NumBirds];

            if (par.MatchPreference == 0 && !par.SaveMatch)
            {
                for (int i = 0; i < par.NumBirds; i++)
                {
                    MaleSongs[i] = GenerateNovelSong(par);
                }
            }
            else  //Matching context
            {
                FemaleSongs = GenerateFemaleSongs(par);
                if (par.MaleDialects == "Same")
                {
                    for (int i = 0; i < MaleSongs.Length; i++)
                    {
                        MaleSongs[i] = FemaleSongs[i].ToList();
                    }
                }
                else
                {
                    for (int i = 0; i < par.NumBirds; i++)
                    {
                        MaleSongs[i] = GenerateNovelSong(par);
                    }
                    if (par.MaleDialects == "Similar" && par.NumDialects > 1)
                    {
                        MaleSongs = EstablishDialects(par, MaleSongs);
                    }
                }
                if (par.ChooseMate && par.MaleDialects != "Same")
                {
                    var          Assign        = AssignFemale(par, MaleSongs, FemaleSongs);
                    List <int>[] NewMaleSong   = new List <int> [par.NumBirds];
                    List <int>[] NewFemaleSong = new List <int> [par.NumBirds];
                    for (int i = 0; i < par.NumBirds; i++)
                    {
                        NewMaleSong[i]   = MaleSongs[Assign.MaleOrder[i]];
                        NewFemaleSong[i] = FemaleSongs[Assign.FemaleOrder[i]];
                    }
                    MaleSongs   = NewMaleSong;
                    FemaleSongs = NewFemaleSong;
                    Match       = Assign.Match;
                }
                else
                {
                    for (int i = 0; i < par.NumBirds; i++)
                    {
                        Match[i] = Songs.GetMatch(par, MaleSongs[i], FemaleSongs[i]);
                    }
                }
            }
        }
Пример #2
0
 private static Population UpdateSongTraits(SimParams par, Population pop, List <int> learners)
 {
     for (int i = 0; i < learners.Count; i++)
     {
         pop.SyllableRepertoire[learners[i]] = pop.MaleSong[learners[i]].Count;
         if (par.MatchPreference != 0 || par.SaveMatch)
         {
             pop.Match[learners[i]] = Songs.GetMatch(par, pop.MaleSong[learners[i]], pop.FemaleSong[learners[i]]);
         }
     }
     return(pop);
 }
Пример #3
0
        public void ReplaceBird(SimParams par, int father, int territory)
        {
            //manditory
            Bred[territory] = 0;
            Age[territory]  = 0;

            /*Each set either takes the fathers value or calculates a new values based on a
             * Distribution about the father's value.*/
            ChanceForget[territory] = par.InheritedChancetoForgetNoise != 0?
                                      (float)Inheritance(par.MinChancetoForget, par.MaxChancetoForget,
                                                         ChanceForget[father], par.InheritedChancetoForgetNoise, par.Rand)
                :ChanceForget[father];
            ChanceInvent[territory] = par.InheritedChancetoInventNoise != 0?
                                      (float)Inheritance(par.MinChancetoInvent, par.MaxChancetoInvent, ChanceInvent[father], par.InheritedChancetoInventNoise, par.Rand)
                :ChanceInvent[father];
            LearningThreshold[territory] = par.InheritedLearningThresholdNoise != 0?
                                           (float)Inheritance(par.MinLearningThreshold, par.MaxLearningThreshold, LearningThreshold[father], par.InheritedLearningThresholdNoise, par.Rand)
                :LearningThreshold[father];
            Accuracy[territory] = par.InheritedAccuracyNoise != 0?
                                  (float)Inheritance(par.MinAccuracy, par.MaxAccuracy, Accuracy[father], par.InheritedAccuracyNoise, par.Rand)
                :Accuracy[father];
            if (par.VerticalLearning)
            {
                MaleSong[territory] = Learning.VerticalLearning(par, this, father, territory);
            }
            else
            {
                MaleSong[territory] = new List <int> {
                };
            }
            SyllableRepertoire[territory] = MaleSong[territory].Count;

            //Optional
            if (par.SaveNames)
            {
                Name[territory]       = System.Guid.NewGuid().ToString();
                FatherName[territory] = Name[father];
            }
            if (par.MatchPreference != 0 || par.SaveMatch)
            {
                Match[territory] = Songs.GetMatch(par, MaleSong[territory], FemaleSong[territory]);
            }
        }