-
Notifications
You must be signed in to change notification settings - Fork 6
/
World.py
54 lines (37 loc) · 1.35 KB
/
World.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
(c) 2015 Georgia Tech Research Corporation
This source code is released under the New BSD license. Please see the LICENSE.txt file included with this software for more information
authors: Arindam Bose (arindam.1993@gmail.com), Tucker Balch (trbalch@gmail.com)
'''
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
import os
from StatsTracker import StatsTracker
class World(object):
def __init__(self, width, height):
self.agents=[]
self.obstacles=[]
self.balls=[]
self.width = width
self.height = height
def draw(self, ax):
ax.set_xlim3d(-self.width,self.width)
ax.set_ylim3d(-self.width,self.width)
ax.set_zlim3d(-self.height,self.height)
for agent in self.agents:
agent.draw(ax)
for obstacle in self.obstacles:
obstacle.draw(ax)
for ball in self.balls:
ball.draw(ax)
return ax
def addAgent(self, agent):
self.agents.append(agent)
#add entry to stats tracker
StatsTracker.stunTimeDict[agent] = 0
def addBall(self, ball):
self.balls.append(ball)
def addObstacle(self, obstacle):
self.obstacles.append(obstacle)