Ejemplo n.º 1
0
        public void PerformAction()
        {
            //Console.WriteLine("Foraging...");
            if (me.sensoryInput.Count > 0)
            {
                //TODO: Code refactoring, access to pathsToFood
                List <Ants.Vector2> temp = new List <Ants.Vector2>();
                temp.AddRange(me.myPath);
                me.myAnthill.pathsToFood.Add(temp);
                finished = true;
            }
            if (Ants.Vector2.Distance(me.position, me.myAnthill.position) > Variables.maximumDistanceFromAnthill)
            {
                finished = true;
            }

            Random r  = Program.globalRandom;
            double d1 = r.NextDouble(0, Variables.maximumDistanceToNewTarget);
            double d2 = Variables.maximumDistanceToNewTarget - d1;

            if (r.Next(2) > 0)
            {
                d2 *= -1;
            }
            if (r.Next(2) > 0)
            {
                d1 *= -1;
            }
            Ants.Vector2 target = me.position + new Ants.Vector2(d1, d2);
            me.MoveTo(target);
            me.myPath.Add(target);
        }
Ejemplo n.º 2
0
 public void MoveTo(Ants.Vector2 pos)
 {
     target = pos;
 }