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
41 """
42 The state of the ship for an outside observer
43 """
44
45 - def __init__(self, x, y, orientation, speed, angularSpeed):
46 """
47 Initialize an I{external state} of a ship, namely its position and speeds
48
49 @type x: float
50 @param x: x-position, in meters
51
52 @type y: float
53 @param y: y-position, in meters
54
55 @type orientation: float
56 @param orientation: the ship orientation, where -180 < orientation <= 180 degrees
57
58 @type speed: float
59 @param speed: ship forward speed in m/sec (TODO: need to replace it by x-speed and y-speed)
60
61 @type angularSpeed: float
62 @param angularSpeed: ship angular speed in deg / sec
63 """
64 self.x = x
65 self.y = y
66 self.orientation = orientation
67 self.speed = speed
68 self.angularSpeed = angularSpeed
69
71 return "\nExternal State:" + \
72 " x=" + str(self.x) + \
73 " y=" + str(self.y) + \
74 " orientation=" + str(self.orientation) + \
75 " speed=" + str(self.speed) + \
76 " angularSpeed=" + str(self.angularSpeed) + "\n"
77
78
79
80
81
83 """
84 This is a base class for the world state.
85 """
86
87 - def __init__(self, sea, ships, shipExternalStates):
88 """
89 Initialize the world state that is external to the agent.
90
91 @type sea: Sea
92 @param sea: the sea model
93
94 @type ships: array of Ship
95 @param ships: the ships being simulated
96
97 @type shipExternalStates: array of ShipExternalStates
98 @param shipExternalStates: the external states of the ships, namely their global positions
99 """
100
101 self.sea = sea
102 self.ships = ships
103 self.shipExternalStates = shipExternalStates
104
106 res = "\n\nWorld State: \n"
107 res += str(self.sea)
108 res += "\nShips:\n"
109 for ship, state in zip(self.ships, self.shipExternalStates):
110 res += str(ship) + str(state)
111 return res
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136