Skip to content

Commit

Permalink
add environment screen maxing for avoid glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
carpedm20 committed Jun 20, 2016
1 parent e2ff644 commit 15dbba9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dqn/environment.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ def __init__(self, config):
self.display = config.display
self.dims = (screen_width, screen_height)

self._previous_screen = None
self._screen = None
self.reward = 0
self.terminal = True
@@ -40,6 +41,14 @@ def _random_step(self):

@ property
def screen(self):
if not self.terminal and self._previous_screen is not None:
_previous_screen = self._screen
self._screen = np.maximum(self._screen, self._previous_screen)
self._previous_screen = _previous_screen

if self.previous_screen is None:
self.previous_screen = self._screen

return cv2.resize(cv2.cvtColor(self._screen, cv2.COLOR_RGB2GRAY)/255., self.dims)
#return cv2.resize(cv2.cvtColor(self._screen, cv2.COLOR_BGR2YCR_CB)/255., self.dims)[:,:,0]

@@ -75,7 +84,7 @@ def act(self, action, is_training=True):
cumulated_reward = cumulated_reward + self.reward

if is_training and start_lives > self.lives:
cumulated_reward -= 1
cumulated_reward += -1
self.terminal = True

if self.terminal:

0 comments on commit 15dbba9

Please sign in to comment.