Dev FAQ
This page provides answers to common questions for developers working on the project.
Project Setup
Q: How do I set up the development environment?
A: We recommend using uv for fast installation:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh # Linux/macOS
irm https://astral.sh/uv/install.ps1 | iex # Windows
# Clone and setup
git clone https://github.com/ArtyomZemlyak/rulka.git
cd rulka
uv sync
# Activate environment
source .venv/bin/activate # Linux/macOS
.\.venv\Scripts\activate # Windows
Q: Can I use pip instead of uv?
A: Yes:
python -m venv .venv
source .venv/bin/activate # or .\.venv\Scripts\activate on Windows
pip install -e .
Dependencies
Q: How do I add a new dependency?
A: All dependencies are managed in pyproject.toml:
# Using uv (recommended)
uv add package-name
# Using pip
# 1. Edit pyproject.toml manually
# 2. pip install -e .
Q: Where are the requirements.txt files?
A: They’ve been replaced by pyproject.toml. All dependencies (PyTorch, TorchRL, etc.) are specified in the [project.dependencies] section.
Code Quality
Q: How do I run linters?
A: The project uses Ruff for linting and formatting:
# Install dev dependencies
uv sync --group dev # or pip install -e ".[dev]"
# Run linter
ruff check .
ruff format .
Q: Are there pre-commit hooks?
A: Not currently set up. Contributions to add pre-commit hooks are welcome!
Testing & Verification
Q: How do I test my installation?
A:
# Verify config loads (from project root)
python -c "from config_files.config_loader import load_config; c = load_config('config_files/rl/config_default.yaml'); print('Config OK')"
python scripts/check_plugin.py
# Verify packages
python -c "import torch; print(f'PyTorch: {torch.__version__}')"
python -c "import torchrl; print(f'TorchRL: {torchrl.__version__}')"
python -c "import trackmania_rl; print('OK')"
Q: Are there unit tests?
A: Not currently. The project uses integration testing by running training. Unit tests would be a valuable contribution!
Configuration Development
Q: How do I add a new configuration parameter?
A:
Add the parameter to the appropriate Pydantic model in
config_files/config_schema.pyAdd it to the corresponding section in
config_files/rl/config_default.yamlUpdate the Configuration Guide (Configuration Guide) with full documentation
Verify with:
python -c "from config_files.config_loader import load_config; load_config('config_files/rl/config_default.yaml')"
Q: Can I modify config during training?
A: Config is loaded once at startup. To change parameters, edit the YAML file and restart training. A snapshot is saved in save/{run_name}/config_snapshot.yaml.
Warning
Don’t change network architecture, input dimensions, or action space - these require restart.
Documentation
Q: How do I build the documentation?
A:
# Install doc dependencies
pip install -e ".[doc]"
# Build docs
cd docs
make html # Linux/macOS
.\make.bat html # Windows
# View docs
firefox build/html/index.html # Linux
open build/html/index.html # macOS
start build/html/index.html # Windows
Q: How do I add a new documentation page?
A:
Create
.rstfile indocs/source/Add it to the toctree in
docs/source/index.rstBuild and verify:
make htmlCheck links:
make linkcheck
Troubleshooting
Q: Import errors after installation
A:
# Reinstall in editable mode
pip install -e .
Q: CUDA not available in development
A:
# Check CUDA
nvidia-smi
python -c "import torch; print(torch.cuda.is_available())"
# Reinstall PyTorch
uv sync --reinstall
Q: Game connection issues during development
A: Checklist:
Verify TMInterface is running
Check port in
.env(BASE_TMI_PORT, default 8478)Ensure
Python_Link.asis copied toTMInterface/Plugins/Check TMLoader profile includes TMInterface
Performance
Q: How can I speed up training during development?
A:
Increase
gpu_collectors_countin theperformancesectionIncrease
running_speed(up to 200x)Reduce image resolution (
w_downsized,h_downsized) in theneural_networksectionDisable visualization in the
performancesection
Q: How can I reduce memory usage?
A:
Reduce
memory_size_schedulein thememorysectionReduce
batch_sizein thetrainingsectionReduce
gpu_collectors_countin theperformancesection
Virtual Checkpoints
Q: How do I create virtual checkpoints for a new map?
A:
# 1. Drive the track and save replay
# 2. Convert replay to VCP
python scripts/tools/gbx_to_vcp.py "path/to/replay.Replay.Gbx"
# 3. File is saved to maps/ folder
# 4. Update map_cycle.entries in config YAML to use new VCP file
Q: What’s the format of VCP files?
A: VCP files are NumPy arrays (.npy) with shape (N, 3) containing waypoint coordinates (X, Y, Z). Points are sampled every 0.5m (configurable via distance_between_checkpoints) along the replay trajectory.
Project Structure
Q: Where is the main code located?
A:
trackmania_rl/- Core RL implementationagents/- IQN agent implementationmultiprocess/- Parallel training (collector & learner processes)tmi_interaction/- Game interface (TMInterface communication)
config_files/- YAML configuration (config_default.yaml, config_schema.py, config_loader.py)scripts/- Training script and tools
Q: How is configuration structured?
A:
Configuration is loaded from a YAML file (e.g.
config_files/rl/config_default.yaml) at startup viatrain.py --config <path>Use
from config_files.config_loader import get_configandget_config().<attribute>to access settings in codeUser-specific settings (paths, username) come from
.envin the project rootA snapshot of the config used for each run is saved in
save/{run_name}/config_snapshot.yaml
Build System
Q: Why was setup.py removed?
A: Migrated to modern pyproject.toml with hatchling build backend (PEP 517/518 compliant). Benefits:
Single source of truth for dependencies
Native uv support
Faster installation
Modern Python packaging standards
Q: What’s in pyproject.toml?
A:
Project metadata (name, version, description)
All dependencies (PyTorch, TorchRL, etc.)
Optional dependencies (dev, doc)
Build system configuration (hatchling)
Tool configuration (ruff)
uv-specific settings (PyTorch CUDA index)
Contributing
Q: How do I contribute to this fork?
A:
Fork the repository
Create a feature branch
Make your changes
Follow coding guidelines (use Ruff)
Update documentation
Test thoroughly
Submit a pull request
See Contributions for detailed guidelines.
Q: What coding style should I follow?
A:
Use Ruff for formatting:
ruff format .Add docstrings to new functions/classes
Follow existing code patterns
Update documentation for new features
Links
Original Linesight: https://github.com/pb4git/linesight
TMInterface: https://donadigo.com/tminterface/
TMNF Exchange: https://tmnf.exchange/
PyTorch Docs: https://pytorch.org/docs/
TorchRL Docs: https://pytorch.org/rl/
uv Package Manager: https://github.com/astral-sh/uv
Ruff Linter: https://github.com/astral-sh/ruff