Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 269551668
  • Loading branch information
qstanczyk committed Sep 17, 2019
1 parent 72827dd commit 71180d3
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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.5
- Fix to numerical issue resulting in asserts in long runs (https://github.com/google-research/football/issues/78).
- Eliminate dependense on Glee (https://github.com/google-research/football/issues/77)
- Created [email protected] email for direct contact with the environment team.

v1.4
- Added implementation of architecture 'gfootball_impala_cnn' used in the paper.
- Added possibility of loading PPO checkpoints as players, added example checkpoints (for levels 11_vs_11_easy_stochastic and academy_run_to_score_with_keeper).
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ RUN apt-get update && apt-get install -yq git cmake build-essential \
libgl1-mesa-dev libsdl2-dev \
libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev libboost-all-dev \
libdirectfb-dev libst-dev mesa-utils xvfb x11vnc \
glee-dev libsdl-sge-dev python3-pip
libsdl-sge-dev python3-pip

RUN pip3 install "tensorflow<2.0" dm-sonnet

COPY . /gfootball
RUN cd /gfootball && pip3 install .[tf_$DEVICE]
RUN cd /gfootball && pip3 install .
RUN pip3 install git+https://github.com/openai/baselines.git@master
WORKDIR '/gfootball'
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ We'd like to thank Bastiaan Konings Schuiling, who authored and open-sourced the
For more information, please look at our [paper](https://arxiv.org/abs/1907.11180).

Mailing list: https://groups.google.com/forum/#!forum/google-research-football
Comments / suggestions / feature ideas are welcome on this list, and please
use it to communicate with us (in addition to GitHub issues).

For non-public matters that you'd like to discuss directly with the Google Research Football team,
please use [email protected].

## Installation
Currently we're supporting only Linux and Python3.
Expand All @@ -18,7 +23,7 @@ You can either install the code from github (newest version) or from pypi (stabl
1. Install required apt packages with
`sudo apt-get install git cmake build-essential libgl1-mesa-dev libsdl2-dev
libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev libboost-all-dev
libdirectfb-dev libst-dev mesa-utils xvfb x11vnc glee-dev libsdl-sge-dev
libdirectfb-dev libst-dev mesa-utils xvfb x11vnc libsdl-sge-dev
python3-pip`

1. Install gfootball python package from pypi:
Expand Down
2 changes: 2 additions & 0 deletions gfootball/env/football_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def __init__(self, config):
# team and the index on the team to generate observations appropriately.
self._agent = None
self._agent_index = -1
self._agent_left_position = -1
self._agent_right_position = -1
self._players = self._construct_players(config['players'], player_config)
self._env = football_env_wrapper.FootballEnvWrapper(self._config)
self._num_actions = len(football_action_set.get_action_set(self._config))
Expand Down
4 changes: 0 additions & 4 deletions gfootball/env/football_env_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ def step(self, action):
if 'frame' in self._observation:
self._trace.add_frame(self._observation['frame'])
debug['frame_cnt'] = self._step
if self._step == 1:
# Put environment config into the debug, so that we can replay a given
# scenario from the dump.
debug['config'] = self._config.get_dictionary()

previous_score_diff = 0
if self._trace.len() > 0:
Expand Down
12 changes: 6 additions & 6 deletions gfootball/env/observation_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def softmax(x):


@cfg.log
def write_dump(name, trace, skip_visuals=False, config={}):
if not skip_visuals:
def write_dump(name, trace, config):
if config['write_video']:
fd, temp_path = tempfile.mkstemp(suffix='.avi')
if HIGH_RES:
frame_dim = (1280, 720)
Expand Down Expand Up @@ -212,6 +212,7 @@ def write_dump(name, trace, skip_visuals=False, config={}):
# For some reason sometimes the file is missing, so the code fails.
if WRITE_FILES:
shutil.copy2(temp_path, name + '.avi')
logging.info('Video written to %s.avi', name)
os.remove(temp_path)
except:
logging.info(traceback.format_exc())
Expand All @@ -222,15 +223,15 @@ def write_dump(name, trace, skip_visuals=False, config={}):
temp_frames.append(o._trace['observation']['frame'])
o._trace['observation']['frame'] = REMOVED_FRAME
to_pickle.append(o._trace)
# Add config to the first frame for our replay tools to use.
to_pickle[0]['debug']['config'] = config.get_dictionary()
if WRITE_FILES:
with open(name + '.dump', 'wb') as f:
six.moves.cPickle.dump(to_pickle, f)
for o in trace:
if 'frame' in o._trace['observation']:
o._trace['observation']['frame'] = temp_frames.pop(0)
logging.info('Dump written to %s.dump', name)
if not skip_visuals:
logging.info('Video written to %s.avi', name)
return True


Expand Down Expand Up @@ -379,8 +380,7 @@ def process_pending_dumps(self, finish):
if finish or config._trigger_step <= self._frame:
logging.info('Start dump %s', name)
trace = list(self._trace)[-config._max_length:]
write_dump(config._file_name, trace, self._config['write_video'],
self._config)
write_dump(config._file_name, trace, self._config)
config._file_name = None
if config._result:
assert not config._file_name
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.4',
version='1.5',
description=('Google Research Football - RL environment based on '
'open-source game Gameplay Football'),
author='Google LLC',
Expand Down
4 changes: 2 additions & 2 deletions third_party/gfootball_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ add_library(gamelib ${GAME_SOURCES} ${GAME_HEADERS})
add_library(menulib ${MENU_SOURCES} ${MENU_HEADERS})
add_library(datalib ${DATA_SOURCES} ${DATA_HEADERS})

set(LIBRARIES gamelib menulib datalib glee
blunted2 rt ${Boost_LIBRARIES} ${PYTHON_LIBRARY}
set(LIBRARIES gamelib menulib datalib blunted2 rt
${Boost_LIBRARIES} ${PYTHON_LIBRARY}
${SDL2_IMAGE_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2_GFX_LIBRARIES}
${SDL2_LIBRARY} ${SGE_LIBRARY} ${OPENGL_LIBRARIES})
add_library(baselib OBJECT ${BASE_SOURCES} ${BASE_HEADERS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Vector3 GetBallControlVector(Ball *ball, Player *player, const Vector3 &nextStar
if (currentAnim->originatingCommand.desiredVelocityFloat > walkSprintSwitch) maximumOverdrive_mps = 2.0f * explosivenessFactor;
float dotFactor1 = spatialState.directionVec.GetDotProduct(currentAnim->originatingCommand.desiredDirection) * 0.5f + 0.5f; // inv deviation from the current direction
float dotFactor2 = Vector3(0, -1, 0).GetRotated2D(nextStartAngle).GetDotProduct(currentAnim->originatingCommand.desiredDirection) * 0.5f + 0.5f; // inv deviation from the direction we wanted
float dotFactor = std::min(dotFactor1, dotFactor2);
float dotFactor = clamp(std::min(dotFactor1, dotFactor2), 0.0f, 1.0f); // clamp for numerical problems, don't want negative values out of this.
maximumOverdrive_mps *= dotFactor;

if (FloatToEnumVelocity(currentAnim->anim->GetOutgoingVelocity()) == e_Velocity_Idle) maximumOverdrive_mps = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#include "interface_renderer3d.hpp"

#include <GLee.h>

namespace blunted {

class OpenGLRenderer3D : public Renderer3D {
Expand Down Expand Up @@ -145,9 +143,9 @@ namespace blunted {

float overallBrightness = 0.0f;

GLfloat largest_supported_anisotropy = 0.0f;
float largest_supported_anisotropy = 0.0f;

std::map<std::string, GLint> uniformCache;
std::map<std::string, int> uniformCache;

std::map<int, int> VBOPingPongMap;
std::map<int, int> VAOPingPongMap;
Expand Down

0 comments on commit 71180d3

Please sign in to comment.