Skip to content

Commit 70638d8

Browse files
committed
Project import generated by Copybara.
PiperOrigin-RevId: 262097325
1 parent 325516e commit 70638d8

4 files changed

Lines changed: 25 additions & 12 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ should not change, as modifications made to the environment are either
55
new features or backward compatible bug fixes. We will maintain vX branches
66
pointing at the most recent vX.Y.
77

8+
v1.3
9+
- Fix to pixel representation (https://github.com/google-research/football/issues/54,56,57).
10+
811
v1.2
912
- Reduction of memory usage by the environment (https://github.com/google-research/football/issues/47).
1013
- Reduction of memory usage during compilation (https://github.com/google-research/football/issues/49).

gfootball/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@
3838
'representation': 'pixels'
3939
},
4040
)
41+
42+
register(
43+
id='GFootball-{env_name}-simple115-v0'.format(env_name=env_name),
44+
entry_point='gfootball.env:create_environment',
45+
kwargs={
46+
'env_name': env_name,
47+
'representation': 'simple115'
48+
},
49+
)

gfootball/env/wrappers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def __init__(self, env, grayscale=True,
123123
gym.ObservationWrapper.__init__(self, env)
124124
self._grayscale = grayscale
125125
self._channel_dimensions = channel_dimensions
126-
self._i=0
127126
self.observation_space = gym.spaces.Box(
128127
low=0, high=255,
129128
shape=(self.env.unwrapped._config.number_of_players_agent_controls(),
@@ -132,16 +131,18 @@ def __init__(self, env, grayscale=True,
132131
dtype=np.uint8)
133132

134133
def observation(self, obs):
135-
frame = obs['frame']
136-
if self._grayscale:
137-
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
138-
frame = cv2.resize(frame, (self._channel_dimensions[0],
139-
self._channel_dimensions[1]),
140-
interpolation=cv2.INTER_AREA)
141-
if self._grayscale:
142-
frame = np.expand_dims(frame, -1)
143-
return ([frame] *
144-
self.env.unwrapped._config.number_of_players_agent_controls())
134+
o = []
135+
for observation in obs:
136+
frame = observation['frame']
137+
if self._grayscale:
138+
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
139+
frame = cv2.resize(frame, (self._channel_dimensions[0],
140+
self._channel_dimensions[1]),
141+
interpolation=cv2.INTER_AREA)
142+
if self._grayscale:
143+
frame = np.expand_dims(frame, -1)
144+
o.append(frame)
145+
return np.array(o, dtype=np.uint8)
145146

146147

147148
class SMMWrapper(gym.ObservationWrapper):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run(self):
4141

4242
setup(
4343
name='gfootball',
44-
version='1.2',
44+
version='1.3',
4545
description=('Google Research Football - RL environment based on '
4646
'open-source game Gameplay Football'),
4747
author='Google LLC',

0 commit comments

Comments
 (0)