Python library for developing TORCS racing robots
Project description
Čapek
Python library for developing TORCS racing robots.
Getting started
-
Install TORCS.
The most convenient way is to install TORCS from this repository. The repository contains the most recent version of the simulator with SCR patches that allow communicating with TORCS via UDP.
$ git clone https://github.com/fmirus/torcs-1.3.7.git $ sudo apt-get install libglib2.0-dev libgl1-mesa-dev libglu1-mesa-dev \ freeglut3-dev libplib-dev libopenal-dev libalut-dev libxi-dev \ libxmu-dev libxrender-dev libxrandr-dev libpng-dev $ cd torcs-1.3.7 $ ./configure $ make $ sudo make install $ sudo make datainstall -
Install Čapek.
$ pip install capek --user -
Program a robot's logic.
Reference robots are located in the
examplesdirectory. -
Test the robot.
- Start TORCS.
- Select
Race → Practice → Configure Race → Accept. - Drop
scr_server 1to theSelectedmenu. This is the robot. - Select
Accept → Accept → New Race. - Observe.
-
Fix, if necessary.
Creating robots
To create a robot using Čapek, you have to re-implement the Driver class.
The common structure of a robot is demonstrated below.
from capek import Driver, Client
class MyDriver(Driver):
# ...
# Initialize necessary classes or variables.
# ...
def drive(self, state, control):
# ...
# Define behavior on gear change, steering, etc.
# ...
if state.speed_X < 300:
control.accel = 1
else:
control.accel = 0
# Changes in control are sent to TORCS on the next tick.
return control
client = Client(verbosity=1)
# Enters loop until reaches maximum learning episodes.
# Or is interrupted.
client.run(driver=MyDriver)
The only methods that are supposed to be re-implemented are drive, on_shutdown and on_restart.
The two latter exist because of convention with C++ and Java clients.
Project details
Release history Release notifications | RSS feed
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 capek-0.1.0.tar.gz.
File metadata
- Download URL: capek-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.6.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
781f6f5df27c7e3f50af1ebfab2d7be412e5d22a603f6931b36da4535464864f
|
|
| MD5 |
26a2ba978bd219021378551b27fd7b2c
|
|
| BLAKE2b-256 |
0080cbbb9f1ea491cf01e431d773cb852e35d693e940d8f9ab2a49168da00756
|
File details
Details for the file capek-0.1.0-py3-none-any.whl.
File metadata
- Download URL: capek-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.6.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f8e5f494a36155c9860569a9f3e9ffc9c3d6be823af1bb0e0dd22311f91b287
|
|
| MD5 |
8df2142e4e063e157fe36a3db1dcd1ad
|
|
| BLAKE2b-256 |
521207ecdf8c654fe4b2a8b3bddf2b1749ca496c7aaae52c8c524d61146ce25a
|