예제 #1
0
파일: Tower.cs 프로젝트: Exospector/Tower
 public static Tower ConstructTower1(Tower tow)
 {
     Tower retour=(Tower)tow.MemberwiseClone ();
     retour.fitness = 0;
     mutation (retour);
     return retour;
 }
예제 #2
0
        public static Tower ConstructTower1(Tower tow)
        {
            Tower retour = (Tower)tow.MemberwiseClone();

            retour.fitness = 0;
            mutation(retour);
            return(retour);
        }
예제 #3
0
파일: Tower.cs 프로젝트: Exospector/Tower
        public static Tower ConstructTower2(Tower parent1,Tower parent2)
        {
            int total = 50;
            int i = 0;
            Tower retour=(Tower)parent1.MemberwiseClone ();
            List<Arme> temp = new List<Arme> (parent1.weapons);
            parent1.weapons.Clear ();
            int random = 0;
            while (total>0&&temp.Count>0) {
                int decrement=0;
                random=UnityEngine.Random.Range(0,temp.Count);
                    if(temp[random].taille==(int)taille.grand){
                    decrement+=10;
                }else{
                    decrement+=5;
                }
                if(temp[random].Type==(int)type.laser){
                }else if (temp[random].Type==(int)type.minigun){
                }else{
                }
                total-=decrement;

                if(total>=0){
                    retour.weapons.Add(temp[random]);
                }
                temp.RemoveAt(random);

                i++;
            }

            total = 50;

            temp = new List<Arme> (parent2.weapons);
            while (total>0&&temp.Count>0) {
                int decrement=0;

                random=UnityEngine.Random.Range(0,temp.Count);
                if(temp[random].taille==(int)taille.grand){
                    decrement+=10;
                }else{
                    decrement+=5;
                }
                if(temp[random].Type==(int)type.laser){
                }else if (temp[random].Type==(int)type.minigun){
                }else{
                }

                if(retour.weapons.Exists(ar=>ar.pos.x==temp[random].pos.x&&ar.pos.y==temp[random].pos.y&&ar.pos.z==temp[random].pos.z)){
                        decrement=0;
                }
                total-=decrement;
                if(total>=0&&decrement!=0){
                    retour.weapons.Add(temp[random]);
                }
                temp.RemoveAt(random);

            }

            retour.fitness = 0;
            mutation (retour);
            return retour;
        }
예제 #4
0
        public static Tower ConstructTower2(Tower parent1, Tower parent2)
        {
            int         total  = 50;
            int         i      = 0;
            Tower       retour = (Tower)parent1.MemberwiseClone();
            List <Arme> temp   = new List <Arme> (parent1.weapons);

            parent1.weapons.Clear();
            int random = 0;

            while (total > 0 && temp.Count > 0)
            {
                int decrement = 0;
                random = UnityEngine.Random.Range(0, temp.Count);
                if (temp[random].taille == (int)taille.grand)
                {
                    decrement += 10;
                }
                else
                {
                    decrement += 5;
                }
                if (temp[random].Type == (int)type.laser)
                {
                }
                else if (temp[random].Type == (int)type.minigun)
                {
                }
                else
                {
                }
                total -= decrement;

                if (total >= 0)
                {
                    retour.weapons.Add(temp[random]);
                }
                temp.RemoveAt(random);

                i++;
            }

            total = 50;

            temp = new List <Arme> (parent2.weapons);
            while (total > 0 && temp.Count > 0)
            {
                int decrement = 0;

                random = UnityEngine.Random.Range(0, temp.Count);
                if (temp[random].taille == (int)taille.grand)
                {
                    decrement += 10;
                }
                else
                {
                    decrement += 5;
                }
                if (temp[random].Type == (int)type.laser)
                {
                }
                else if (temp[random].Type == (int)type.minigun)
                {
                }
                else
                {
                }


                if (retour.weapons.Exists(ar => ar.pos.x == temp[random].pos.x && ar.pos.y == temp[random].pos.y && ar.pos.z == temp[random].pos.z))
                {
                    decrement = 0;
                }
                total -= decrement;
                if (total >= 0 && decrement != 0)
                {
                    retour.weapons.Add(temp[random]);
                }
                temp.RemoveAt(random);
            }


            retour.fitness = 0;
            mutation(retour);
            return(retour);
        }