Racing: Artificial Stupidity

Sports games have it tough. Whether it be Football, Hockey, Formula One or Tennis; attempting to virtually replicate a sport is a difficult business; especially when they are trying to do realistically. Today I want to focus on racing games for two reasons. Firstly, that is the genre closest to my heart; I am a passionate racer and enjoy attending motorsport events as often as I can afford. Secondly, I believe racing games have the hardest job of all when it comes to recreating the sport it is based on. The problem these games face is one of artificial intelligence. It is difficult enough to program AI that can set consistent and realistic lap times, so to try and get them to race as well is a nightmare scenario for any developer.

Let’s have a look at a typical case to illustrate the problem. Polyphony Digital’s Gran Turismo 5 couples an incredibly accurate and detailed physics engine with a huge variety of tracks and cars to race with. In terms of correctly replicating the feel and handling of the cars in its collection, the game does an admiral job. But Gran Turismo is a game played for the lap time, because the race AI is exceedingly poor. Opposing cars will tend to drive on rails around the track, keeping accurately to the racing line and, depending on the difficulty level, sometimes managing it with some kind of realistic speed. But when you send a move down the inside as you enter a braking zone, they will just turn right in as if you aren’t there. Getting a Gran Turismo 5 AI to move off the racing line without physically crashing into him is about as difficult as out-qualifying Sebastian Vettel; at the end of the day it would be a lot less hassle to not try in the first place. When push comes to shove, the Gran Turismo AI will overtake you by slamming you into a wall, and you’ll have to do the same to them lest they spin you out. This kind of thing forces people who want to race seriously to go online and face human opponents; if only your average online driver were as clean as the AI*!

*At this point it occurs to me an opportunity has arisen to advertise http://www.apexracingleague.com. Sign up for clean, exciting racing in all the latest racing games across all major platforms!

Let’s move on to one of my favourite racing games: (and I’m not just saying this because I work for Codemasters…) F1 2010. Although this is a game that struggles to get the AI lapping accurately around every track (the high speed turns 11 and 12 in Melbourne are a good example of where it struggles), the racecraft itself is a marked improvement on Gran Turismo. Where that game will simply take you out if you have the audacity to try and race, the F1 cars will give you a bit of space. As they head down the straight they will move to the inside to defend against you, but when you are alongside they will give you room. Although overtaking is never really particularly difficult as, if anything, they do not defend aggressively enough; each pass does at least feel like it was earned. AI overtaking you, on the other hand, is a rather different matter. Although it is admirable that the opposing cars give you room so as not to knock you off the track, they aren’t very brave either. I don’t remember a single instance of an AI driver out-braking me at the end of a long straight. Whilst I would be happy to put this down to my supreme driving talent; my position somewhere near the middle of my Apex Racing League division doesn’t really lend much credence to that conclusion.

So what useful points can we take from all these observations at this stage? Is it that the trouble with racing AI is it is difficult to find the right balance of aggression? Do developers shoot themselves in the foot by assuming that the players will not give AI drivers space to race if they attempt to overtake? Well…no. At least, whilst there are certainly elements of these points involved, the core issue lies at a slightly more fundamental level than that.

The problem as I see it is that AI drivers are unable to adapt when the conditions are less than optimal.

A race circuit is a difficult thing to navigate. There isn’t just one route as you might think; a racing drivers job is to get around that stretch of asphalt as fast as possible, and the way to do that changes on a second to second basis. Racing AI know where they need to brake. They know where to turn in. They know where to accelerate. But these are usually programmed as fixed points on a racing line, which is only good in optimal conditions. But what if entry speed is higher because the car has caught a slipstream, or been bumped from behind? What if they turn in and another car is in the way? What if they lose grip mid corner? The latter is something that very rarely happens to AI cars, and the number of control inputs a driver makes in any one corner would be a technical nightmare to program. Developers in such instances are forced to take certain shortcuts, which results in an AI car that handles problematic situations in a less than realistic way. Let’s have a look at a single corner from a driver’s perspective.

Full power. Approaching the braking point. I’ll try it a metre or two later than last lap, I can carry more speed than I got last lap for sure. Full on the brakes…downshift…tyre starting to lock – ease off the brake slightly…downshift again. Roll off the brakes and turn in – sweet. Pick up the throttle now, just at the apex. Gradually increasing power… back steps out – lift off the throttle slightly, a bit of opposite lock to control the slide and regain traction. Back down on the power gently but firmly…more…upshift, full power, drift to the kerb out wide. Upshift. Touch the kerb – too much! Back loses grip – ease the power and counter-steer. Traction returns, back on the power.

All that happens in the space of a few seconds, and assumes optimal conditions on a dry track. When the grip is lowered because they are following another car closely, or it is wet, or they have been off line and picked up some debris on the tyres, then it becomes much more difficult. And it is all these subtleties of any given handling model that the AI can’t get their artificial heads around.  When they are defending a position by going off-line, they brake far too early to be sure to maintain control. A real driver would brake as late as possible, try and slow right down on the apex to stop his opponent from turning in, then on the power as early as possible and simply try to hang on to any sliding or other problems that may occur.

One other issue is their lack of racecraft. Whilst in certain games like F1 2010 you do get the AI trying to defend their position and, to a less successful degree, try to overtake, they can never plan ahead. If I am in a racing car and trying to get past the guy in front, I will force him to defend the inside line. Then I’ll move to the outside line and brake early. As my opponent struggle to slow the car down and turn in to the corner from the tighter line, I will take a late apex, get on the power early and cut back underneath him. Some drivers plan overtakes laps in advance, forcing their target out of position a little more in each corner until they finally create an opening big enough to strike. Racing AI lacks this ability to plan and adapt to the movements of cars around it, and this is why it struggles to be successful.

So what are the solutions? Well, unfortunately there is no easy one. The less complicated the handling model of any given racing game, the easier time the AI has adapting to events that occur during the race. Look at something like Mario Kart – sure the physics aren’t exactly at the level of iRacing, but the AI is competitive (albeit selectively competitive due to a catch-up system) because even if the player rams the AI car off the ideal lines, it is much simpler in that kind of game to calculate a new route and keep to it without losing too much speed. The result is constantly close racing and, whilst you wouldn’t exactly call any Mario kart racing ‘clean’, it is at least fair-ish on an equal footing. For more ‘realistic’ games such as Gran Turismo, Forza and F1, I would personally consider having completely separate AI routines for ‘lapping’ a track and ‘racing’ on one. Whenever a human player is close enough, the AI would switch to racecraft mode, with the focus lying on maintaining track position when defending or overtaking on the inside, or maximizing exit speed/using the cutback if the player is defending.

I don’t think the challenge of creating some additional racing lines, specifically to use when in ‘racecraft’ mode and thus fighting with human players, is insurmountable. The problem with race AI as it stands is that it doesn’t want to be off the racing line, and gets confused when it is. The solution to this, or at least an improvement to this, would be to program unnatural racing lines as if they were natural ones, and the line picked by the AI would be dependent on the situation. This would make it more effective when it comes to overtaking or maintaining a position, as the designers could instruct the AI to brake late on the inside, or early or brake and turn in early on the racing line if the player goes defensive. Although the same problems of adapting to the situation when something unexpected occurs (such as contact, or less available grip than expected), it would at least allow clean drivers in typical race conditions to have a better race with AI opponents.

- Luke

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 85 other followers