Beispiel #1
0
 public Simulator(int noRobots, int speed, int width, int height, int minCovarage, int noTrails, Visual visualForm)
 {
     random = new Random();
     NoRobots = noRobots;
     Speed = speed;
     Width = width;
     Height = height;
     MinCovarage = minCovarage;
     NoTrials = noTrails;
     Trials = new List<int>[NoTrials];
     for (int i = 0; i < NoTrials; i++)
         Trials[i] = new List<int>();
     TimeSteps = new int[NoTrials];
     Room = new RectangularRoom(Width, Height);
     Robots = new List<BaseRobot>();
     for (int i = 0; i < NoRobots; i++)
         Robots.Add(new BaseRobot(Room, Speed, random));
     this.visualForm = visualForm;
     visualForm.Sim = this;
 }
Beispiel #2
0
        private void Simulate_Click_1(object sender, EventArgs e)
        {
            visualForm = new Visual();
            sim = new Simulator((int)numericUpDown1.Value, (int)numericUpDown4.Value, (int)numericUpDown2.Value,
                (int)numericUpDown3.Value, (int)numericUpDown5.Value, (int)numericUpDown6.Value, visualForm);

            if (sim.NoTrials <= 1)
            {
                visualForm.Width = sim.Room.Width + 18;
                visualForm.Height = sim.Room.Height + 40;
                visualForm.Show(this);
                MoveChildForm();
                visualForm.Invalidate();
                timer1.Enabled = true;
            }
            else
            {
                sim.RunSimulation();
                richTextBox1.Text = sim.PrintData();
            }
        }