Clean up; do the terminal states

This commit is contained in:
Nicolai Czempin 2017-04-01 01:54:06 +02:00
parent a1198af230
commit c96cb1e48e

View File

@ -8,14 +8,24 @@ class RandomWalkEnv(gym.Env):
def __init__(self): def __init__(self):
self.action_space = spaces.Discrete(2) self.action_space = spaces.Discrete(2)
print("init") #print("init")
def _step(self, action): def _step(self, action):
print("step") #print("step")
reward = 0 reward = 0
done = False done = False
if (action == 0):
self.state -= 1
if (action == 1):
self.state += 1
if (self.state >= 6):
reward = 1
done = True
if (self.state <= 0):
done = True
return np.array(self.state), reward, done, {} return np.array(self.state), reward, done, {}
def _reset(self): def _reset(self):
print("reset") #print("reset")
self.state = 0 # TODO start in a random position self.state = 1 # TODO start in a random position
def _render(self, mode='human', close=False): def _render(self, mode='human', close=False):
print("render") #print("render")
print(self.state)