Skip to main content

Čapek

Python library for developing TORCS racing robots.

Getting started

  1. 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
    
  2. Install Čapek.

    $ pip install capek --user
    
  3. Program a robot's logic.

    Reference robots are located in the examples directory.

  4. Test the robot.

    1. Start TORCS.
    2. Select Race → Practice → Configure Race → Accept.
    3. Drop scr_server 1 to the Selected menu. This is the robot.
    4. Select Accept → Accept → New Race.
    5. Observe.
  5. 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.

Metadata

Release files for capek 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for capek 0.1.0
File Size Uploaded
capek-0.1.0.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for capek 0.1.0
File Interpreter ABI Platform
capek-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / capek-0.1.0.tar.gz

Download URL capek-0.1.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
781f6f5df27c7e3f50af1ebfab2d7be412e5d22a603f6931b36da4535464864f
BLAKE2b-256 checksum
How to use checksums
0080cbbb9f1ea491cf01e431d773cb852e35d693e940d8f9ab2a49168da00756
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / capek-0.1.0-py3-none-any.whl

Download URL capek-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f8e5f494a36155c9860569a9f3e9ffc9c3d6be823af1bb0e0dd22311f91b287
BLAKE2b-256 checksum
How to use checksums
521207ecdf8c654fe4b2a8b3bddf2b1749ca496c7aaae52c8c524d61146ce25a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page