Skip to content

Deep Reinforcement Learning AI to play the SuperTuxKart race game using a Decision Transformer

License

Notifications You must be signed in to change notification settings

vibalcam/deep-rl-supertux-race

Repository files navigation

TransformerKart: A Full SuperTuxKart AI Controller

Deep Reinforcement Learning AI controller that plays the SuperTuxKart race using only inputs available to the user (images, velocity, and rotation). The controller is based on a Decision Transformer. The SuperTuxKart race game has been wrapped using a gym environment.

Full report pdf

5-minute summary video (also available youtube):

video_summary.mp4

Results

The results obtained by the different models can be found in evaluate.xlsx. Some sample videos and a chart summarizing the results can be found in the evaluate folder.

Summary chart

Full model (steer, drift, and acceleration):

lighthouse_trans_drift_acc_0.mp4

Steer and drift model:

lighthouse_trans_drift_0.mp4

Training Process

The following steps have to be done to train a model:

Once the model has been trained and saved, we can evaluate the models by specifying the models to be evaluated in run.py.

Get Data

It runs the baseline model (with and without noise) on the environment to obtain a dataset of episodes that are used for training our models.

To change the way data is gathered or more information check run.py.

python -m run -t

CNN Autoencoder

The CNN autoencoder that is later used by the controller models can be found in agents/cnn.py.

To train the CNN autoencoder on the available data:

python -m agents.cnn

Full Model

Learns to steer, drift, and accelerate.

It can be trained from scratch. However, we have first pretrained a CNN autoencoder and used the encoder for the image embedding layer. To modify this behavior or more information check agents/decision_transformer.py.

The following command trains this model with the autoencoder and data already available:

python -m agents.decision_transformer 

Steer Model

Learns to steer and has fixed acceleration and drift disabled.

It can be trained from scratch. However, we have first pretrained a CNN autoencoder and used the encoder for the image embedding layer. To modify this behavior or more information check agents/decision_transformer.py.

The following command trains this model with the autoencoder and data already available:

python -m agents.decision_transformer --no_drift 

Drift Model

Learns to drift and steer, and has fixed acceleration.

It can be trained from scratch. However, we have used the steer model with the best validation loss as our starting model for training. To modify this behavior or more information check agents/decision_transformer.py.

The following command trains this model with the steer model and data already available:

python -m agents.decision_transformer --fixed_velocity 

Evaluate Models

It runs the set of given models, the baseline, and the game AI for a certain number of episodes to evaluate their performance.

The models being evaluated are preset and need to be unziped before being used (the models are available in the saved folder). To change the models being evaluated or more information check run.py.

To evaluate the models on the lighthouse track:

python -m run --evaluate_lighthouse

To evaluate the models on all selected tracks (models given have not been trained in other tracks than lighthouse):

python -m run --evaluate

Environment

Gym environment that wraps the PySuperTuxKart game environment.

To check the environment options or select which tracks to use check environments/pytux.py.

About

Deep Reinforcement Learning AI to play the SuperTuxKart race game using a Decision Transformer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages