Reinforcement Learning toolkit for Assetto Corsa and Car Racing environments
Project description
Assetto Corsa RL
A comprehensive reinforcement learning toolkit for training agents in Assetto Corsa and Car Racing environments using Soft Actor-Critic (SAC) with optional VAE-based vision encoding.
Features
- ๐๏ธ Assetto Corsa Integration: Full telemetry and control integration with Assetto Corsa
- ๐ฎ Car Racing Support: OpenAI Gym Car Racing environment compatibility
- ๐ง SAC Implementation: State-of-the-art Soft Actor-Critic algorithm
- ๐๏ธ Vision-Based Learning: VAE encoder for image-based observations
- ๐ Behavioral Cloning: Pretrain agents from human demonstrations
- ๐ ๏ธ Complete CLI: Unified command-line interface for all operations
- ๐ WandB Integration: Experiment tracking and visualization
Installation
From PyPI (Recommended)
pip install assetto-corsa-rl
From Source
git clone https://github.com/yourusername/assetto-corsa-rl.git
cd assetto-corsa-rl
pip install -e .
Development Installation
pip install -e ".[dev]"
Quick Start
Assetto Corsa
1. Record Racing Line
acrl ac record-line --output racing_lines.json --laps 2
2. Train Agent
acrl ac train
3. Test Agent
acrl ac load --ckpt models/checkpoint.pt --episodes 5
Car Racing (Gym)
Train Agent
acrl gym train
Test Agent
acrl gym load --model pretrained.pt --episodes 5 --render
CLI Reference
Global Commands
acrl --version # Show version
acrl --help # Show help
Assetto Corsa Commands
Training
# Train SAC agent
acrl ac train
# Pretrain with behavioral cloning
acrl ac pretrain --data-dir datasets/demonstrations --epochs 50
# Train VAE encoder
acrl ac train-vae --input-dir datasets/ac_images --epochs 100
Testing
# Load and test trained agent
acrl ac load --ckpt models/checkpoint.pt --episodes 5 --deterministic
# Visualize VAE reconstructions
acrl ac load-vae --ckpt vae.ckpt --env ac
Data Collection
# Record racing line
acrl ac record-line --output racing_lines.json --laps 2 --track monza
# Record demonstrations
acrl ac record-demo --output-dir datasets/demonstrations --duration 300
# Save image dataset
acrl ac save-images --output-dir datasets/ac_images --frame-stack 4
Visualization
# Visualize racing line
acrl ac vis-line --input racing_lines.json --lap 0
# Visualize image dataset
acrl ac vis-images --input-dir datasets/ac_images
Car Racing Commands
# Train agent
acrl gym train
# Test agent
acrl gym load --model checkpoint.pt --episodes 5 --render
# Train VAE
acrl gym train-vae --epochs 10 --batch-size 128
# Visualize VAE
acrl gym load-vae --model vae.ckpt --frames 4
Project Structure
assetto-corsa-rl/
โโโ src/
โ โโโ assetto_corsa_rl/
โ โโโ ac_env.py # Assetto Corsa environment
โ โโโ cli.py # Command-line interface
โ โโโ model/
โ โ โโโ sac.py # SAC implementation
โ โ โโโ vae.py # VAE encoder
โ โโโ train/
โ โโโ train_core.py # Training loop
โโโ scripts/
โ โโโ ac/ # Assetto Corsa scripts
โ โโโ car-racing/ # Car Racing scripts
โโโ configs/ # Configuration files
โโโ tests/ # Unit tests
โโโ pyproject.toml # Package configuration
Configuration
The toolkit uses YAML configuration files in the configs/ directory:
configs/ac/env_config.yaml- Environment settingsconfigs/ac/model_config.yaml- Model architectureconfigs/ac/train_config.yaml- Training hyperparameters
Requirements
- Python >= 3.9
- PyTorch >= 2.0.0
- TorchRL >= 0.2.0
- Gymnasium >= 0.29.0
- OpenCV >= 4.8.0
- Click >= 8.1.0
See requirements.txt for full list.
Development
Running Tests
pytest tests/
Code Formatting
black src/ tests/
isort src/ tests/
Type Checking
mypy src/
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details
Citation
If you use this toolkit in your research, please cite:
@software{assetto_corsa_rl,
title = {Assetto Corsa RL: Reinforcement Learning Toolkit},
author = {Contributors},
year = {2026},
url = {https://github.com/yourusername/assetto-corsa-rl}
}
Acknowledgments
- Built with TorchRL
- Inspired by racing simulation research
- SAC algorithm from Haarnoja et al. (2018)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file assetto_corsa_rl-0.1.0.tar.gz.
File metadata
- Download URL: assetto_corsa_rl-0.1.0.tar.gz
- Upload date:
- Size: 85.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dde33526d8fc72dfb0b732d4b1832af25cee94186665dc60459c6ad8c1894fc3
|
|
| MD5 |
9e500cc88b00eff503942a1e9cce6528
|
|
| BLAKE2b-256 |
8bdd727860327be2e1eb035f26967220c709c1d2bf90ced4fc860cc18d70ec20
|
File details
Details for the file assetto_corsa_rl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: assetto_corsa_rl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8413f62292425487b742a4b29328120d129f2898e6df11396f1f54eae32cd050
|
|
| MD5 |
3a168dad99f50f1bfdad9ba7e8854328
|
|
| BLAKE2b-256 |
8f468b54a257f7c25d4d13cde9ad9ab7759b0cbb6737343126b0f9a6fb7bc1df
|