-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToMReasoner.cs
30 lines (24 loc) · 1 KB
/
ToMReasoner.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
public class ToMReasoner
{
// 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);
}
}
}