Skip to content

Commit

Permalink
Not returning RGB data for Tiles env - To speed up gameplay
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaquette committed Nov 23, 2016
1 parent a9be7b0 commit 350c2e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ppaquette_gym_super_mario/lua/super-mario-bros.lua
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ end;
-- Palette is a number from 0 to 127 that represents an RGB color (conversion table in python file)
function get_screen()

-- Skipping screen is skip_screen is set
if skip_screen == 1 then
-- Skipping screen is skip_screen is set or draw_tiles if set
if (skip_screen == 1) or (draw_tiles == 1) then
return;
end;

Expand Down
6 changes: 6 additions & 0 deletions ppaquette_gym_super_mario/super_mario_bros.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def __init__(self, draw_tiles=False, level=0):
if 1 == self.draw_tiles:
self.tile_height = 13
self.tile_width = 16
self.screen_height = 13
self.screen_width = 16
self.tiles = np.zeros(shape=(self.tile_height, self.tile_width), dtype=np.uint8)
self.observation_space = spaces.Box(low=0, high=3, shape=(self.tile_height, self.tile_width))

Expand Down Expand Up @@ -134,6 +136,10 @@ def _process_tiles_message(self, frame_number, data):
y = int(part[1:2], 16)
v = int(part[2:3], 16)
self.tiles[y][x] = v
if v == 0: self.screen[y][x] = self._get_rgb_from_palette('0D')
if v == 1: self.screen[y][x] = self._get_rgb_from_palette('30')
if v == 2: self.screen[y][x] = self._get_rgb_from_palette('27')
if v == 3: self.screen[y][x] = self._get_rgb_from_palette('05')

def _process_ready_message(self, frame_number):
# Format: ready_<frame>
Expand Down

0 comments on commit 350c2e1

Please sign in to comment.