Esempio n. 1
0
        public override byte Get_Action(Awareness Awareness)
        {
            // look for a human
            for (int x = 0; x < Awareness.map.GetLength(0); x++)
            {
                for (int y = 0; y < Awareness.map.GetLength(1); y++)
                {
                    if (Awareness.map[x, y] == Tile.Player)
                    {
                        if (x > Awareness.map.GetLength(0) / 2) return Action.Move_East;
                        else if (x < Awareness.map.GetLength(0) / 2) return Action.Move_West;
                        else if (y > Awareness.map.GetLength(1) / 2) return Action.Move_North;
                        else if (y > Awareness.map.GetLength(1) / 2) return Action.Move_South;
                    }
                }
            }

            // no human, wander in search of flesh
            switch (r.Next(0, 4))
            {
                case 0:
                    return Action.Move_North;
                case 1:
                    return Action.Move_South;
                case 2:
                    return Action.Move_East;
                case 3:
                    return Action.Move_West;
                default:
                    return Action.None;
            }
        }
Esempio n. 2
0
 public virtual byte Get_Action(Awareness Awareness)
 {
     switch (r.Next(0, 8))
     {
         case 0:
             return Action.Move_North;
         case 1:
             return Action.Move_South;
         case 2:
             return Action.Move_East;
         case 3:
             return Action.Move_West;
         case 4:
             return Action.Shoot_North;
         case 5:
             return Action.Shoot_South;
         case 6:
             return Action.Shoot_East;
         case 7:
             return Action.Shoot_West;
         default:
             return Action.None;
     }
 }
Esempio n. 3
0
 public override byte Get_Action(Awareness Awareness)
 {
     String awareness = get_awareness_string(Awareness);
     byte   action    = Action.None;
     lock (brain)
     {
         if (learnmode)
         {
             if (brain.ContainsKey(awareness)) action = brain[awareness].Get_Learn();
             else action = (byte)r.Next(0, Action.Total_Actions);
         }
         else
         {
             if (brain.ContainsKey(awareness)) action = brain[awareness].Get_Perform();
             else action = (byte)r.Next(0, Action.Total_Actions);
         }
     }
     trail.Add(new Trail(awareness, action));
     return action;
 }
Esempio n. 4
0
 public String get_awareness_string(Awareness Awareness)
 {
     String key = "";
     for (int x = 0; x < Awareness.map.GetLength(0); x++)
     {
         for (int y = 0; y < Awareness.map.GetLength(1); y++)
         {
             key += Awareness.map[x, y];
         }
     }
     return key;
 }
Esempio n. 5
0
        private Awareness build_awareness(int x, int y, int size)
        {
            // build awareness
            Awareness awareness = new Awareness(size);
            int xwalk, ywalk;
            xwalk = 0;
            ywalk = 0;
            for (int ax = x - size; ax <= x + size; ax++)
            {
                ywalk = 0;
                for (int ay = y - size; ay <= y + size; ay++)
                {
                    if (ax < 0 || ay < 0 || ax >= map.Width || ay >= map.Height) { ywalk++; continue; } // if we are oob the default is wall - we just skip over it

                    Color apixel = map.GetPixel(ax, ay);
                    if (apixel.ToArgb() == Human.ToArgb() || apixel.ToArgb() == Human_Post.ToArgb())
                        awareness.map[xwalk, ywalk] = Tile.Player;
                    else if (apixel.ToArgb() == Zombie.ToArgb() || apixel.ToArgb() == Zombie_Post.ToArgb())
                        awareness.map[xwalk, ywalk] = Tile.Zombie;
                    else if (apixel.ToArgb() == Empty.ToArgb())
                        awareness.map[xwalk, ywalk] = Tile.Empty;
                    else if (apixel.ToArgb() == Bullet_East.ToArgb() || apixel.ToArgb() == Bullet_East_Post.ToArgb() || apixel.ToArgb() == Bullet_North.ToArgb() || apixel.ToArgb() == Bullet_North_Post.ToArgb() || apixel.ToArgb() == Bullet_South.ToArgb() || apixel.ToArgb() == Bullet_South_Post.ToArgb() || apixel.ToArgb() == Bullet_West.ToArgb() || apixel.ToArgb() == Bullet_West_Post.ToArgb())
                        awareness.map[xwalk, ywalk] = Tile.Bullet;

                    ywalk++;
                }
                xwalk++;
            }
            return awareness;
        }