Esempio n. 1
0
        public Chromosome CloneSpace()
        {
            var ChromosomeClone = new Chromosome();
            // Genes
            var genesListClone = new List <Gene>();

            foreach (var originalGene in this.genesList)
            {
                Gene gene = new Gene();
                gene.type           = originalGene.type;
                gene.SpaceAttribute = originalGene.SpaceAttribute;
                gene.isMainPath     = originalGene.isMainPath;
                genesListClone.Add(gene);
            }
            ChromosomeClone.genesList = genesListClone;

            // SpaceList
            var spaceListClone = new List <SpaceInfo>();

            foreach (var originalSpaceInfo in this.spaceList)
            {
                SpaceInfo spaceInfo = new SpaceInfo();
                spaceInfo.startPos       = originalSpaceInfo.startPos;
                spaceInfo.length         = originalSpaceInfo.length;
                spaceInfo.width          = originalSpaceInfo.width;
                spaceInfo.SpaceAttribute = originalSpaceInfo.SpaceAttribute;
                spaceListClone.Add(spaceInfo);
            }
            ChromosomeClone.spaceList = spaceListClone;

            return(ChromosomeClone);
        }
Esempio n. 2
0
        public Chromosome CloneSpaceGameObject()
        {
            var ChromosomeClone = new Chromosome();
            // Genes
            var genesListClone = new List <Gene>();

            foreach (var originalGene in this.genesList)
            {
                Gene gene = new Gene();
                gene.type                = originalGene.type;
                gene.SpaceAttribute      = originalGene.SpaceAttribute;
                gene.GameObjectAttribute = originalGene.GameObjectAttribute;
                gene.isMainPath          = originalGene.isMainPath;
                genesListClone.Add(gene);
            }
            ChromosomeClone.genesList = genesListClone;

            // SpaceList
            var spaceListClone = new List <SpaceInfo>();

            foreach (var originalSpaceInfo in this.spaceList)
            {
                SpaceInfo spaceInfo = new SpaceInfo();
                spaceInfo.startPos       = originalSpaceInfo.startPos;
                spaceInfo.length         = originalSpaceInfo.length;
                spaceInfo.width          = originalSpaceInfo.width;
                spaceInfo.SpaceAttribute = originalSpaceInfo.SpaceAttribute;
                spaceListClone.Add(spaceInfo);
            }
            ChromosomeClone.spaceList = spaceListClone;

            // gameObjectList
            var gameObjectListClone = new List <GameObjectInfo>();

            foreach (var originalGameObjectList in this.gameObjectList)
            {
                GameObjectInfo gameObjectInfo = new GameObjectInfo();
                gameObjectInfo.Position            = originalGameObjectList.Position;
                gameObjectInfo.GameObjectAttribute = originalGameObjectList.GameObjectAttribute;
                gameObjectListClone.Add(gameObjectInfo);
            }
            ChromosomeClone.gameObjectList = gameObjectListClone;

            // Main Path
            var mainPathListClone = new List <int>();

            foreach (var originalmainPath in this.mainPath)
            {
                mainPathListClone.Add(originalmainPath);
            }
            ChromosomeClone.mainPath = mainPathListClone;

            return(ChromosomeClone);
        }