Compare commits
No commits in common. "1ef66a7674078b58f41f4cfce8d6a76d812020e4" and "0fe5c35dda5fd66909f115611cb3eb6f680388a2" have entirely different histories.
1ef66a7674
...
0fe5c35dda
@ -368,9 +368,6 @@ class TeleportingReward(OnceReward):
|
|||||||
self.env.check_collisions_for(self)
|
self.env.check_collisions_for(self)
|
||||||
|
|
||||||
def on_collected(self):
|
def on_collected(self):
|
||||||
# Force rerender of value func (even in static envs)
|
|
||||||
self.env._invalidate_value_map()
|
|
||||||
|
|
||||||
self.env.new_abs_reward += self.reward
|
self.env.new_abs_reward += self.reward
|
||||||
self.pos = (self.env.random(), self.env.random())
|
self.pos = (self.env.random(), self.env.random())
|
||||||
self.env.check_collisions_for(self)
|
self.env.check_collisions_for(self)
|
||||||
@ -385,9 +382,6 @@ class LoopReward(OnceReward):
|
|||||||
self.barrier_physics = False
|
self.barrier_physics = False
|
||||||
|
|
||||||
def jump_to_state(self):
|
def jump_to_state(self):
|
||||||
# Force rerender of value func (even in static envs)
|
|
||||||
self.env._invalidate_value_map()
|
|
||||||
|
|
||||||
pos_vec = [v for v in self.loop[self.state]]
|
pos_vec = [v for v in self.loop[self.state]]
|
||||||
if len(pos_vec) == 4:
|
if len(pos_vec) == 4:
|
||||||
pos_vec = pos_vec[0] + pos_vec[2] * \
|
pos_vec = pos_vec[0] + pos_vec[2] * \
|
||||||
@ -428,9 +422,6 @@ class TimeoutReward(OnceReward):
|
|||||||
|
|
||||||
def on_collected(self):
|
def on_collected(self):
|
||||||
if self.avaible:
|
if self.avaible:
|
||||||
# Force rerender of value func (even in static envs)
|
|
||||||
self.env._invalidate_value_map()
|
|
||||||
|
|
||||||
self.env.new_abs_reward += self.reward
|
self.env.new_abs_reward += self.reward
|
||||||
self.set_avaible(False)
|
self.set_avaible(False)
|
||||||
self.env.timers.append((self.timeout, self.set_avaible, True))
|
self.env.timers.append((self.timeout, self.set_avaible, True))
|
||||||
@ -477,9 +468,6 @@ class TeleportingGoal(Goal):
|
|||||||
self.env.check_collisions_for(self)
|
self.env.check_collisions_for(self)
|
||||||
|
|
||||||
def on_collected(self):
|
def on_collected(self):
|
||||||
# Force rerender of value func (even in static envs)
|
|
||||||
self.env._invalidate_value_map()
|
|
||||||
|
|
||||||
self.env.new_abs_reward += self.reward
|
self.env.new_abs_reward += self.reward
|
||||||
self.pos = (self.env.random(), self.env.random())
|
self.pos = (self.env.random(), self.env.random())
|
||||||
self.env.check_collisions_for(self)
|
self.env.check_collisions_for(self)
|
||||||
|
@ -381,13 +381,13 @@ class ColumbusEnv(gym.Env):
|
|||||||
pygame.draw.circle(self.screen, smolcol, (20+int(60*x) +
|
pygame.draw.circle(self.screen, smolcol, (20+int(60*x) +
|
||||||
self.joystick_offset[0], 20+int(60*y)+self.joystick_offset[1]), 20, width=0)
|
self.joystick_offset[0], 20+int(60*y)+self.joystick_offset[1]), 20, width=0)
|
||||||
|
|
||||||
def _draw_confidence_ellipse(self, chol, forceDraw=False, seconds=0.5):
|
def _draw_confidence_ellipse(self, chol, forceDraw=False, seconds=1):
|
||||||
# The 'seconds'-parameter only really makes sense, when using control_type='SPEED',
|
# The 'seconds'-parameter only really makes sense, when using control_type='SPEED',
|
||||||
# you can still use it to scale the cov-ellipse when using control_type='ACC',
|
# you can still use it to scale the cov-ellipse when using control_type='ACC',
|
||||||
# but it's relation to 'seconds' is no longer there...
|
# but it's relation to 'seconds' is no longer there...
|
||||||
if self.draw_confidence_ellipse and (self.visible or forceDraw):
|
if self.draw_confidence_ellipse and (self.visible or forceDraw):
|
||||||
col = (255, 255, 255)
|
col = (255, 255, 255)
|
||||||
f = seconds*self.speed_fac*self.fps*max(self.width, self.height)
|
f = seconds/self.speed_fac
|
||||||
|
|
||||||
while len(chol.shape) > 2:
|
while len(chol.shape) > 2:
|
||||||
chol = chol[0]
|
chol = chol[0]
|
||||||
@ -399,20 +399,21 @@ class ColumbusEnv(gym.Env):
|
|||||||
|
|
||||||
L, V = th.linalg.eig(cov)
|
L, V = th.linalg.eig(cov)
|
||||||
L, V = L.real, V.real
|
L, V = L.real, V.real
|
||||||
# 5.911 is the magic-number to get a 95%-confidence interval
|
w, h = int(abs(L[0].item()*f))+1, int(abs(L[1].item()*f))+1
|
||||||
l1, l2 = int(abs(math.sqrt(L[0].item()*5.911)*f)) + \
|
# In theory we would have to solve:
|
||||||
1, int(abs(math.sqrt(L[1].item()*5.911)*f))+1
|
# R = [[cos, -sin],[sin, cos]]
|
||||||
|
# But we only use the -sin term.
|
||||||
|
# Because of this our calculated angle might be wrong
|
||||||
|
# by periods of 180°
|
||||||
|
# But since an ellipsoid does not change under such an 'error',
|
||||||
|
# we don't care
|
||||||
|
# ang1 = int(math.acos(V[0, 0])/math.pi*360)
|
||||||
|
ang2 = int(math.asin(-V[0, 1])/math.pi*360)
|
||||||
|
# ang3 = int(math.asin(V[1, 0])/math.pi*360)
|
||||||
|
ang = ang2
|
||||||
|
|
||||||
if l1 >= l2:
|
# print(cov)
|
||||||
w, h = l1, l2
|
# print(w, h, (ang1, ang2, ang3))
|
||||||
run, rise = V[0][0], V[0][1]
|
|
||||||
else:
|
|
||||||
w, h = l2, l1
|
|
||||||
run, rise = V[1][0], V[1][1]
|
|
||||||
|
|
||||||
ang = (math.atan(rise/run))/(2*math.pi)*360
|
|
||||||
|
|
||||||
# print(w, h, (run, rise, ang))
|
|
||||||
|
|
||||||
x, y = self.agent.pos
|
x, y = self.agent.pos
|
||||||
x, y = x*self.width, y*self.height
|
x, y = x*self.width, y*self.height
|
||||||
|
Loading…
Reference in New Issue
Block a user