Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 288868157
  • Loading branch information
qstanczyk committed Jan 9, 2020
1 parent 52cfcab commit a3652fb
Show file tree
Hide file tree
Showing 14 changed files with 778 additions and 49 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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.

v2.0.4
- Added Colab support (see readme file).
- Some minor bug fixes (including https://github.com/google-research/football/issues/110)

v2.0 - this release is not backward-compatible due to making game fully symmetric (training agents can behave differently).
- Game is fully symmetric now (playing left to right and right to left is equivalent). All observations are modified inside of the
environment and from agent's perspective the game is always presented as playing from left to right (no need to train from both
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Football. <br> It was created by the Google Brain team for research purposes.

Useful links:
* __(NEW!)__ [GRF Game Server](https://research-football.dev/) - challenge other researchers!
* __(NEW!)__ [Run in Colab](https://colab.research.google.com/github/google-research/football/blob/master/colabs/gfootball_example_from_prebuild.ipynb) - start training in less that 2 minutes.
* [Google Research Football Paper](https://arxiv.org/abs/1907.11180)
* [GoogleAI blog post](https://ai.googleblog.com/2019/06/introducing-google-research-football.html)
* [Google Research Football on Cloud](https://towardsdatascience.com/reproducing-google-research-football-rl-results-ac75cf17190e)
Expand All @@ -18,6 +19,15 @@ We'd like to thank Bastiaan Konings Schuiling, who authored and open-sourced the


## Quick Start

### In colab

Open our example [Colab](https://colab.research.google.com/github/google-research/football/blob/master/colabs/gfootball_example_from_prebuild.ipynb), that will allow you to start training your model in less than 2 minutes.

This method doesn't support game rendering on screen - if you want to see the game running, please use the method below.

### On your computer

Install required apt packages with:

```
Expand Down Expand Up @@ -58,8 +68,9 @@ python3 -m gfootball.play_game --action_set=full
### Run training
In order to run TF training, install additional dependencies:

- TensorFlow: `pip3 install "tensorflow<2.0"` or
`pip3 install "tensorflow-gpu<2.0"`, depending on whether you want CPU or
- Update PIP, so that tensorflow 1.15rc2 is available: `python3 -m pip install --upgrade pip`
- TensorFlow: `pip3 install "tensorflow==1.15rc2"` or
`pip3 install "tensorflow-gpu==1.15rc2"`, depending on whether you want CPU or
GPU version;
- Sonnet: `pip3 install dm-sonnet`;
- OpenAI Baselines:
Expand Down
108 changes: 108 additions & 0 deletions gfootball/colabs/gfootball_example_from_prebuild.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "gfootball_example_from_prebuild.ipynb",
"provenance": [],
"collapsed_sections": [],
"toc_visible": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/google-research/football/blob/master/colabs/gfootball_example_from_prebuild.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "iCWQ9yUT3W61",
"colab_type": "text"
},
"source": [
"# Setup (should take < 100 seconds)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "kB9McZ4THuor",
"colab_type": "code",
"colab": {}
},
"source": [
"!apt-get update\n",
"!apt-get install libsdl2-gfx-dev libsdl2-ttf-dev\n",
"\n",
"# Make sure that the Branch in git clone and in wget call matches !!\n",
"!git clone -b v2.0 https://github.com/google-research/football.git\n",
"!mkdir -p football/third_party/gfootball_engine/lib\n",
"\n",
"!wget https://storage.googleapis.com/gfootball/prebuilt_gameplayfootball_v2.0.so -O football/third_party/gfootball_engine/lib/prebuilt_gameplayfootball.so\n",
"!cd football && GFOOTBALL_USE_PREBUILT_SO=1 pip3 install ."
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "GGCu8kbl21Rx",
"colab_type": "text"
},
"source": [
"# Now, you can run it:"
]
},
{
"cell_type": "code",
"metadata": {
"id": "vLg01fIo2lpV",
"colab_type": "code",
"outputId": "13dcac37-3f59-4f1e-f430-fed46f965ff5",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
}
},
"source": [
"import gfootball.env as football_env\n",
"env = football_env.create_environment(env_name=\"academy_empty_goal_close\", stacked=False, logdir='/tmp/football', write_goal_dumps=False, write_full_episode_dumps=False, render=False)\n",
"env.reset()\n",
"steps = 0\n",
"while True:\n",
" obs, rew, done, info = env.step(env.action_space.sample())\n",
" steps += 1\n",
" if steps % 100 == 0:\n",
" print(\"Step %d Reward: %f\" % (steps, rew))\n",
" if done:\n",
" break\n",
"\n",
"print(\"Steps: %d Reward: %.2f\" % (steps, rew))"
],
"execution_count": 16,
"outputs": [
{
"output_type": "stream",
"text": [
"Step 100 Reward: 0.000000\n",
"Step 200 Reward: 0.000000\n",
"Steps: 202 Reward: 0.00\n"
],
"name": "stdout"
}
]
}
]
}
Loading

0 comments on commit a3652fb

Please sign in to comment.