There are loads of methods of making a race game AI. Which one is best depends entirely on your game and also, to an extent, where your strengths as a programmer are.
In some of my early race games from when I was a kid I made a picture template of the race track and on each pixel I placed a coloured dot for the direction I would like the AI's to be if they where on that part of the racetrack. Red might be true left, red with a bit of green might be left and down just a little bit. This made accident recovery very good no matter where the cars ended up, but the only deviation in the racing line was from minor changes in the cars physics such as acceleration speed, top speed, turn speed etc. It's great for 2D racers.
Other methods might be to store checkpoints in an array as you have suggested, or you might also use limbs on the track object and read off their position.
You could also use object intersection to test for line of sight and have the AI calculate a racing line on the fly. That might sound slow but actually it isn't. With just three object intersections you could read off everything the AI can see and calculate where it wants to be heading. It would only work if the track was walled. It wouldn't be my choice of method, but it could be got to work.
One change I would make to your system is not to check *every* checkpoint in order for the AI. If you have anything like a racing line setup on some bends you could easily skip a checkpoint. Instead just pick a few that are on straits midway down.
Another option is a bit like the first. Make a little editor to view your track, make an array that breaks the track down into small areas. So if you track is 2000x2000 in 3D size you might make an array that is 100x100 where each value represents a 20x20 area.
Now set the ideal facing for each area. So if the AI is in square 1,1 (top left corner) he would want to be facing bearing 135 (down right).
This method requires lots of data, but less calculation in real time because you have already precalculated your entire movement path no matter where the AI ends up.
Rather than using checkpoints you could also do ghosting. Record your x,z position as you yourself drive around a lap and have the AI's copy that. You could enhance this further by having several ghosted laps that they can follow, or by letting them experiment with a few of the recorded positions by trying adjusting a few checkpoints subtley and comparing the laptimes so that the drivers learn what is faster and what isn't.
There's probably a few more possibilities as well, what it all boils down too is how you have constructed your world and where your strengths as a programmer lie.
Pneumatic Dryll
