예제 #1
0
        public Specimen ReproduseGomo()//создать свою копию
        {
            this.wantReproduse = false;
            Random r = new Random();

            int      immun         = this.immun;
            int      maxAge        = this.maxAge;
            int      sex           = this.sex;
            int      health        = this.health;
            int      x             = this.x;
            int      y             = this.y;
            int      MutateChanse  = this.MutateChanse;
            int      freqReproduse = this.freqReproduse;
            int      speed         = this.maxWay;
            Specimen newS          = new Specimen(immun, maxAge, sex, health, x, y, MutateChanse, freqReproduse, speed);

            newS.maxWay = freqReproduse;
            newS.Mutate();
            if (this.isSick)
            {
                newS.TryBeginSick(this.ill);
            }

            return(newS);
        }
예제 #2
0
        Specimen ReproduseGetero(ref Specimen secondParent)//размножиться с партнером
        {
            this.wantReproduse         = false;
            secondParent.wantReproduse = false;
            Random r = new Random();

            int      immun         = Convert.ToInt32((this.immun + secondParent.immun) / 2);
            int      maxAge        = Convert.ToInt32((this.maxAge + secondParent.maxAge) / 2);
            int      sex           = r.Next(1, 3);
            int      health        = Convert.ToInt32((this.health + secondParent.health) / 2);
            int      x             = Convert.ToInt32((this.x + secondParent.x) / 2);
            int      y             = Convert.ToInt32((this.y + secondParent.y) / 2);
            int      MutateChanse  = Convert.ToInt32((this.MutateChanse + secondParent.MutateChanse) / 2);
            int      freqReproduse = Convert.ToInt32((this.freqReproduse + secondParent.freqReproduse) / 2);
            int      speed         = Convert.ToInt32((this.maxWay + secondParent.maxWay) / 2);
            Specimen newS          = new Specimen(immun, maxAge, sex, health, x, y, MutateChanse, freqReproduse, speed);

            newS.maxWay = freqReproduse;
            newS.Mutate();
            if (this.isSick)//заражение партнера
            {
                secondParent.TryBeginSick(this.ill);
            }
            else
            {
                if (secondParent.isSick)
                {
                    this.TryBeginSick(secondParent.ill);
                }
            }
            //заражение ребенка
            if (this.sex == 1 && this.isSick)
            {
                newS.TryBeginSick(this.ill);
            }
            if (secondParent.sex == 1 && secondParent.isSick)
            {
                newS.TryBeginSick(secondParent.ill);
            }


            return(newS);
        }