Beispiel #1
0
        /// <summary>
        /// Explicit pheromone dropping
        /// The pheromone will NOT be dropped if it is not allowed for the ant type
        /// </summary>
        /// <param name="ant"></param>
        /// <param name="pherotype"></param>
        void IMotherNature.DropPheromon(Ant ant, MotherNature.PheromonTypes pherotype)
        {
            switch (ant.GetType().Name) // Must use name and not full type, because Ants have the same class names in different colonies
            {
            case "FarmerAnt":
                if (pherotype != MotherNature.PheromonTypes.Food)
                {
                    return;
                }
                break;

            case "WorkerAnt":
                if (pherotype != MotherNature.PheromonTypes.Build)
                {
                    return;
                }
                break;

            case "ScoutAnt":
                if (pherotype != MotherNature.PheromonTypes.Food && pherotype != MotherNature.PheromonTypes.Danger)
                {
                    return;
                }
                break;

            case "SoldierAnt":
                if (pherotype != MotherNature.PheromonTypes.Danger)
                {
                    return;
                }
                break;
            }
            // if we make it there: we passed the test
            pheromons.Add(new Pheromon(new System.Drawing.Point((int)ant.X, (int)ant.Y), pherotype, ant.Colony));
        }
Beispiel #2
0
 public Pheromon(Point loc, MotherNature.PheromonTypes pherotype, Colony col)
 {
     location     = loc;
     pheromontype = pherotype;
     colony       = col;
     birthday     = col.World().universaltime.Elapsed;
 }