Ejemplo n.º 1
0
    // The recursive higher-order observation method as described in the thesis.
    // It has a height limiter to specify the desired max order of observation.
    public void UpdateToM(Subject s, Beliefs b, HashSet <Location> fov, int height)
    {
        if (height == 0 || b.Sees.Agents.Count == 0)
        {
            return;
        }

        foreach (KeyValuePair <char, Subject> kvp in b.Sees.Agents)
        {
            HashSet <Location> intersectFov = FOV.GetSharedFov(kvp.Value, s);

            VisionPercept vp = Sight.Perceive(kvp.Key, intersectFov);
            AudioPercept  ap = Hearing.Perceive(kvp.Key, kvp.Value.Location);

            if (!b.ToM.ContainsKey(kvp.Key))
            {
                b.ToM.Add(kvp.Key, new Beliefs());
            }

            b.ToM[kvp.Key].Update(vp);
            b.ToM[kvp.Key].Update(ap);

            UpdateToM(kvp.Value, b.ToM[kvp.Key], intersectFov, height - 1);
        }
    }
Ejemplo n.º 2
0
 public Beliefs()
 {
     Agents    = new Dictionary <char, Subject>();
     Obstacles = new Dictionary <Location, Obstacle>();
     Foods     = new Dictionary <Location, Food>();
     Rooms     = new Dictionary <char, Room>();
     Sees      = new VisionPercept();
     Hears     = new AudioPercept();
     ToM       = new Dictionary <char, Beliefs>();
 }
Ejemplo n.º 3
0
Archivo: Agent.cs Proyecto: s162995/CtC
    // The agent generates audio and vision percept from the locations
    // within the agent's field of view.
    protected List <IPercept> Perceive()
    {
        HashSet <Location> fov = FOV.GetFov(Direction, Location);

        VisionPercept p  = Sight.Perceive(ID, fov);
        AudioPercept  p2 = Hearing.Perceive(ID, Location);

        Piece.DisplayFeature(fov.ToList(), Feature.Vision);
        Piece.DisplayFeature(fov.Intersect(Manager.Board.Obstacles.Keys).ToList(), Feature.Obstacle);
        Piece.DisplayFeature(fov.Intersect(Manager.Board.Foods.Keys).ToList(), Feature.Food);

        return(new List <IPercept>()
        {
            p, p2
        });
    }
Ejemplo n.º 4
0
    // Hearing is determined by checking for sound at the agents current
    // location.
    public static AudioPercept Perceive(char agtID, Location loc)
    {
        AudioPercept p = new AudioPercept();

        foreach (Agent a in Manager.Board.Agents.Values)
        {
            if (a.Noise == null || a.ID == agtID)
            {
                continue;
            }

            if (a.Noise.Contains(Manager.Board.Agents[agtID].Location))
            {
                p.Agents.Add(a.ID, new Subject(a.ID, a.Location));
            }
        }

        return(p);
    }
Ejemplo n.º 5
0
Archivo: Agent.cs Proyecto: s162995/CtC
    // The percepts are passed to the belief-revision function, which updates
    // the agent's beliefs.
    protected virtual Beliefs BRF(Beliefs b, List <IPercept> p)
    {
        VisionPercept vp = new VisionPercept();
        AudioPercept  ap = new AudioPercept();

        foreach (IPercept ip in p)
        {
            if (ip is VisionPercept)
            {
                vp = (VisionPercept)ip;
            }
            else
            {
                ap = (AudioPercept)ip;
            }
        }

        b.Update(vp);
        b.Update(ap);

        return(b);
    }
Ejemplo n.º 6
0
 // Updates the beliefs according to what the agent hears.
 public void Update(AudioPercept ap)
 {
     Hears = ap;
 }