-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathold_world.py
95 lines (75 loc) · 2.61 KB
/
old_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import numpy as np
import math
class World:
'World class for the physics engine.'
def __init__(self):
self.actorList = [] # container for the objects in this world
# define position of objects
actorList.append(Robot(np.array([0, 0, 0])))
actorList.append(Gate(np.array([5, 3, 0])))
actorList.append(Buoy(np.array([7, 5, 0])))
actorList.append(ChipDispenser(np.array([7, 7, 0])))
actorList.append(SlotMachine(np.array([14, 5, 0])))
actorList.append(ChipDispenser(np.array([14, 7, 0])))
actorList.append(Roulette(np.array([20, 10, 0])))
actorList.append(Register(np.array([24, 13, 0])))
actorList.append(Bin(np.array([24, 14, 0])))
# Create new objects in case we encounter unaccounted things.
# There could be multiple buoys and bins.
def create_actor(self, actorType, position):
if actorType == 0:
new_actor = Actor(position)
self.actorList.append(new_actor)
return new_actor
elif actorType == 1:
new_actor = Buoy(position)
self.actorList.append(new_actor)
return new_actor
elif actorType == 2:
new_actor = Bin(position)
self.actorList.append(new_actor)
return new_actor
else:
print "Invalid actor type."
# Deletes actor from world
def delete_actor(self, actor):
self.actorList.remove(actor)
# Display everything we know about the world.
def display_actors(self):
for a in self.actorList:
print '-', a.name, a.position
class Actor:
'Base class for all actors.'
name = "Obstacle"
def __init__(self, position):
self.position = position # position of actor in the world
# Updates actor position
def update_position(self, new_position):
self.position = new_position
class Robot(Actor):
'Robot class for our robot.'
name = "Robot"
def __init__(self, position):
self.velocity = [0, 0, 0] # initial velocity
self.w = 0 # angular velocity
self.a = 0 # alpha; angular acceleration
self.t = 0 # time
class Buoy(Actor):
'Buoy class.'
name = "Buoy"
class ChipDispenser(Actor):
'Chip dispenser class. Could have at least 2.'
name = "Chip Dispenser"
class SlotMachine(Actor):
'Slot machine class.'
name = "Slot Machine"
class Roulette(Actor):
'Roulette class.'
name = "Roulette"
class Register(Actor):
'Cashier Register class.'
name = "Register"
class Bin(Actor):
'Bins/funnels with different colors.'
name = "Bin"
r = World()