Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 262097325
  • Loading branch information
qstanczyk committed Aug 7, 2019
1 parent 325516e commit 70638d8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ should not change, as modifications made to the environment are either
new features or backward compatible bug fixes. We will maintain vX branches
pointing at the most recent vX.Y.

v1.3
- Fix to pixel representation (https://github.com/google-research/football/issues/54,56,57).

v1.2
- Reduction of memory usage by the environment (https://github.com/google-research/football/issues/47).
- Reduction of memory usage during compilation (https://github.com/google-research/football/issues/49).
Expand Down
9 changes: 9 additions & 0 deletions gfootball/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@
'representation': 'pixels'
},
)

register(
id='GFootball-{env_name}-simple115-v0'.format(env_name=env_name),
entry_point='gfootball.env:create_environment',
kwargs={
'env_name': env_name,
'representation': 'simple115'
},
)
23 changes: 12 additions & 11 deletions gfootball/env/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def __init__(self, env, grayscale=True,
gym.ObservationWrapper.__init__(self, env)
self._grayscale = grayscale
self._channel_dimensions = channel_dimensions
self._i=0
self.observation_space = gym.spaces.Box(
low=0, high=255,
shape=(self.env.unwrapped._config.number_of_players_agent_controls(),
Expand All @@ -132,16 +131,18 @@ def __init__(self, env, grayscale=True,
dtype=np.uint8)

def observation(self, obs):
frame = obs['frame']
if self._grayscale:
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
frame = cv2.resize(frame, (self._channel_dimensions[0],
self._channel_dimensions[1]),
interpolation=cv2.INTER_AREA)
if self._grayscale:
frame = np.expand_dims(frame, -1)
return ([frame] *
self.env.unwrapped._config.number_of_players_agent_controls())
o = []
for observation in obs:
frame = observation['frame']
if self._grayscale:
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
frame = cv2.resize(frame, (self._channel_dimensions[0],
self._channel_dimensions[1]),
interpolation=cv2.INTER_AREA)
if self._grayscale:
frame = np.expand_dims(frame, -1)
o.append(frame)
return np.array(o, dtype=np.uint8)


class SMMWrapper(gym.ObservationWrapper):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def run(self):

setup(
name='gfootball',
version='1.2',
version='1.3',
description=('Google Research Football - RL environment based on '
'open-source game Gameplay Football'),
author='Google LLC',
Expand Down

0 comments on commit 70638d8

Please sign in to comment.