A.I.
This document explains how you can modify the AI players in Turbo Sliders and how you can make new driving lines for the AI players. AI support was added in version 1.0.6.
MODIFYING AI PLAYERS
File ai/aiplayers.dat defines all the AI players in the game.
You can change the name, color or skill for every player or add your own new players. A new AI player is added with a line "AIPlayer <name>". It gets these properties:
- Skill: The skill group to which the player belongs to. When AI players are added to a race, they are picked among the players that belong to the right skill group. Skill value does not define as such how good a driver the player is, and if you want, you may make some skill groups have both good and bad players.
- SpeedFactor <val>: This value is multiplicated by the optimal speed value given by driving line files. If you make this value less than 1.00, the player drives slower than it should. Some tracks with jumps may override this value to make the players be able to complete critical jumps.
- LapClass <val1> <val2>: These values define how good driving lines the car picks. When a new lap is started, one new driving line is selected by random. The first value is the proportion of the best laps that are not possible. The second value defines the other end, the greater it is the more bad laps are possible. For example, if the values are 0.0 and 1.0, any driving line can be taken. If the values are 0.0 and 0.5, only the best half of the laps are considered. If the values are 0.9 1.0, only the worst tenth of the laps are possible.
- BestCarProb <val>: This is the probability (in percentage) for the AI player to select the best car (according to driving lines) for a race if it can choose which car to take.
- MaxSpeedUp <val>: The AI player can decide to increase SpeedFactor at most by this value if a human player is ahead of it. The addition cannot make the value more than 1.00, though. Valid range from 0.0 to 0.5.
- MaxSpeedDown <val>: The AI player can decide to decrease SpeedFactor at most by this value if a human player is behind it. Valid range is from 0.0 to 0.5.
- MaxLapClassChange <val>: If this is more than 0, AI player can decide to prefer better or worse laps than normally (to make the race tighter against human players). The valid range is from 0 to 0.5. If the value is 0, all laps within LapClass are possible. If it is 0.5, only half of the laps may sometimes be possible.
- Color <color>: This defines the color of the player. The color is defined either in a short or long form. In the short form, there is only one solid color (given in hexadecimal number). In a long form, there is first a number defining color mode and then three colors.
When any of these values is defined in the file, all the following players will have the previous value until a new value is given. By default, all players in the same skill level have the same values for SpeedFactor, LapClass, BestCarProb etc. but if you want, you can change them anywhere.
CREATING DRIVING LINES
AI players can only drive in a race if they have driving lines made for the track and their car. If you want to drive against AI with a new car or track, you need either to get a new driving line file from someone else or make one yourself. The driving lines are defined in the lap files under the ai directory. The game first tries to find .lap.gz, then .lap, then .lap.new.gz and finally .lap.new. If the file ends with gz, it is packed with GNU zip. You can get it from http://www.gzip.org/ but many other unpacker programs can open gz files, too. The unpacked version of the lap file is a text file but generating laps manually is virtually impossible. Below is explained what you should do instead.
To make new driving lines, you must run the game with the command line option "-airecord 1". See the bottom of this document on how to do this if you don't know. If you run the game with this option and drive a track alone without any AIs or other players, your laps are recorded. You will see text "AIRec" in the corner and all other laps but the very first one will be appended to file ai/<trackname>.lap.new.
After you have recorded a set of laps, you can open the file with a text editor and remove laps that were bad. A lap definition is started with "Lap" and ended with "End" so remove them and everything between them to get rid of the lap. The recorded laps of a session are ordered by time.
Note that if there already is a lap file, the new additions in lap.new are not taken into use until you either remove the lap file or append the laps in lap.new to it.
One big problem is that if you drive very close to obstacles, it is very probably that the AI drivers will often hit them. This is especially true with cars like Slider which require lots of sliding.
The AI can't follow the lines exactly and it will result in problems. There is a special command line option that can be used to test which driving lines are working.
If you run the game with "-lapdebug 1", AI Fill is 20 and an accelerated ghost race is driven. All laps are tested in order (ignoring LapClass).
Debug information about laps is put to output.txt and by searching lines which do not contain "coll: 0" you can find which laps caused the AI to collide on obstacles.
If you want to make your lines as good as possible, set AI skill to 5/5 and the number of laps to something big like 20, and then make the AI drive a race. Then, check output.txt, open the lap.new file and remove the laps that caused collisions. This can be very painful since some tracks can require you to remove many good lines and drive new lines until you finally find working ones. Try not to go very close to obstacles especially in inner curves.
About 10-20 laps per a track and a car is probably a good number. The default driving lines were usually done so that about 50 % of the laps are good ones and the rest get gradually worse. This way, the high skill AIs will get the best laps and the lower skill AIs get slower laps and more variation.
If the track contains jumps that must not be missed (like Westleap), you can set MinSpeedFactor by adding a line like "MinSpeedFactor 0.95" in the lap file. All driving lines that follow that line will be marked such that even bad AI players cannot have speed factor less than that.
This way, even low skill AIs should be able to get over the jumps.
If you are making driving lines for a set of cars for a track, it is usually best to work with one car at a time. Save the finished lap.new files for certain cars to different directories and finally, when every car is finished, combine them all to one lap file. If you want, you can then pack the file with gzip to save space (as was done with the default lap files).
RUNNING THE GAME WITH DIFFERENT COMMAND LINE OPTIONS
In Windows, there are at least two ways on how you can run the game with different command line options. The first one is to use command prompt (assuming Windows XP or similar):
- Select Start->Run... and write cmd.exe and press enter.
- Go to the Turbo Sliders directory, for example like this: cd "C:\Program Files\JollygoodGames\Turbo Sliders\" (or wherever you installed the game).
- Run the game by adding your command line options after sliders.exe. For example, if you want to use "-airecord 1", write "sliders.exe -airecord 1" and press enter.
Another possibility is to create a new shortcut of sliders.exe using Windows Explorer. To do this, go to the Turbo Sliders directory, right-click sliders.exe and select "Create Shortcut".
Now right-click the new "Shortcut to sliders.exe" and select "Properties". Now, add your command line parameters in the end of the target line. For example, make it like this:
"C:\Program Files\JollygoodGames\Turbo Sliders\sliders.exe" -airecord 1
Click Ok. Now you can run the game with the given command line parameters by double-clicking the shortcut. You can also rename the shortcut to something else, like "sliders_airecord.exe" to know what it is (and make new ones for other command line options).