Beispiel #1
0
        private void Start()
        {
            if (g != null)
            {
                timer1.Enabled = true;
                if (CS == CurrentSimulation.EString)
                {
                    listView1.Items.Clear();
                    if (textBoxTargetString.Text != "")
                    {
                        {
                            EString.target = textBoxTargetString.Text;
                            EString.Execute(g, listView1);
                        }
                    }
                }

                if (CS == CurrentSimulation.Ants)
                {
                    world.Step();
                }


                //timer1.Enabled = true;
            }
        }
 private void initializeToolStripMenuItem2_Click(object sender, EventArgs e)
 {
     if (!drawingSurfaceInitialized)
     {
         InitializeDrawingSurface();
     }
     DestroyAll();
     listView1.Items.Clear();
     DestroyAll();
     listView1.Visible = true;
     CS    = CurrentSimulation.Ants;
     world = new Cosmos(int.Parse(textBoxFood.Text), int.Parse(textBoxNo.Text), mainPanel.ClientSize, g, listView1, mainPanel, grafx);
     world.Step();
 }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!leaveTrail)
            {
                ClearScreen();
            }
            switch (CS)
            {
            case CurrentSimulation.SteeringBehaviours:
                if (sBC != null)
                {
                    sBC.Step();
                }
                break;

            case CurrentSimulation.EString:
                newPoint = new Point(80 + (EString.generationCount * 2), 450 - (EString.errorCount * 2));
                g.DrawLine(boldPen, oldPoint, newPoint);
                oldPoint = newPoint;
                g.DrawString("E Strings", new Font(FontFamily.GenericSansSerif, 14), Brushes.White, new PointF(20, 20));
                g.DrawString("Target String: " + EString.target, new Font(FontFamily.GenericSansSerif, 20), Brushes.PaleGoldenrod, new PointF(20, 50));
                g.DrawString("Error Graph", new Font(FontFamily.GenericSansSerif, 20), Brushes.Yellow, new PointF(180, 180));
                g.DrawLine(arrowPen, axisPoints[1], axisPoints[0]);
                g.DrawLine(arrowPen, axisPoints[1], axisPoints[2]);
                g.DrawString("Y", this.Font, Brushes.White, new PointF(axisPoints[0].X - 30, axisPoints[0].Y));
                g.DrawString("X", this.Font, Brushes.White, new PointF(axisPoints[2].X - 10, axisPoints[2].Y + 25));
                g.DrawString("0", this.Font, Brushes.White, new PointF(axisPoints[1].X - 10, axisPoints[1].Y + 10));
                break;

            case CurrentSimulation.Ants:
                if (world != null)
                {
                    world.Step();
                }
                break;

            default:
                break;
            }
            DrawTitle();
            grafx.Render(Graphics.FromHwnd(mainPanel.Handle));
        }
Beispiel #4
0
 private void initializeToolStripMenuItem2_Click(object sender, EventArgs e)
 {
     if (!drawingSurfaceInitialized)
         InitializeDrawingSurface();
     DestroyAll();
     listView1.Items.Clear();
     DestroyAll();
     listView1.Visible = true;
     CS = CurrentSimulation.Ants;
     world = new Cosmos(int.Parse(textBoxFood.Text), int.Parse(textBoxNo.Text), mainPanel.ClientSize, g, listView1, mainPanel, grafx);
     world.Step();
 }