README.md 13.9 KB
Newer Older
Benjamin Beyret's avatar
Benjamin Beyret committed
1
2
# Animal-AI Olympics

Matthew Crosby's avatar
Matthew Crosby committed
3
4
5
6
<p align="center">
  <img height="300" src="documentation/PrefabsPictures/steampunkFOURcrop.png">
</p>

7
8
See [competition launch page](https://mdcrosby.com/blog/animalailaunch.html) and official rules for further details.

Benjamin Beyret's avatar
Benjamin Beyret committed
9
10
## Overview

Benjamin's avatar
Benjamin committed
11
This repo contains **the training environment** (v1.0) that will be used for the competition. Information for entering can be found in the [submission documentation](documentation/submission.md). Please check back during the competition for minor bug-fixes and updates, but as of v1.0 the major features and contents are set in place.
12
13

For more information on the competition itself and to stay updated with any developments, head to the 
14
[Competition Website](http://www.animalaiolympics.com/) and follow [@MacroPhilosophy](https://twitter.com/MacroPhilosophy) and [@BenBeyret](https://twitter.com/BenBeyret) on twitter.
15
16

The environment contains an agent enclosed in a fixed sized arena. Objects can spawn in this arena, including positive 
17
and negative rewards (green, yellow and red spheres) that the agent must obtain (or avoid). All of the hidden tests that will appear in the competition are made using the objects in the training environment. We have provided some sample environment configurations that should be useful for training (see examples/configs), but part of the challenge is to experiment and design new configurations.
Benjamin Beyret's avatar
Benjamin Beyret committed
18
19

To get started install the requirements below, and then follow the [Quick Start Guide](documentation/quickstart.md). 
20
More in depth documentation can be found on the [Documentation Page](documentation/README.md).
Benjamin Beyret's avatar
Benjamin Beyret committed
21

22
23
24
25
## Evaluation

The competition has 300 tests, split over ten categories. The categories range from the very simple (e.g. **food retrieval**, **preferences**, and **basic obstacles**) to the more complex (e.g. **spatial reasoning**, **internal models**, **object permanence**, and **causal reasoning**). We have included example config files for the first seven categories. Note that the example config files are just simple examples to be used as a guide. An agent that solves even all of these perfectly may still not be able to solve all the tests in the category, but it would be off to a good start.

Matthew Crosby's avatar
Matthew Crosby committed
26
27
28
The submission website allows you to submit an agent that will be run on all 300 tests and it returns the overall score (number of tests passed) and score per category. We cannot offer infinite compute, so instances will be timed out after ~90 minutes and only tests performed up to that point counted (all others will be considered failed). See the [submission documentation](documentation/submission.md) for more information. 

For the mid-way and final evaluation we will (resources permitting) run more extensive testing with 3 variations per test (so 900 tests total). The variations will include minor perturbations to the configurations. The agent will have to pass all 3 variations to pass each individual test, giving a total score out of 300. This means that **your final test score might be lower than the score achieved during the competition** and that **the competition leaderboard on EvalAI may not exactly match the final results**. 
29

mdcrosby's avatar
mdcrosby committed
30
31
## Development Blog

32
You can read the launch posts - with information about prizes and the categories in the competition here:
33

34
35
[Animal-AI: AWS Prizes and Evaluation: Aug 12th](https://www.mdcrosby.com/blog/animalaiprizes1.html) - with updated submission and test information.

Matthew Crosby's avatar
Matthew Crosby committed
36
[Animal-AI Evaluation: July 8th](https://mdcrosby.com/blog/animalaieval.html) - with collated information about the evaluation.
37
38

[Animal-AI Launch: July 1st](https://mdcrosby.com/blog/animalailaunch.html) - with information about the prizes and  introduction to all 10 categories.
39

40
41
You can read the development blog [here](https://mdcrosby.com/blog). It covers further details about the competition as 
well as part of the development process.
mdcrosby's avatar
mdcrosby committed
42
43
44
45
46

1. [Why Animal-AI?](https://mdcrosby.com/blog/animalai1.html)

2. [The Syllabus (Part 1)](https://mdcrosby.com/blog/animalai2.html)

47
48
3. [The Syllabus (Part 2): Lights Out](https://mdcrosby.com/blog/animalai3.html)

Benjamin Beyret's avatar
Benjamin Beyret committed
49
50
## Requirements

51
The Animal-AI package works on Linux, Mac and Windows, as well as most Cloud providers. Note that for submission to the competition we only support linux-based Docker files.  
52
<!--, for cloud engines check out [this cloud documentation](documentation/cloud.md).-->
Benjamin Beyret's avatar
Benjamin Beyret committed
53

54
We recommend using a virtual environment specifically for the competition. You will need `python3.6` installed (we currently only support **python3.6**). Clone this repository to run the examples we provide.
Benjamin Beyret's avatar
Benjamin Beyret committed
55

56
57
58
We offer two packages for this competition:

- The main package is an API for interfacing with the Unity environment. It contains both a 
59
60
61
[gym environment](https://github.com/openai/gym) as well as an extension of Unity's 
[ml-agents environments](https://github.com/Unity-Technologies/ml-agents/tree/master/ml-agents-envs). You can install it
 via pip:
62
63
64
65
    ```
    pip install animalai
    ```
    Or you can install it from the source, head to `animalai/` folder and run `pip install -e .`
66

67
    In case you wish to create a conda environment you can do so by running the below command from the `animalai` folder:
Guikarist's avatar
Guikarist committed
68
    ```
69
    conda env create -f conda_isntall.yaml
Guikarist's avatar
Guikarist committed
70
71
    ```

72
- We also provide a package that can be used as a starting point for training, and which is required to run most of the 
Matthew Crosby's avatar
Matthew Crosby committed
73
example scripts found in the `examples/` folder. At the moment **we only support Linux and Max** for the training examples. It contains an extension of 
74
75
76
77
78
[ml-agents' training environment](https://github.com/Unity-Technologies/ml-agents/tree/master/ml-agents) that relies on 
[OpenAI's PPO](https://openai.com/blog/openai-baselines-ppo/), as well as 
[Google's dopamine](https://github.com/google/dopamine) which implements 
[Rainbow](https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/download/17204/16680) (among others). You can also install 
this package using pip:
79
80
81
82
    ```
    pip install animalai-train
    ```
    Or you can install it from source, head to `examples/animalai_train` and run `pip install -e .`
Benjamin Beyret's avatar
Benjamin Beyret committed
83

Benjamin Beyret's avatar
Benjamin Beyret committed
84
Finally download the environment for your system:
Benjamin Beyret's avatar
Benjamin Beyret committed
85
86
87

| OS | Environment link |
| --- | --- |
Benjamin Beyret's avatar
Benjamin Beyret committed
88
89
90
| Linux |  [download v1.0.0](https://www.doc.ic.ac.uk/~bb1010/animalAI/env_linux_v1.0.0.zip) |
| MacOS |  [download v1.0.0](https://www.doc.ic.ac.uk/~bb1010/animalAI/env_mac_v1.0.0.zip) |
| Windows | [download v1.0.0](https://www.doc.ic.ac.uk/~bb1010/animalAI/env_windows_v1.0.0.zip)  |
Benjamin Beyret's avatar
Benjamin Beyret committed
91

92
93
94
You can now unzip the content of the archive to the `env` folder and you're ready to go! Make sure the executable 
`AnimalAI.*` is in `env/`. On linux you may have to make the file executable by running `chmod +x env/AnimalAI.x86_64`. 
Head over to [Quick Start Guide](documentation/quickstart.md) for a quick overview of how the environment works.
Benjamin Beyret's avatar
Benjamin Beyret committed
95

Benjamin Beyret's avatar
Benjamin Beyret committed
96
97
98
99
The Unity source files for the environment can be find on the [AnimalAI-Environment repository](https://github.com/beyretb/AnimalAI-Environment). 
Due to a lack of resources we cannot provide support on this part of the project at the moment. We recommend reading the documentation on the 
[ML-Agents repo](https://github.com/Unity-Technologies/ml-agents) too.

Benjamin Beyret's avatar
Benjamin Beyret committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
## Manual Control

If you launch the environment directly from the executable or through the VisualizeArena script it will launch in player 
mode. Here you can control the agent with the following:

| Keyboard Key  | Action    |
| --- | --- |
| W   | move agent forwards |
| S   | move agent backwards|
| A   | turn agent left     |
| D   | turn agent right    |
| C   | switch camera       |
| R   | reset environment   |

mdcrosby's avatar
mdcrosby committed
114
## Citing
115
If you use the Animal-AI environment in your work you can cite the environment paper:
mdcrosby's avatar
mdcrosby committed
116

117
118
119
120
121
122
123
124
125
126
Beyret, B., Hernández-Orallo, J., Cheke, L., Halina, M., Shanahan, M., Crosby, M. [The Animal-AI Environment: Training and Testing Animal-Like Artificial Cognition](https://arxiv.org/abs/1909.07483), arXiv preprint

```
@inproceedings{Beyret2019TheAE,
  title={The Animal-AI Environment: Training and Testing Animal-Like Artificial Cognition},
  author={Benjamin Beyret and Jos'e Hern'andez-Orallo and Lucy Cheke and Marta Halina and Murray Shanahan and Matthew Crosby},
  year={2019}
}
```

127
Paper with all the details of the test battery will be released after the competition has finished.
128

Benjamin Beyret's avatar
Benjamin Beyret committed
129
130
131
132
133
## Unity ML-Agents

The Animal-AI Olympics was built using [Unity's ML-Agents Toolkit.](https://github.com/Unity-Technologies/ml-agents)

The Python library located in [animalai](animalai) is almost identical to 
134
135
136
[ml-agents v0.7](https://github.com/Unity-Technologies/ml-agents/tree/master/ml-agents-envs). We only added the 
possibility to change the configuration of arenas between episodes. The documentation for ML-Agents can be found 
[here](https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Python-API.md).
Benjamin Beyret's avatar
Benjamin Beyret committed
137

138
139
Juliani, A., Berges, V., Vckay, E., Gao, Y., Henry, H., Mattar, M., Lange, D. (2018). [Unity: A General Platform for 
Intelligent Agents.](https://arxiv.org/abs/1809.02627) *arXiv preprint arXiv:1809.02627*
Benjamin Beyret's avatar
Benjamin Beyret committed
140

141
142
## EvalAI

Benjamin Beyret's avatar
Benjamin Beyret committed
143
The competition is kindly hosted on [EvalAI](https://github.com/Cloud-CV/EvalAI), an open source web application for AI competitions. Special thanks to [Rishabh Jain](https://rishabhjain.xyz/) for his help in settting this up.
144
145
146

Deshraj Yadav, Rishabh Jain, Harsh Agrawal, Prithvijit Chattopadhyay, Taranjeet Singh, Akash Jain, Shiv Baran Singh, Stefan Lee and Dhruv Batra (2019) [EvalAI: Towards Better Evaluation Systems for AI Agents](https://arxiv.org/abs/1902.03570)

147
## Known Issues
148

149
In play mode pressing `R` or `C` does nothing sometimes. This is due to the fact that we have synchronized these 
150
features with the agent's frames in order to have frames in line with the configuration files for elements such as blackouts. **Solution**: press the key again, several times if needed.
151
152
153

## TODO

Benjamin Beyret's avatar
Benjamin Beyret committed
154
- [x] Add custom resolutions
Benjamin Beyret's avatar
Benjamin Beyret committed
155
- [x] Add inference viewer to the environment
156
- [x] Offer a gym wrapper for training
Benjamin Beyret's avatar
Benjamin Beyret committed
157
- [x] Improve the way the agent spawns
Benjamin Beyret's avatar
Benjamin Beyret committed
158
- [x] Add lights out configurations.
mdcrosby's avatar
mdcrosby committed
159
160
- [x] Improve environment framerates
- [x] Add moving food
mdcrosby's avatar
mdcrosby committed
161

Benjamin Beyret's avatar
Benjamin Beyret committed
162
## Version History
Benjamin Beyret's avatar
Benjamin Beyret committed
163

Benjamin Beyret's avatar
Benjamin Beyret committed
164
165
166
- v1.1.1
    - Hotfix curriculum loading in the wrong order
    
Benjamin Beyret's avatar
Benjamin Beyret committed
167
- v1.1.0
168
169
    - Add curriculum learning to `animalai-train` to use yaml configurations

Benjamin Beyret's avatar
Benjamin Beyret committed
170
- v1.0.5
171
    - ~~Adds customisable resolution during evaluation~~ (removed, evaluation is only `84x84`)
Benjamin Beyret's avatar
Benjamin Beyret committed
172
173
    - Update `animalai-train` to tf 1.14 to fix `gin` broken dependency
    - Release source code for the environment (no support to be provided on this for now)
Benjamin Beyret's avatar
Benjamin Beyret committed
174
175
    - Fixes some legacy dependencies and typos in both libraries
    
Benjamin Beyret's avatar
Benjamin Beyret committed
176
177
- v1.0.3
    - Adds inference mode to Gym environment
178
    - Adds seed to Gym Environment
179
180
181
    - Submission example folder containing a trained agent
    - Provide submission details for the competition
    - Documentation for training on AWS
Benjamin Beyret's avatar
Benjamin Beyret committed
182

183
184
- v1.0.2
    - Adds custom resolution for docker training as well
185
    - Fix version checker
186
187

- v1.0.0
Benjamin Beyret's avatar
Benjamin Beyret committed
188
    - Adds custom resolution to both Unity and Gym environments
Benjamin Beyret's avatar
Benjamin Beyret committed
189
    - Adds inference mode to the environment to visualize trained agents
Benjamin Beyret's avatar
Benjamin Beyret committed
190
191
    - Prizes announced
    - More details about the competition
192
193
194
195
196

- v0.6.1 (Environment only) 
    - Fix rare events of agent falling through the floor or objects flying in the air when resetting an arena

- v0.6.0 
197
    - Adds score in playmode (current and previous scores)
Benjamin Beyret's avatar
Benjamin Beyret committed
198
    - Playmode now incorporates lights off directly (in `examples` try: `python visualizeArena.py configs/lightsOff.yaml`)
199
200
201
    - To simplify the environment several unnecessary objects have been removed [see here](documentation/definitionsOfObjects.md)
    - **Several object properties have been changed** [also here](documentation/definitionsOfObjects.md)
    - Frames per action reduced from 5 to 3 (*i.e.*: for each action you send we repeat it for a certain number of frames 
Benjamin Beyret's avatar
Benjamin Beyret committed
202
203
204
    to ensure smooth physics)
    - Add versions compatibility check between the environment and API
    - Remove `step_number` argument from `animalai.environment.step`
Benjamin Beyret's avatar
Benjamin Beyret committed
205

Benjamin's avatar
Benjamin committed
206
- v0.5 Package `animalai`, gym compatible, dopamine example, bug fixes
207
208
209
210
211
212
213
214
    - Separate environment API and training API in Python
    - Release both as `animalai` and `animalai-train` PyPI packages (for `pip` installs)
    - Agent speed in play-mode constant across various platforms
    - Provide Gym environment
    - Add `trainBaselines,py` to train using `dopamine` and the Gym wrapper
    - Create the `agent.py` interface for agents submission
    - Add the `HotZone` object (equivalent to the red zone but without death)

Benjamin Beyret's avatar
Benjamin Beyret committed
215
216
217
- v0.4 - Lights off moved to Unity, colors configurations, proportional goals, bugs fixes
    - The light is now directly switched on/off within Unity, configuration files stay the same
    - Blackouts now work with infinite episodes (`t=0`)
218
219
220
221
    - The `rand_colors` configurations have been removed and the user can now pass `RGB` values, see 
    [here](documentation/configFile.md#objects)
    - Rewards for goals are now proportional to their size (except for the `DeathZone`), see 
    [here](documentation/definitionsOfObjects.md#rewards)
Benjamin Beyret's avatar
Benjamin Beyret committed
222
    - The agent is now a ball rather than a cube
Benjamin Beyret's avatar
Benjamin Beyret committed
223
    - Increased safety for spawning the agent to avoid infinite loops
Benjamin Beyret's avatar
Benjamin Beyret committed
224
225
    - Bugs fixes
    
Benjamin Beyret's avatar
Benjamin Beyret committed
226
- v0.3 - Lights off, remove Beams and add cylinder
227
228
    - We added the possibility to switch the lights off at given intervals, see 
    [here](documentation/configFile.md#blackouts)
Benjamin Beyret's avatar
Benjamin Beyret committed
229
    - visualizeLightsOff.py displays an example of lights off, from the agent's point of view
Benjamin Beyret's avatar
Benjamin Beyret committed
230
231
    - Beams objects have been removed
    - A `Cylinder` object has been added (similar behaviour to the `Woodlog`)
Benjamin Beyret's avatar
Benjamin Beyret committed
232
    - The immovable `Cylinder` tunnel has been renamed `CylinderTunnel`
Benjamin Beyret's avatar
Benjamin Beyret committed
233
    - `UnityEnvironment.reset()` parameter `config` renamed to `arenas_configurations_input`
Benjamin Beyret's avatar
Benjamin Beyret committed
234
    
mdcrosby's avatar
mdcrosby committed
235
236
- v0.2 - New moving food rewards, improved Unity performance and bug fixes 
    - Moving rewards have been added, two for each type of reward, see 
Benjamin Beyret's avatar
Benjamin Beyret committed
237
    [the details here](documentation/definitionsOfObjects.md#rewards).
mdcrosby's avatar
mdcrosby committed
238
239
240
    - Added details for the maze generator.
    - Environment performance improved.
    - [Issue #7](../../issues/7) (`-inf` rewards for `t: 0` configuration) is fixed.
Benjamin Beyret's avatar
Benjamin Beyret committed
241
242

- v0.1 - Initial Release
Benjamin Beyret's avatar
Benjamin Beyret committed
243