5.3 Creating the Directory Structure

Introduction

In this section we will create the directory structure and the Makefiles for the cg-nascar-rwd (the car with index 0). For the other cars it works the same way. We need Makefiles just to ease the deployment, we could also copy the setup files manually to the torcs directory.

Creating the Directories

Make sure you are in the bt source directory:

$ cd $TORCS_BASE/src/drivers/bt

Now we create the subdirectories for the setups:

$ mkdir -p 0/practice
$ mkdir 0/qualifying
$ mkdir 0/race

For another car replace 0 with its index and do it the same way.

The Makefiles

First we change the main Makefile of bt to process the subdirectory 0. Change the line

SHIPSUBDIRS =

to

SHIPSUBDIRS = 0

When you want to add more subdirectories append them to this line, e. g. "0 1". Now create the Makefile in directory 0 with the following content:

ROBOT       = bt
SHIPDIR     = drivers/${ROBOT}/0
SHIP        = default.xml
SHIPSUBDIRS = practice qualifying race

PKGSUBDIRS  = ${SHIPSUBDIRS}
src-robots-bt_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-bt_PKGDIR   = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))
include ${MAKE_DEFAULT}

Like you can see it deploys the file default.xml and the subdirectories practice, qualifying and race. In this subdirectories we need also Makefiles to deploy the setup files. Here is the Makefile for the 0/practice directory.

ROBOT       = bt
SHIPDIR     = drivers/${ROBOT}/0/practice
SHIP        = $(shell find *.xml -maxdepth 0 -type f -print)

src-robots-bt_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-bt_PKGDIR   = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))
include ${MAKE_DEFAULT}

Here the Makefile for the 0/qualifying directory.

ROBOT       = bt
SHIPDIR     = drivers/${ROBOT}/0/qualifying
SHIP        = $(shell find *.xml -maxdepth 0 -type f -print)

src-robots-bt_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-bt_PKGDIR   = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))
include ${MAKE_DEFAULT}

And finally the Makefile for the 0/race directory.

ROBOT       = bt
SHIPDIR     = drivers/${ROBOT}/0/race
SHIP        = $(shell find *.xml -maxdepth 0 -type f -print)

src-robots-bt_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-bt_PKGDIR   = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))
include ${MAKE_DEFAULT}

Before the Makefiles work there has to be at least one XML file in every directory. Put this stripped down default setup of cg-nascar-rwd into the file 0/default.xml. Copy it also to the following locations:

$ cp 0/default.xml 0/practice/g-track-3.xml
$ cp 0/default.xml 0/qualifying/g-track-3.xml
$ cp 0/default.xml 0/race/g-track-3.xml

This should be enough for a litte test run. Do a "make install", check if it works without errors and look up in the target directory if everything is in place. In the next sections we will work with these files.

Downloads

In case you got lost, you can download my robot for TORCS 1.2.0 or later.

Summary

  • You know the directory structure.
  • You have created all files.
  • You have checked if the installation works.