Skip to content

Delaunay/cartpole

Repository files navigation

Cartpole

Documentation Status

Reimplementation of the cartpole environment in UE4 as a demo of the MLAdapter plugin

/_static/Cartpole_big.png

Requirements

  • UE4 - 4.27/master/5.1

Note

For linux you will need to compile Enable_U4ML_Linux branch from source.

Note

For a more reliable experience you can use UE4ML_Tweaks branch

Note

For UE5 on linux you will need to disable 2 plugins (XGEController and FastBuildController as of Jan 2022)

Packaged Install

Unfortunately U4ML python package is not open source and you will need to create an Epic account to install it on your machine. Once it is install you can run any packaged environment without installing or compiling UnrealEngine.

# Install MLAdapter python package
python -e UnrealEngine/Engine/Plugins/AI/MLAdapter/Source/python

# Download the cartpole environment
wget https://github.com/Delaunay/cartpole/releases/download/0.0.0-package-test/cartpole-0.0.0-py3-none-any.whl
pip install cartpole-0.0.0-py3-none-any.whl

# run the packaged environment for training
cartpole-train --launch

Development Install

Note

This repo started using UE5 after commit 332ae357235995d1184effdb060

Install the python package to run this example as a gym environment

git clone https://github.com/Delaunay/cartpole
cd cartpole
pip install -e .

# Install MLAdapter python package
python -e UnrealEngine/Engine/Plugins/AI/MLAdapter/Source/python

# this will compile the project
UE4Editor Cartpole.uproject

# Click play in the editor to start the game

# this will connect to the game running inside the editor
cartpole-train --no-launch

To run the example just launch the appropriate script

python Source/python/cartpole/run.py --project E:/cartpole/Cartpole.uproject --exec E:/UnrealEngine/Engine/Binaries/Win64/UE4Editor.exe