- Requirements
- Run the Agent
- Level Generation
- Novel Levels Loading
- Outline of the Provided Files
- Outline of the Agent Code
- Ground Truth Data Structure
- Agent-Game Communication Protocols
- Docker
This system has been tested on
- Ubuntu 18.04
- MacOS 10.9 and 10.12
- Windows 10
The framework has been tested with the Java 12 and above.
Java Environment can be downloaded from this link.
- python version>=3.6
- numpy
- shapely
- open cv
- tensorflow
- install the dependencies
pip3 install -r requirements.txt
Pre-compiled Science Birds for different platforms are in folder:
ScienceBirds
These files are tracked with Git Large File System.
- Run the game playing interface
- Unzip the game that suits your OS in
./ScienceBirdsfolder - Navigate to the unzipped game folder.
- use the code below to run:
- Unzip the game that suits your OS in
java -jar game_playing_interface.jar
Arguments:
-
--headless: to run the software in headless mode (headless mode does not work on Windows now due to a potential bug in Unity)
-
--trials-per-agent [number of trials per agent]: the number of trials per agent, default
-
--trial-start-index [trial index]: the start trial index for the first agent, default 0
- NOTE: this argument is only valid if --trials-per-agent is used and the its value is greater than zero
- otherwise all agents will start at trial 0 and play through all trials
-
--agent-name [agent name]: the agent to be run in this GPI
-
--config-path [path to config.xml]: the path to the config.xml, default the same directory as game_playing_interface.jar
-
--game-start-port [start port of SB]: the port of the first SB instance, it will increase by 1 afterwards. Default 9001
-
--agent-port [port for the agent to connect]: the port that the game playing interface opens for agent connection. Default 2004
-
--informed-only: only run agents on the trials trials that inform the novelty appearance
-
--uninformed-only: only run agents on the trials trials that do not inform the novelty appearance
-
--generate-config: generate a new config.xml for each agent in the current run. The configMeta.xml should be placed in
- Linux
ScienceBirds_Linux/ScienceBirds_Linux_Data/StreamingAssets/- MacOS
ab.app/Contents/Resources/Data/StreamingAssets/- Windows
ScienceBirds_Win/Science Birds_Data/StreamingAssets/ -
--dev: run the game playing interface to access more information about the game objects
- in dev mode, the type of the object in the ground truth is the true object type
- in dev mode, agent command groundtruthwithscreenshot and groundtruthwithoutscreenshot will return non-noisy groundtruth
- in dev mode, agent command ShootAndRecordGroundTruth will return non-noisy groundtruth
- in dev mode, object current health value (currentLife) will be present. Unbreakable objects (slingshot and platform) will have max float value (3.402823E+38 in the ground truth json). In normal mode, currentLife will not be present. Ground and Trajectory do not have currentLife in any mode
-
--noisy-batch-gt
- if the argument is used, the batch ground truth command will always return noisy grount truths regardless of the dev mode
-
The Science Birds game does not need to be run separately, GPI will start it automatically
- The Science Birds game used in this framework is a modified version of Lucas N. Ferreira's work that can be found in his Github repository
-
Run the Python naive agent
python3 main.py -
Run the Python deep Q-learning agent
- The dq agent is placed in ./src/demo/ddqn_test_harness_agent.py
- To run it:
python3 ddqn_test_harness_agent.py
-
Eagle Wings
- The eagle wings agent is located in the science birds repository
- A readme file on running the agent is included in the agent's zip file
-
Game levels are stored in the folder:
- Linux
ScienceBirds_Linux/ScienceBirds_Linux_Data/StreamingAssets/Levels/- MacOS
ab.app/Contents/Resources/Data/StreamingAssets/Levels/- Windows
ScienceBirds_Win/Science Birds_Data/StreamingAssets/Levels/ -
Game levels can be dynamically added or removed to the above folder during the running of the pipeline
-
New levels can be generated by running
python3 IratusAves.py
in folder levelgenerator
- the level generator is based on Matthew Stephenson's work.
- the latest changes on the level generator can be found in his repository
- A brief description about the level generator is here
- A detailed description of the level generator is here
- In science birds game Levels folder as shwon in the previous section, there will be a set of folders named novelty_level_*
- In each of these folders, there will be a set of folders named type*
- Each set of novel levels are placed in one type* folder which contain two subfolders: [asset bundle] and [levels]
- By default, there are 2600 levels pre-installed, where the first 200 levels are non-novelty levels used for generating the novelty levels
- To change to levels installed: simply add/remove the type* folders. This operation can be done at the run time of the game
This framework provided the following components:
-
The python naive agent
- setup.py in root folder ./
- the setup file for the python naive agent
- requirements.txt in root folder ./
- the dependencies for the python naive agent
- all source code of the agent is in ./src and will be explained in detail in a separate section
- setup.py in root folder ./
-
The game playing interface
- game_playing_interface.jar in root folder ./
- the compiled game playing interface that handles commnication between the agent and the Science Birds game
- game_playing_interface.jar in root folder ./
-
The Science Birds game
- three (Linux, MacOS and Windows) versions of the science birds game are provided in ./ScienceBirds
-
- located in ./levelgenerator
- use the command:
python3 IratusAves.pyto generator levels
- The levels will be generated into the same folder as the IratusAves.py
- Currently the generated levels can be directly copied into the game level folders
The ./src folder contains all the source code of the python naive agent. The agent is called naive agent because it ignores all other objects in the game but only aims and shoots at the pigs. Below is the outline of the code (this is a simple description. Detailed documentation in progress):
- Files under ./src/demo/
- naive_agent_groundtruth.py
- A naive agent that interacts with the game by the pre-defined protocols
- naive_agent_groundtruth.py
- Files under ./src/client/
- agent_client.py
- it encodes the commands from the naive agent to send to the interface
- it decodes the received interface messages into corresponding python object
- server_client_config.json
- the config file for the agent-interface connection
- agent_client.py
- Files under ./src/trajectory_planner/
- trajectory_planner.py
- The implementation of the trajectory module
- It calculates two possible trajectories given a directly reachable target point
- It returns None if the target is non-reachable by the bird
- trajectory_planner.py
- Files under ./src/computer_vision
- VisionMBR.py
- image segmenting component that outputs a list of minimal bounding boxes (MBRs) to represent objects of a screenshot
- VisionRealShape.py
- image segmenting component that outputs a list of real shapes to represent objects a screenshot
- ImageSegmentor.py
- Implementation of region growing based image segmentation
- GroundTruthReader.py
- Parse the ground truth json object
- Ground gruth data structure is detailed in this section
- game_object.py
- classes for representing game objects
- cv_utils.py
- utilities for vision
- VisionMBR.py
- Files under ./src/utils
- Point2D.py
- A simple 2d point class used by the naive agent and the trajectory planner
- Point2D.py
- ./main.py
- main entry to run the agent
- The coordination system
- in the python naive agent and the game playing interface, the game objects are represented in a Cartesian coordinate system with the origin point to be up-left corner. X coordinate increases along the right direction and Y coordinate increases along the downwards direction.
- in the science birds game, the origin point (0,0) is the buttom-left corner and the Y coordinate increases along the upwards direction, otherwise the same as above.
- this is to preserve compatibility with the existing game agents based on the Chrome game. We plan to change the coordinate system of ScienceBirds to match the default coordinates (origin at top left).
- Ground truth data of game objects are stored in a Json object in GeoJSON inspired format. The differences between the used format and GeoJSON are:
- The Polygon contours may not be closed, i.e., the last point in the contour may not be the same as the first one
- The point coordinates are in integer format, but not long, lat format with decimals
- The Ground object has an empty geometry element
The json object describs an array where each element describes a game object. Game object categories and their properties are described below:
- Ground: the lowest unbreakable flat support surface
- geometry: N/A
- property: id = 'the unique id of the object'
- property: type = 'Ground'
- property: yindex = [the y coordinate of the ground line]
- Platform: Unbreakable obstacles
- geometry: polygon
- property: id = 'the unique id of the object'
- property: type = 'Object' or 'Platform'
- property: currentLife = [remaining life point] (only appear in dev mode; max value for unbreakable object)
object]
- property: colormap = [a list of compressed 8-bit (RRRGGGBB) colour and their percentage in the object]
- Trajectory: the dots that represent the trajectories of the birds
- geometry: MultiPoint
- property: id = 'the unique id of the object'
- property: type = 'Trajectory'
- Slingshot: Unbreakable slingshot for shooting the bird
- geometry: polygon
- property: id = 'the unique id of the object'
- property: type = 'Slingshot'
- property: colormap = [a list of compressed 8-bit (RRRGGGBB) colour and their percentage in the object]
- property: currentLife = [remaining life point] (only appear in dev mode; max value for unbreakable object)
- Red Bird:
- geometry: polygon
- property: id = 'the unique id of the object'
- property: type = 'Object'(in evaluation) or 'red_bird_[index]'(in dev mode)
- property: colormap = [a list of compressed 8-bit (RRRGGGBB) colour and their percentage in the object]
- property: currentLife = [remaining life point] (only appear in dev mode)
- all objects below have the same representation as red bird
- Blue Bird:
- Yellow Bird:
- White Bird:
- Black Bird:
- Small Pig:
- Medium Pig:
- Big Pig:
- TNT: an explosive block
- Wood Block: Breakable wooden blocks
- Ice Block: Breakable ice blocks
- Stone Block: Breakable stone blocks
- ./src/computer_vision/GroundTruthReader.py is sample tool to read the parse ground truth json object.
- Round objects are also represented as polygons with a list of vertices
- Ground truth with noise
- If noisy ground truth is requested, the noise will be applied to each point in vertices of the game objects except the ground, all birds and the slingshot
- The noise for 'vertices' is applied to all vertices with the same amount within 2 pixels
- The colour map has a noise of +/- 2%.
- The colour is the colour map compresses 24 bit RGB colour into 8 bit
- 3 bits for Red, 3 bits for Green and 2 bits for Blue
- the percentage of the colour that accounts for the object is followed by colour
- example: (127, 0.5) means 50% pixels in the objects are with colour 127
- The noise is uniformly distributed
- We will later offer more sophisticated and adjustable noise.
- Example ground truth Json Object:
[
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {},
"properties": {
"id": "-472",
"label": "Ground",
"yindex": 300,
"colormap": []
}
},
{
"type": "Feature",
"geometry":{
"type":"MultiPoint",
"coordinates":[
[195,188],[391,108],[591,143]
]
},
"properties":{"id":"-18206","label":"Trajectory","colormap":[]}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[207,216],[207,167],[224,167],[224,216]
]
]
},
"properties": {
"id": "-608",
"label": "Slingshot",
"colormap": [],
"currentLife": 3.402823e+38
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[587,188],[587,187],[587,184],[583,184],[581,183]
]
]
},
"properties": {
"id": "-716",
"label": "pig_basic_medium_1",
"colormap": [
{"color": 0,"percent": 0.5},{"color": 4,"percent": 0.5}
],
"currentLife": 2.5
}
}
]
}
]A Docker image that uses the same setup in the evaluations is available.
- To pull the docker image:
docker pull aibirds/sbgame - To start the container:
docker run -p 2004:2004 -p 2006:2006 aibirds/sbgame - The ENTRYPOINT is
["java", "-jar", "/sciencebirds/linux/game_playing_interface.jar", "--headless"]You may append any arguments as desired
