示例#1
0
        /// <summary>
        /// Запустить генетическую программу
        /// </summary>
        private void GeneticProgram()
        {
            foreach (BlockPlant OneBlockPlant in ListBlocksPlant)
            {
                OneBlockPlant.Activate();
                ///rand = MainWorld.GlobalRand.Next(ActionsOfPlants.LengthActionsOfPlants);
                switch (Genomes.GetGeneCommand(IndexGenocode, 0, OneBlockPlant.GoActiveGene()))
                {
                case (int)TypeActionsOfPlants.GrowUp:
                    AddNewBlockPlant(OneBlockPlant.X, OneBlockPlant.Y + 1, OneBlockPlant);
                    break;

                case (int)TypeActionsOfPlants.GrowLeft:
                    AddNewBlockPlant(OneBlockPlant.X - 1, OneBlockPlant.Y, OneBlockPlant);
                    break;

                case (int)TypeActionsOfPlants.GrowRight:
                    AddNewBlockPlant(OneBlockPlant.X + 1, OneBlockPlant.Y, OneBlockPlant);
                    break;

                case (int)TypeActionsOfPlants.GrowDown:
                    AddNewBlockPlant(OneBlockPlant.X, OneBlockPlant.Y - 1, OneBlockPlant);
                    break;

                default:
                    break;
                }
                OneBlockPlant.NextActiveGene();
            }

            if (StackBlocksPlant.Count > 0)
            {
                AddListNewBlocksPlant();
            }
        }