Goal: build your first robot, select it in Practice, and see it hold still.
You need Visual Studio 2022 with the C++ tools and Windows SDK, and a working TORCS development build with game data. To get started, use Release / x64. Prepare the repository using setup_win32.bat and setup_win32-data-from-CVS.bat, then build TORCS.sln with that configuration. Confirm that runtime/wtorcs.exe launches normally.
Open PowerShell in the TORCS source root: the directory containing TORCS.sln and src/. In a double-nested checkout this is torcs/torcs/. Run the commands below from that directory.
If src/drivers/tutorial1 already exists, use your existing copy. Keep the name tutorial1 for now. Edit files in this working copy, rather than the documentation's reference copy.
Use Microsoft's vswhere utility, included with the Visual Studio Installer, to locate MSBuild automatically:
Copy this whole block once. It finds your installed build tool. You can use this command without understanding every option yet.
This finds a Visual Studio 2022 installation with the C++ tools, regardless of edition or installation directory. See Microsoft's MSBuild discovery documentation for details. Then build the stationary checkpoint:
The project uses the headers and libraries from your TORCS build and installs the driver into runtime/drivers/tutorial1/ automatically. Wait for the build to finish successfully before opening the game. If it reports an error, use the help section below.
Your car should stay still. That is success! The skeleton deliberately holds the brakes. You now know how to build a robot and get TORCS to load it.
Next: Chapter 1 — Make It Drive. Come back to the short rebuild instructions below when the chapter asks you to try the driving code.
Leave the Practice session and return to the menu. TORCS unloads the driver when the session ends, so you can keep the game open. Then run this from the source root in the same PowerShell session:
If you opened a new PowerShell session, set $msbuild again as shown above. This build selects driving.cpp instead of skeleton.cpp. Start a new Practice session with the same driver and track; TORCS loads the rebuilt DLL. Use this command again after each edit to driving.cpp.
Continue making your robot drive.
From the source root, copy the new example into its own working directory:
If that directory already exists, use your existing copy. Leave the current Practice session and return to the menu, then build and install:
If you opened a new PowerShell session, run the MSBuild discovery block above first. Select Tutorial 2 on CG Speedway number 1 in a new Practice session. This example deliberately makes a small driving mistake at the start. Chapter 2 — Get Back on Track explains what to watch for.
After edits to recovery.cpp or practice.cpp, save and use the same build command. The Chapter 1 driver remains available as Tutorial 1.
From the source root, copy the new example into its own working directory:
If it already exists, use your working copy. Leave the current Practice session, then build and install:
If this is a new PowerShell session, run the MSBuild discovery block above first. Select Tutorial 3 on CG Speedway number 1 in a new Practice session. Chapter 3 — Choose Your Speed explains what to observe. After changes to speed.cpp or braking.cpp, save and use the same build command. The earlier drivers remain available for comparison.
From the source root, copy the steering example into its own working directory:
If it already exists, use your working copy. Leave the current Practice session, then build and install:
If this is a new PowerShell session, run the MSBuild discovery block above first. Select Tutorial 4 on CG Speedway number 1 in a new Practice session. Chapter 4 — Steering and Trajectory explains the comparison. Edit steering4.cpp for lookahead experiments and speed4.cpp for later speed experiments. Save and use the same build command after each change.
This chapter adds traffic decisions and a reference pace driver. Assemble a new working folder from its files and the supplied Chapter 4 helper sources. From the source root:
If the folder already exists, use your working copy. Copy the helpers from the supplied examples so earlier experiments do not change this chapter's baseline. The assembled folder contains everything needed to compile both modules.
Leave the current session, then build and install both drivers:
In a new PowerShell session, run the MSBuild discovery block above first. Follow Chapter 5's Quick Race instructions. The drivers appear as Tutorial 5 and Tutorial Pace. The project builds two independent, single-entry DLLs into separate output directories.
For the main experiments, edit traffic5.cpp. tutorial5pace.cpp contains the reference opponent's speed cap. Use the same two build commands after edits.
The final checkpoint contains every helper source. From the source root:
If the directory already exists, use your working copy. Leave the active session, then build and install:
In a new PowerShell session, run the MSBuild discovery block above first. Follow Chapter 6's six-lap Quick Race exercise. Select Tutorial 6. Edit tutorial6.cpp for starting fuel and pit.cpp for pit/strategy settings, then use the same rebuild command.
The downloadable tutorial6.zip contains the same complete folder. If using that download, extract its tutorial6 directory under src/drivers/ before building. No files or DLLs from the earlier checkpoints are required for the solo exercise; the optional traffic exercise adds a separately selected opponent.
From the source root, create a separate working copy of the complete example:
Alternatively extract the download's tutoriala folder under src/drivers/. Run the MSBuild discovery block above if this is a new PowerShell session. Leave the active session, then build and install:
The project copies the module and tutoriala.xml, default.xml, and g-track-1.xml into runtime/drivers/tutoriala/ for Release. Select Tutorial A for Appendix A's baseline race.
For XML-only experiments, edit default.xml or g-track-1.xml in your working copy, save, leave the session, and deploy using the same build command. The post-build installation target copies XML even when compilation is up to date. Alternatively copy just those edited configuration files to the Release runtime:
Start a new session to read them. C++ changes require the build command. Debug uses the matching runtimed installation instead; keep the game's configuration and platform consistent with the module. A new track file must also be added to the project's install Copy list. Editing installed XML directly works, but the next build/install replaces it from your working copy.
From the source root, create a working copy of the complete example:
Alternatively extract the download's tutorialb folder under src/drivers/. In a new PowerShell session, run the MSBuild discovery block above first. Leave the active session and build/install:
The project installs the module, configuration, car1-stock1.rgb, logo.rgb, and artwork notice into runtime/drivers/tutorialb/ for Release. Select Tutorial B for the appearance exercise.
After editing the XCF or SVG sources, export the SGI images into your working folder. Leave the session and use the same build command to deploy them, or copy just those two images into the Release runtime:
Start a new session to load the new images. Image-only edits do not require C++ compilation. Use the corresponding runtimed destination for a matching Debug build. The editable artwork stays in the source folder and download; it is not needed by the running game. If you add individual index directories later, add their directory creation and image copies to the project's installation target.
From the source root, create a working copy of the complete final checkpoint:
Alternatively extract the download's tutorialc folder under src/drivers/. Run the MSBuild discovery block above if needed, leave the active session, then build and install the single module:
The project builds driver.cpp along with the helpers and installs one DLL, the description XML, shared configuration, and the team logo. It creates runtime/drivers/tutorialc/1/ and 2/ and installs the individual settings and textures there. Keep these folders intact in your working copy.
Select Tutorial C Red, Tutorial C Teal, or both for Appendix C's exercises. Build the module once for both entries. After individual XML/image edits, leave the session and use the same build/install command; its installation target runs even when compilation is up to date. Start a new session to read the files. C++ changes require a rebuild. Debug uses the corresponding runtimed destination and matching game build. Add new individual runtime files to the project's installation Copy list.
| Symptom | What to check |
|---|---|
| MSBuild discovery fails | Copy the whole discovery block into PowerShell again. If it still cannot find the tools, ask your teacher or the community to help check the Visual Studio installation. |
| Build cannot find headers or libraries | The initial TORCS development setup may be incomplete. Ask your teacher or the community for help and include the error text. |
| The DLL cannot be replaced | Leave the Practice session and return to the menu before rebuilding; merely pausing keeps the driver loaded. Check that another TORCS instance is not using it. |
| Tutorial 1 is missing | Launch runtime/wtorcs.exe from this checkout and check that the car1-stock1 game data is present. |
| The old behaviour persists | Save the file in src/drivers/tutorial1/, leave the session, check that the rebuild succeeds, and start a new Practice session. |
Still stuck? Questions and feedback explains where to ask. You do not need to diagnose the problem first.
The project also supports Debug and Win32. If you use these later, match the game's configuration and architecture; Debug uses the debug setup scripts, debug libraries, and runtimed/ rather than runtime/.