Making the repo somewhat understandable to other readers...

This commit is contained in:
2022-09-16 11:38:21 +02:00
parent 5cedffa473
commit d2c2343d08
4 changed files with 85 additions and 4 deletions
+6 -2
View File
@@ -309,9 +309,13 @@ class ColumbusEnv(gym.Env):
L, V = th.linalg.eig(cov)
L, V = L.real, V.real
w, h = int(abs(L[0].item()*f))+1, int(abs(L[1].item()*f))+1
# TODO: Is this correct? We try to solve for teh angle from this:
# In theory we would ahve to solve:
# R = [[cos, -sin],[sin, cos]]
# Via only the -sin term.
# 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)
+7
View File
@@ -29,6 +29,7 @@ class Observable():
class CnnObservable(Observable):
# Currently broken...
def __init__(self, in_width=256, in_height=256, out_width=32, out_height=32, draw_width=128, draw_height=128, smooth_scaling=True):
super(CnnObservable, self).__init__()
self.in_width = in_width
@@ -195,6 +196,7 @@ class RayObservable(Observable):
class StateObservable(Observable):
# Whitelists probably don't work...
def __init__(self, coordsAgent=False, speedAgent=False, coordsRelativeToAgent=True, coordsRewards=True, rewardsWhitelist=None, coordsEnemys=True, enemysWhitelist=None, enemysNoBarriers=True, rewardsTimeouts=True, include_rand=True):
super(StateObservable, self).__init__()
self._entities = None
@@ -287,6 +289,9 @@ class StateObservable(Observable):
class CompassObservable(Observable):
# Usefull for navigation close to an reward.
# Works like the StateObservable, but we assign a bigger range of possible input values to those, that are close to zero.
# I found that Agents without such an Observable often moved close to a reward and then just jiggled arround, adding a CompassObservable fixes this
def __init__(self, coordsRewards=True, rewardsWhitelist=None, coordsEnemys=False, enemysWhitelist=None, enemysNoBarriers=True):
super().__init__()
self._entities = None
@@ -355,6 +360,8 @@ class CompassObservable(Observable):
class CompositionalObservable(Observable):
# Used whenever you want to attach multiple Observables to an Env.
# We currently flatten the outputs of all attached Observables, so using a CNN though an CompositionalObservable would lead to problems.
def __init__(self, observables):
super().__init__()
self.observables = observables