Пример #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);
        }
    }
Пример #2
0
        public override Queue <Location> ExtractPlan(Subject s, Intention i, Beliefs b, List <Location> path)
        {
            Queue <Location> plan = new Queue <Location>();
            Location         dest = new Location();

            HashSet <Location> fov = FOV.GetFov(b.Agents[i.ID].Direction, b.Agents[i.ID].Location);

            if (fov.Except(FOV.GetSharedFov(s, b.Agents[i.ID])).Count() > 0)
            {
                dest = Util.RandomElement(fov.Except(FOV.GetSharedFov(s, b.Agents[i.ID])).ToList(), s.Location);
            }
            else
            {
                dest = Util.RandomElement(fov.ToList(), s.Location);
            }

            FlankNode fNode = new FlankNode(null, dest, b.Agents[i.ID].Location)
            {
                CurLocation = new Location(s.Location),
                Obstacles   = new HashSet <Location>(b.Obstacles.Keys)
            };

            fNode.Obstacles.UnionWith(Util.GetDynamicObstacles(s.ID, s.Location, b));

            plan = Planner.Search(fNode);

            return(plan);
        }