Difference between revisions of "GPL Track Creating - AI"
(Created page with '''Authored by Ed Solheim'' '''To make AI-files for GPL you need this guide and 7 other things:''' 1) A driveable track. 2) RPY2LP by Nigle Pattinson [available at www.t...') |
|||
Line 85: | Line 85: | ||
This record shows that: | This record shows that: | ||
− | + | *the car's speed is 154.024 mph. (80*1.9253 (value = meters per tick) | |
− | + | *lateral speed is 0.0571 meters per tick (could be 4.568mph (i.e 80*0.0571) | |
− | + | *the car's [centre] posistion is 0.1838m to the left of the track centre-line (positive vaule is always on the left-side) | |
− | + | *yaw-velocity = 0.0002 radians per 1/36th of a second or tick. | |
− | + | *the waypoint or flag to tell the AI that a long straight is ahead. | |
Latest revision as of 20:48, 5 May 2009
Authored by Ed Solheim
To make AI-files for GPL you need this guide and 7 other things:
1) A driveable track.
2) RPY2LP by Nigle Pattinson [available at www.theuspits.com]
3) LP-Edit by Frank Dubuc [available at www.simcyberworld.com]
4) The TRACK.INI GUIDE by yours truly.
5) A spreadsheet program such as Excel.
6) A good, clean and preferably fast driver.
7) Last but not least - plenty of time!
Contents
Track
It's important to notice that the number of records in the lp-files is dependent upon the length of the track. Should the number of records in the LP-files be incorrect, GPL will simply ignore the files completely and you'll end up with the AI's "coasting" around the track [in the middle of the road] at 40mph or so...
GPL uses 1 record per "tick" [1 "tick" = 1/36th of a second], so if you change the track-length you're screwed and have to start making these files all over again. This is why I always wait until the last possible minute [prior to release] before I make the LP-files for the AI's.
Another thing to point out is that everything that will have an influence on laptimes or speed should be finished before you go and make these files. Things such as elevations, track "camber", surface-types etc. all determine what sort of pace you can keep at any given point on the track, and small changes in these areas can have a great influence on speed - so you should wait until these bits are "set in stone" before you go on to make the [final] version of the AI's. I say 'final' because - it doesn't hurt to practice :)
LP Files
The LP-files you see in each track-directory are used to control the AI's behaviour. GPL use 6 such files:
Race.lp:
This file controls the speed and line the AI's use for "normal" driving/lapping ["alone"]around the track.
Pass1.lp:
Controls the AI's line and speed when passing [and possible being passed (on the right-side)] a car on the *left* side of the track.
Pass2.lp:
Controls the AI's line and speed when passing (and possible being passed (on the left-side)) a car on the *right* side of the track.
Maxrace.lp:
Defines the left-most "edge" of the track. Used by the AI's to determine where they can drive if the road ahead is blocked etc. Also for SHIFT-R resetting (more on this later).
Minrace.lp:
Defines the right-most "edge" of the track. Used by the AI's to determine where they can drive if the road ahead is blocked etc. Also for SHIFT-R resetting (more on this later).
Pit.lp:
Controls the line and speed AI's use when exiting and entering the pits.
File Structure
Each LP-file contains X number of records [one for each "tick"] and each record has 5 fields of data. These are [in correct order]:
1) Longitudinal speed
2) Lateral Speed
3) Lateral Position
4) Yaw Velocity
5) Waypoints (or "flags")
If you convert an LP-file to text and open it in Notepad, the records will look like this:
1.9253, 0.0571, 0.1838, 0.0002, 16
This record shows that:
- the car's speed is 154.024 mph. (80*1.9253 (value = meters per tick)
- lateral speed is 0.0571 meters per tick (could be 4.568mph (i.e 80*0.0571)
- the car's [centre] posistion is 0.1838m to the left of the track centre-line (positive vaule is always on the left-side)
- yaw-velocity = 0.0002 radians per 1/36th of a second or tick.
- the waypoint or flag to tell the AI that a long straight is ahead.
Way Points or Flags
Meaning | Hexidecimal | Decimal |
Passing Checkpoint | 0x01 | 1 |
Set Checkpoint Speed | 0x02 | 2 |
Outbrake Decision Point | 0x04 | 4 |
Clear Passee | 0x08 | 8 |
Start Long Straight | 0x10 | 16 |
End Long Straight | 0x20 | 32 |
Unknown | 0x40 | 64 |
Clear Waypoint Hype | 0x100 | 256 |
No Pass Zone | 0x200 | 512 |
Clear No Pass Zone | 0x400 | 1024 |
Tire Warmup | 0x10000 | 65536 |
Hype Modifier | 0xFF000000 | Big! |
A quick run down of the various flags:
PASSING CHECKPOINT:
Always seems to be followed by another flag, so I assume this tells the AI to prepare for an upcoming flag. Could also be that this infact tells the AI's to "pass here".
SET CHECKPOINT SPEED:
I assume this is used by the AI's to check their pace/speed compared to the information in the LP-file.
OUTBRAKE DECISION POINT:
Used to define outbraking zone.
CLEAR PASSEE:
Normally used after (or just inside) a NO PASS ZONE.
START LONG STRAIGHT:
Tell the AI's that a long straight is ahead. Probably to encourage slipstreaming.
END LONG STRAIGHT:
Used at the end of straights - see above.
CLEAR WAYPOINT HYPE:
I assume this is used after a HYPE MODIFIER zone.
NO PASS ZONE:
Self-explaining.
CLEAR NO PASS ZONE:
Ditto.
TIRE WARMUP:
Due to the fact that the AI's in GPL use a much simpler physics engine than the players, the AI's do not actually generate heat in their tires. Thus the need for a flag to increase the heat in their tires. This flag is normally deployed every 400 records (depending upon the track) or so. Then the AI pass this flag - its tires will be heated up to the next level. This continues until the tires reach their optimum temperature - after which the flags will be ignored.
HYPE MODIFIER:
The HYPE MODIFIER is used to speed up the AI's at specific places around the track, probably at places where they are too slow etc. So if you make some AI's and they turn out to be abit slow at certain spots you can use this modifier to speed them up. The modifier is scaleable - ie. you use the two topmost bits to adjust how much faster you want to make them. So, one hype modifer can look like this: 0x02000000 (this only sped them up a "tad") or you can make one that looks like this: 0xDF000000 which make them go a lot faster. The MODIFIER must be present in all the records you want to "speed up" (look at the Kyalami AI-files and you'll get the idea).
The HYPE MODIFIER can also be combined with any of the other flags -like this: 0x3C010000
(MODIFIER and TIRE WARMUP) or 0x08000400 (MODIFIER + CLEAR NO PASS ZONE)
PLEASE NOTE: The MINRACE, MAXRACE and PIT.LP files DO **NOT** NEED ANY WAYPOINTS OR FLAGS IN THEM AT ALL!!
How to make LP-files:
You convert replays to LP-files with RPY2LP. Note that each lap must be a complete lap - i.e . you must pass the start/finish line *twice*. To give you an idea.. this is how I make them:
MAXRACE.LP:
Use one of the widest cars in GPL (Lotus or Eagle). Drive a complete lap of the track along the left-side of the aspahlt. I also move a little away from the track-edge when driving along the outside of a corner. Speed is 30-35mph as this is the speed the AI's use when they "limp" back to the pits after a breakdown etc.
MINRACE.LP:
As MAXRACE, only that this time it's along the right-side of the track.
PIT.LP:
This lap has to start and end in the pits. I do NOT suggest that you stop in the pits or just start from the pits when doing this lap. Do one lap first... then drive into the pits and thru it at 10-15mph, then exit the pits like one normally does. Drive around the track and then enter the pits again, like if you were pitting. NOTE: all of this depends upon *where* the pits are situated in releation to the S/F-line.
RACE.LP:
This is the file used for "normal" driving/racing. Make this out of a normal "hotlap" - where you drive the line and speed you normally would in a race.
PASS1.LP and PASS2.LP:
Now this is where it's getting tricky. The quality of the AI's ability to race both humans and each other, depends upon the "quality" of these files. It might look like there are various ways to make these. If you look at the original tracks, you'll see that on some tracks the passing line is made by just driving on either side of the normal line throughout a whole lap. And on a few other tracks the Lateral-position in these files will revert back to the normal [race.lp] position after a "passing move". Drive a complete lap of the track at race-pace using the line you would for passing on the left-side [for pass1.lp] and one lap using the line you would for passing on the right-hand side for the pass2.lp.
Getting It All To Work
Now that you've made all the replays for the lp-files.. you need to convert them using RPY2LP. Once you have them converted, either use LP-Edit to add flags etc. or better yet, use LP-Edit to convert the LP-files to Text, and then use Excel etc. for the flags.
Please note that in LP-Edit you need to enter the flags as Hexadecimal. If you convert the files to Text and use Excel etc., you will need to add the flags using Decimal formats. If you want to add some hype-modifiers into the files, I strongly recommend that you use LP-Edit for this task as adding them as Hex is much easier than Decimals.
Also, when exporting or saving the files from Excel, they must be saved in a *comma-separated* text-format for LP-Edit to import them properly.
Now all you need is plenty of spare time to get these damn things to work!
More Helpful Hints
When creating AI's for "add-on tracks" you might run into a few problems:
On some tracks you'll see that the AI's you create seem to drive badly through chicanes and esses etc. Sometimes they will also seem to be somewhat "out of sync" at the latter parts of the lap. I've found that on most tracks, and especially those where RPY2LP has to "estimate" the number of records needed for the files, the first record in the LP-file will be based upon data from what really should have been the last record in the file. You can easily spot this by comparing the data in record #1 and #2 or #1 and the last record in the file. This actually causes the AI's to be somewhat "delayed" in their behaviour, and this problem seems to grow the further into the lap they get. Moving the first record to the end of the file seems to fix this.
Another thing worth mentioning is that you should make all the LP-files (based on correct replays) before you start to adjust or edit them. Sometimes I've been working on small problems for hours, only to find them being fixed by adding correct pass1/2 - files.
I also strongly suggest that you use LP-Edit to explore the original LP-files that came with GPL. There are plenty of things to learn from them.
I also suggest you get hold of my TRACK.INI SETTING GUIDE, as this will give you all the information you need for the TRACK.INI.
Help, RPY2LP wont let me convert the replays!
GPL trk file seventh surface value not zero:
Some add-on tracks have additional information in their trk-files. Contact the author of the track for a "clean" version of the trk-file. (Track creators: Please contact me or the GPLEA for converting and "cleaning" of these files.)
GPL trk file section start error:
Only applies to add-on tracks AFAIK. This is caused by a start mismatch in one or more of the track sections. Again, contact the authors of the track. (Track creators: Please contact me or the GPLEA for converting and "cleaning" of these files.)
Happy editing!!
Updated 30-Dec-2000
Transferred to the wiki: 23.04.2009