示例#1
0
        private void InitializeLabels()
        {
            this.CounterLabel              = new Label();
            this.CounterLabel.Top          = 5;
            this.CounterLabel.Left         = this.Width - 90;
            this.CounterLabel.Font         = new Font(FontFamily.GenericSerif, 21);
            this.CounterLabel.ForeColor    = Color.Black;
            this.CounterLabel.SizeChanged += labelResize;
            this.CounterLabelData          = 0;
            this.CounterLabel.BackColor    = Color.Transparent;
            this.CounterLabel.AutoSize     = true;
            this.CounterLabel.Text         = CounterLabelData.ToString();

            this.HighScoreLabel              = new Label();
            this.HighScoreLabel.Top          = 35;
            this.HighScoreLabel.Left         = this.Width - 135;
            this.HighScoreLabel.Font         = new Font(FontFamily.GenericSerif, 21);
            this.HighScoreLabel.ForeColor    = Color.Black;
            this.HighScoreLabel.SizeChanged += labelResize2;
            this.HighScoreLabelData          = 0;
            this.HighScoreLabel.BackColor    = Color.Transparent;
            this.HighScoreLabel.AutoSize     = true;
            this.HighScoreLabel.Text         = "High:" + HighScoreLabelData.ToString();

            this.GenerationLabel              = new Label();
            this.GenerationLabel.Top          = 70;
            this.GenerationLabel.Left         = this.Width - 135;
            this.GenerationLabel.Font         = new Font(FontFamily.GenericSerif, 21);
            this.GenerationLabel.ForeColor    = Color.Black;
            this.GenerationLabel.SizeChanged += labelResize3;
            this.GenerationLabelData          = 0;
            this.GenerationLabel.BackColor    = Color.Transparent;
            this.GenerationLabel.AutoSize     = true;
            this.GenerationLabel.Text         = "Gen:" + GenerationLabelData.ToString();

            this.PopulationLabel           = new Label();
            this.PopulationLabel.Top       = 105;
            this.PopulationLabel.Left      = this.Width - 135;
            this.PopulationLabel.Font      = new Font(FontFamily.GenericSerif, 21);
            this.PopulationLabel.ForeColor = Color.Black;
            this.PopulationLabelData       = 0;
            this.PopulationLabel.BackColor = Color.Transparent;
            this.PopulationLabel.AutoSize  = true;
            this.PopulationLabel.Text      = "Live:" + PopulationLabelData.ToString();
        }
示例#2
0
        private void NextGeneration()
        {
            GenerationLabelData++;
            GenerationLabel.Text = "Gen:" + GenerationLabelData.ToString();
            this.birds           = new List <Bird>();
            pipes.Clear();
            Pipe initPipe = Pipe.RandomPipe(70, 120, 550, 750);

            initPipe.Up_X   = 500;
            initPipe.Down_X = 500;
            initPipe.Update();
            pipes.Add(initPipe);

            CalculateFitness();

            for (int i = 0; i < population; i++)
            {
                birds.Add(PickOne());
            }
        }