Making strating_pos configurable

This commit is contained in:
Dominik Moritz Roth 2022-06-19 15:48:51 +02:00
parent 12cac4db99
commit daf8ec2c4d
4 changed files with 17 additions and 1 deletions

View File

@ -72,7 +72,7 @@ class Enemy(Entity):
def __init__(self, env): def __init__(self, env):
super(Enemy, self).__init__(env) super(Enemy, self).__init__(env)
self.col = (255, 0, 0) self.col = (255, 0, 0)
self.damage = 10 self.damage = 100
def on_collision(self, other): def on_collision(self, other):
if isinstance(other, Agent): if isinstance(other, Agent):

2
env.py
View File

@ -26,6 +26,7 @@ class ColumbusEnv(gym.Env):
self.screen = None self.screen = None
self.width = 720 self.width = 720
self.height = 720 self.height = 720
self.start_pos = (0.5, 0.5)
self.speed_fac = 0.01/fps*60 self.speed_fac = 0.01/fps*60
self.acc_fac = 0.03/fps*60 self.acc_fac = 0.03/fps*60
self.agent_drag = 0 # 0.01 is a good value self.agent_drag = 0 # 0.01 is a good value
@ -139,6 +140,7 @@ class ColumbusEnv(gym.Env):
self.entities = newEntities self.entities = newEntities
def setup(self): def setup(self):
self.agent.pos = self.start_pos
for i in range(18): for i in range(18):
enemy = entities.CircleBarrier(self) enemy = entities.CircleBarrier(self)
enemy.radius = self.random()*40+50 enemy.radius = self.random()*40+50

13
gym_binding.py Normal file
View File

@ -0,0 +1,13 @@
from gym.envs.registration import register
from env import *
def register():
register(
# unique identifier for the env `name-version`
id="Columbus-Test317-v0",
# path to the class for creating the env
# Note: entry_point also accept a class as input (and not only a string)
entry_point=env.ColumbusEnv,
# Max number of steps per episode, using a `TimeLimitWrapper`
max_episode_steps=500,
)

View File

@ -8,6 +8,7 @@ from observables import Observable, CnnObservable
def main(): def main():
env = ColumbusEnv(fps=60, observable=CnnObservable()) env = ColumbusEnv(fps=60, observable=CnnObservable())
env.start_pos = [0.6, 0.3]
playEnv(env) playEnv(env)
env.close() env.close()