Пример #1
0
        public Ant(int x, int y, AntHill a)
            : base(x,y)
        {
            hasFood = false;
            status = "";
            anthill = a;

            nearestFood = null;

            current_job = new Job();
        }
Пример #2
0
 private void doJob()
 {
     if(current_job.getName() == "Food")
     {
         if(hasFood)
         {
             moveTo(anthill.getX(), anthill.getY());
             status = "Moving to anthill";
             if(atLoc(anthill.getX(), anthill.getY()))
             {
                 hasFood = false;
                 anthill.incFood(food_capacity);
                 current_job = new Job();
                 status = "";
             }
         }
         else
         {
             findnearestfood();
             status = "Moving to nearest food";
             nearestFood = findnearestfood();
             moveTo(nearestFood.getX(), nearestFood.getY());
         }
         if(atLoc(nearestFood.getX(), nearestFood.getY()) && !hasFood)
         {
             gatherFood();
         }
     }
 }