Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            myScent = new Scent(WWIDTH, WHEIGHT);
            myWorld = new World(WWIDTH, WHEIGHT, NUM_ANTS, (int)FoodPilesBox.Value, (int)FoodPerPileBox.Value, myScent);

            for (int r = 105; r < 116; r++)
            {
                for (int c = 50; c < 61; c++)
                {
                    myWorld.field[c, r] = 2;
                }
            }

            for (int i = 0; i < 200; i++)
            {
                myScent.AddHome(WWIDTH / 2, WHEIGHT / 2);
                myScent.AddHome((WWIDTH / 2 + 1), WHEIGHT / 2);
                myScent.AddHome(WWIDTH / 2, (WHEIGHT / 2 + 1));
                myScent.AddHome((WWIDTH / 2 + 1), (WHEIGHT / 2 + 1));
            }

            b = new Bitmap(WWIDTH, WHEIGHT);
            g = Graphics.FromImage(b);
            pictureBox1.Image = b;
            Display();
        }
Ejemplo n.º 2
0
 public Ant(World w, Scent s, int i)
 {
     world         = w;
     scent         = s;
     index         = i;
     x             = world.width / 2;
     y             = world.height / 2;
     dir           = (Direction)rand.Next(8);
     stepsFromHome = 50;
     poison        = 0;
     resistance    = rand.Next(100);
     alive         = true;
 }
Ejemplo n.º 3
0
        public World(int initWidth, int initHeight, int numAnts, int FoodPiles, int FoodPerPile, Scent s)
        {
            field  = new int[initHeight, initWidth];
            height = initHeight;
            width  = initWidth;
            scent  = s;

            piles = new int[FoodPiles, 2];
            NewPiles(FoodPiles, FoodPerPile);

            ants = new Ant[numAnts];
            for (int i = 0; i < numAnts; i++)
            {
                ants[i] = new Ant(this, scent, i);
            }
        }