forked from sai-byui/NEO2D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.py
28 lines (20 loc) · 830 Bytes
/
environment.py
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
"""
The parent class of all environments. An environment serves as a interface where agents can share objects
with each other. All objects in an environment are accessible to any agent that knows about the environment
"""
class Environment:
def __init__(self):
self.objects = {}
self.agents = {}
def get_object(self, object_name):
if object_name in self.objects:
return self.objects[object_name]
def add_object(self, object_name, item):
self.objects[object_name] = item
def update_object(self, object_name, item):
self.objects[object_name] = item
def remove_object(self, object_name):
if object_name in self.objects:
self.objects.pop(object_name)
def add_agent(self, agent_name, agent):
self.agents[agent_name] = agent