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(); }
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; }
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); } }