1 from teamwork.agent.RecursiveAgent import RecursiveAgent
2 from copy import deepcopy
3
5 '''
6 Memory is stored in a list such that the most recent memory is the 0th element in the list
7 and the oldest memory is the n-1th memory in the list where n is the memory length
8 '''
9
14
16 memory = {}
17
18
19 memory['actions'] = actions.copy()
20
21
22 memory['previousBeliefs'] = deepcopy(previousBeliefs)
23
24
25 self.memory.insert(0, memory)
26
27
28 if len(self.memory) > self.memoryLength:
29 self.memory.pop()
30
31 if __name__ == '__main__':
32 from teamwork.multiagent.GenericSociety import GenericSociety
33 from teamwork.multiagent.sequential import SequentialAgents
34 import teamwork.examples.school.SchoolClasses as classModule
35 from teamwork.multiagent.Historical import HistoricalAgents
36
37
38 society = GenericSociety()
39 society.importDict(classModule.classHierarchy)
40
41
42 victim = society.instantiate("Victim", "Victim")
43 onlooker = society.instantiate("Onlooker", "Onlooker")
44 bully = society.instantiate("Bully", "Bully")
45 teacher = society.instantiate("Teacher", "Teacher")
46
47
48 victim.relationships['victim'] = ['Victim']
49 onlooker.relationships['victim'] = ['Victim']
50 bully.relationships['victim'] = ['Victim']
51
52
53 entities = [victim, onlooker, bully, teacher]
54 agents = SequentialAgents(entities)
55 agents.applyDefaults()
56 agents.compileDynamics()
57
58 result = agents.microstep()
59 agents.microstep()
60
61 print "\n\nmemory!\n\n"
62
63
64 print victim.entities.getStateKeys().keys()
65
66
67
68
69
70
71
72
73
74
75
76