Torquing it up with TORCS, The Open Racing Car Simulator
- Posted: Aug 22, 2012 at 6:00 AM
- 6,626 Views
Todays wild Wednesday project comes to us via David Bolton's The Next Best thing to Racing post.
Racing, who doesn't like racing (or at least the thought of racing)? Yet, that's just not something the average guy and girl gets to do very often. So what's the next best thing? Racing Sim's of course! And what makes it best++? Having the source to a racing sim!
This is the official site of TORCS, The Open Racing Car Simulator. TORCS is a highly portable multi platform car racing simulation. It is used as ordinary car racing game, as AI racing game and as research platform. It runs on Linux (all architectures, 32 and 64 bit, little and big endian), FreeBSD, OpenSolaris, MacOSX and Windows (32 and 64 bit). The source code of TORCS is licensed under the GPL ("Open Source"). You find more information about the project in the menu bar on the left. If you need help have a look at the FAQ first, I added a new Researchers section. You can contact us on the torcs-users mailing list (you need to subscribe to use it because of spam).
There are various sites on the Internet dedicated to TORCS with additional content (cars, tracks, documentation, patches, etc.), you can find them in the "Related Sites" section in the menu on the left. If you are interested in racing visit the sites listed in the Racing section.
If you need new tracks use the online track generator.
TORCS features more than 50 different cars, more than 20 tracks, and 50 opponents to race against. Your can steer with a joystick or steering wheel, if the device is supported by your platform. It is also possible to drive with the mouse or the keyboard. Graphic features lighting, smoke, skidmarks and glowing brake disks. The simulation features a simple damage model, collisions, tire and wheel properties (springs, dampers, stiffness, ...), aerodynamics (ground effect, spoilers, ...) and much more. The gameplay allows different types of races from the simple practice session up to the championship. Enjoy racing against your friends in the split screen mode with up to four human players.
TORCS was initially written by Eric Espié and Christophe Guionneau, substantial parts have been added by other contributors (have a look into the "Credits" section for details). The TORCS source code is licensed under the terms of the GNU General Public License (GPL), most of the artwork is licensed under the Free Art License, have a look into the packages for details about copyright holders and the licensing.
The next big development goal is an online racing mode.
- Download and run torcs_1.3.3_setup.exe. It requires at least an i686 compatible CPU to run.
Sure you can get the binaries and just play the game, but I did mention source?
- Requires VS 6.0 (tested with sp6) or VS 2008 (tested with sp1).
- Download the source package torcs-1.3.3.tar.bz2.
- Unpack the package with "tar xfvj torcs-1.3.3.tar.bz2" or any application you like, be careful to select a path without whitespaces and other special characters.
- Hint: You can build a release and a debug version side by side, the required step for the debug version is showed in brackets "()".
- Open a command prompt and cd into the torcs-1.3.3 directory.
- Run setup_win32.bat (setup_win32_debug.bat).
- Run setup_win32-data-from-CVS.bat (setup_win32-data-from-CVS_debug.bat).
- Open the file TORCS.dsw with VS 6.0 or the TORCS.sln with VS 2008.
- Select the TORCS project and the win32-Release (win32-Debug) version.
- Compile the project (0 warnings).
- cd into the "runtime" ("runtimed") directory.
- Run "wtorcs.exe".
I grabbed the source (note, it's a 300+ MB download and 1.2+ GB uncompressed) and followed the above instructions. Now VS 2010 is not mentioned, but that worked for me with only one very minor tweak.
I was getting an error compiling the Learning.dll.
To fix this all I had to do was comment out the message export in the learning.def
Once I did that (make_message was previously commented) everything compiled with no warnings or errors.
Here's a snap of the Solution;
As you can see, both in the solution and the site, this is not some little, simple, project but a very mature and complex project.
What, you want more? Well what if I was to tell you that you can also code your own robot/AI drivers?
4.4.2 Can I develop a robot using Windows?
Yes, you can. Here is a rough guide:
- Download the TORCS source and manage to compile and run it.
- Download e. g. the bt robot package, it is a little enhanced version of the robot developed in the tutorial, so there is good documentation available to understand it.
- Copy the sources into a new directory, e. g. when you choose the name "myrobot" create a directory /src/drivers/myrobot.
- Copy all the bt files into the myrobot directory.
- Now rename all "bt*" files into "myrobot*".
- Edit myrobot.def and also change all bt strings into myrobot.
- The same for myrobot.dsp, .xml, perhaps more, you get the idea.
- Change the "bt" module entry point in myrobot.cpp to "myrobot", also make the strings for the robots names and description match with those in myrobot.xml.
- Add the myrobot project to TORCS, open the project with vc++ and try to compile it.
- If you want to deploy the files you have to do that manually, create a directory in "runtime" where the other robots are and copy the required files there (myrobot.dll, .xml, setup subdirectories etc.).
- Now TORCS should pick up your robot.
There's more information and tutorials on the wiki too...
If gaming, sims, racing, AI, cars or c++ are your thing, or your just looking for something different to do, TORCS' rev'ing engine might be music to your ears...