Skip to content

Latest commit

 

History

History
134 lines (67 loc) · 7.25 KB

USAGE.md

File metadata and controls

134 lines (67 loc) · 7.25 KB

Using the UnityVGDL Framework

Scenes

UnityVGDL provides a list of scenes, for various purposes.

alt text

Learning Scenes

The learning scenes are setup to be used for training, they can be used either directly from the editor or built into executables and used as learning environments.

VGDL Learning 1, 2, 4, 8, 12, 16

The scenes are setup with 1, 2, 4, 8, 12 and 16 game instances respectively. The ML-Agents python interface can create multiple environment instances (executables), to take advantage of multiple cores when training. To optimally exploit the CPU cores, use a learning scene that uses around 100% of one core, and then use the ML-Agents python interface to spawn an environment for each availble core.

Evaluation Scenes

The evaluation scenes can be used to play vgdl games, as a Player (VGDL Evaluate Player), with scripted behavior (VGDL Evaluate Heuristic) or using a trained brain with inference (VGDL Evaluate Learning).

Setting up the scenes

As a general rule in every scene you have to change which VGDL game(s) to use. This is setup on the VGDL Academy for all scenes except the test scene.

VGDL Academy

The VGDL Academy extends the ML-Agent Academy, they control the VGDL Agent instantiation, and the list of games used for training/playing.

alt text

In any scene used for training, each brain to train is listed in the Broadcast Hub default is set to the VGDLLearning84x84 Brain, that takes a visual 84x84 renderTexture as input and outputs the discrete action space [LEFT, RIGHT, UP, DOWN, USE, NIL].

In case of training the Control checkmark has to be on, allowing the ml-agent python interface pipeline to work.

In the evaluation scenes, the Control checkmark is off, which allows the Academy to setup inference of a trained brain.

VGDL games/levels to train on

This section of the VGDLAcademy controls the game(s) used for playing/training in the scene.

Random Order determines if the order of the listed game(s)/level(s) should be shuffled.

Current Index show which game(s)/level(s) is begin used for training from the curriculum.

Current Repetition is used to determine when procede to a new game/level, based on the Min Lesson Length of each element in the Curriculum.

The curriculum is a partically implemented version of the ml-agents curriculum settings. The system is not integrated with the curriculum learning in ml-agents.

Elements in the Curriculum consists of the following

Type is game type [Grid Physics, Continuous Physics, Two-Player]. (Two-Player games current not fully implemented)

Filename is the game to load, from the selected examples Type folder, gonna be changed to a dropdown soon.

Level the level index to load, [0 to 4].

Use Reward Measure curently unused

Min Lesson Length how many times should the game/level be repeated before a new game/level is selected.

Threshold curently unused

Signal Smoothing curently unused

VGDL Agent

alt text

The VGDLAgent is setup to use visual observations using render textures. Using the Image reference the render texture is added to a UI element, for debug visualization.

The learning scenes have Max Step set to 1500 (a timeout limit also present in some VGDL descriptions).

Reset On Done is on, which means the VGDL game is reset by the VGDLAgent, the game will not restart after it ends, unless this is on.

On Demand Descisions should be disabled

Descision Interval functions like "skip frames", observations will only be collected with this interval, actions repeat between observations.

Step Reward can be used to provide a reward at each step, such as a small negative reward, to encurage agent to explore the state space more.

VGDL Runner

alt text

Verbose logs every step in the parsing and execution of a VGDL game.

Frame Rate Target used for limiting the execution speed. Default values are -1 (unlimited) and 20 (standard in GVGAI)

On Demand Updates when this is set, the VGDL game updates will be based on the VGDLAcademy updates. When it is disabled the Rendering and VGDL game updates are based on the Unity MonoBehavior Update and OnGUI / OnPostRender functions

Skip Frames unused

Render Target the render texture used to render the game.

Number of Runs To Evaluate Once this number is reached, the runner stops updating the VGDL Game. Default -1 (unlimited)

The rest of the values function as debug info.

VGDL Test Scene

The VGDL Test Scene was used heavily during development, it parses (and runs) either one or more VGDL games from the examples.

alt text

The VGDL Test script component is located on the main camera game object. The test script will parse and run games with a Random agent controlling the avatar.

Verbose logs every step in the parsing and execution of a VGDL game.

Steps Between Rendering number of game updates between rendering to the screen (speeds up tests).

Max Steps a update limit before continuing to the next level/game.

Render Target render texture to render to.

Load Levels From Game Tree a subtle new feature for VGDL, implemented in the VGDL Parser of UnityVGDL. This feature allows a VGDL level descriptions to be nested inside the game description file. Example can be seen in the Tooltip of this field (or in the code). This feature will be automated in the future (meaning the parser will just look for the Levels set and automatically load levels from game tree).

Type is the test type [Parse From Input String, Run From Input String] parses (and runs) a single game and all its levels, [Parser Test, Parse and Run Test] parses (and runs) every game and level of the selected example type.

Example Types to Load is game type [Grid Physics, Continuous Physics, Two-Player]. (Two-Player games current not fully implemented)

Select a game from the list is a dropdown, showing all games of the selected example type in the examples folder. Only appears when test type is set to [Parse From Input String, Run From Input String].

Building an Executable

alt text

To build an executable you follow the normal Unity Build steps. However you have to make sure only the scene you're trying to build is selected in the Build Settings. If you don't see the current scene in your Scenes In Build click the Add Open Scenes button.

Once the executable has been built, you can use it with the ml-agents python interface by setting the 'env' parameter on the trainer.

Training

Follow the Instructions of the ML-Agents Framework for training.