Post-Play'em - Observations on Game AI

Posts Tagged ‘racing’

Mario Kart: Double Dash

Friday, November 9th, 2007

Over the past 4 years, my family has spent way too much time playing Mario Kart: Double Dash. Given that my kids are teenagers, we billed it as “driving lessons.” Only one of them has taken the wheel rather than the controller pad since that point and we have yet to see any ramifications (if you will pardon an obvious homonymic pun). However, there were times when my wife and I would feel an overwhelming need to swerve to avoid a non-existent red shell or banana peel. At that point, you begin to realize that you have played a game too much. Which had about the same effect as me realizing that I need to lose 20 pounds – it’s nice to acknowledge it, but changing the behavior is something else entirely. Which is why we continue to have family fests and beat the snot out of each other to the ultimate climatic moment of Rainbow Road.

Anyway, many years of playing the game have taken another toll on me – I have not been able to stop myself from making mental notes about the AI and the game design decisions that went into making it tantalizingly addictive. I even mentioned as much to Steve Rabin, Senior Software Engineer at Nintendo of America, while we were having a beer at one of the ubiquitous evening fests during GDC in 2003. If you have ever met Steve, you know that he would make for a fantastic poker player in his ability to not show a reaction. Therefore, I have little idea if the observations and conjecture I made about the DD AI at the time were even remotely close. I would like to think, however, that there was a twinkle and a smirk. Of course, I have no reason to believe that Steve was even involved in the development – perhaps he was just amused at my enthusiasm.

Anyway, here are some of the observations that I made over the past few years. (Has it been that long?) Forgive me if I get either too simplistic or too esoteric…

The State of Racing…

One of the obvious characteristics of the AI is its use of FSMs. This is something that is in use in most games today on some level or another. However, there were some distinct points where it was very noticeable that the AI was switching. For example, once you crossed the finish line, your team either went into “celebrate” mode or “whiny pout” mode. These were simply repeating animations that continued throughout the duration of the post-race promenade (for example, while you are waiting for your wife to finish because you left an ocean of banana peels for her to wade through causing her to look strikingly like Kristi Yamaguchi doing non-stop toe loops down the final stretch). However, if you are to get whacked in the behind by an errant shell, you will immediately transition into the crash state, then the “stunned recovery” state for a few cycles of the animation (about 2 seconds). Then, magically, you will begin to celebrate once again. It makes it very easy to see that there are very defined edges to the states (and likewise the animations).

The major states, then, seem to be as follows:

  • Pre-race
  • Driving (with occasional sub-animations)
  • Toting and throwing items
  • Crashing (various types)
  • Recovering (such as dragging along behind the car)
  • Post-race victory or bitching

There are some sub-states mixed in there for the more subtle animations, but they are usually very short-lived. The driving mode, especially, has extra states for turning, sliding, punching, taunting or even just looking around because there’s nothing going on.

One side effect of this is that the animation will get slightly muddled, for example, when you have multiple collisions in a row (especially in a tunnel). The way they get out of this is to give up trying to transition properly and simply reset the car on its wheels. It makes for an awkward flip

To Drive… the Invisible Path…

The AI racers don’t necessarily navigate freely along the track. They follow the technique of using invisible paths laid over (under?) the course. There are multiple lines on any given track and the AI will choose which one to follow at any one time.

The reason that this became apparent to me was the first time that I saw two opponents in front of me fighting for the exact same stretch of road. There was more than enough room for them to maneuver, but they insisted on being in the same spot for some reason. What’s more, that “spot” was meandering back and forth along the course… as one car drifted left, the other went right along with him. As they drifted back, they did so together like Ben Hur’s chariot trying to dice up his competitor’s wheels. Not only was the path dumb and the colliding dumb, they were being dumb in sync with each other. Solution? Put a repulsion vector on each other so that following the path is not as high a priority as keeping from scraping paint.

I’m not entirely sure what causes the AI to switch paths. Obviously an event like a spin or crash would cause the AI to pick up a new line. However, it is difficult to tell of the AI changes lines when nothing else is happening – like a cross-country skier stepping into a new pair of tracks. This does, happen, however. I’m just curious as to when and why. Certainly not when they are bumping and grinding down the straightaway, however.

There is another factor, it seems, behind why the paths are the way they are. Not all paths are created for all cars. If the AI is in one of the big heavy cars, for example, they will tend to pick a path that wanders back and forth across the track. This is very noticeable with Wario’s purple beast. He drives like he has imbibed heavily. This is an interesting balancing mechanism – Wario’s car, like other larger cars, is fast once it gets up to speed. If that were left unchecked, once he passed you, he would be a bitch to catch up with. However, if that speed were spent meandering all over non-optimum lines, it slows down his progress and makes for a neat stylistic appearance as to what we get out of ol’ Wario’s character. It is difficult to know what exactly is happening behind you in the race except on such short tracks as Baby Park. Does Wario drive like a drunk moron when he’s 3 places back or only when he’s in front of you?

That brings me to another point… rubber banding.

The Search For Equality…

Rubber banding is one of the most misunderstood aspects of Double Dash – and probably many other games that utilize this technique. Really, it is also a point that blurs the lines between AI, simulation modeling and the basic game design decisions. There is a staggering amount of this going on in DD.

First there is the speed of the cars. In general, when you start a new “Cup” (group of races) and the game “picks teams”, the AI will also assign a general skill level for each car. Throughout that cup, the running order will generally be the same give or take a couple of places. The same 2 cars will generally be in the top 3 and the same two cars will generally be in the back of the pack. This is obvious after having finished a 16-race cup and having one car have a single-digit score – which is only possible if you are continually finishing either last or 7th. Also, if you are a trained professional like I am (I have to look into some form of Mario Kart accreditation or certificate), you will realize by about the 2nd lap of Luigi circuit which of the cars you will have to put up with for all 16 races. [misc. editorial rant: Damn big, fat Peety-head!]

There seems to be three ways they go about stringing out the pack like this:

1) By simply using the published speed of the cars. The fast cars will tend to be toward the front, whereas the putt-putt-mobiles will be in the rear. That means that those first two cars you have to contend with as a good driver will be the big, fast cars.
2) By varying the published speed of the cars. Just because two cars are 3-star speed, doesn’t mean they will always go 3-star speed. This is good in that there are more speeds in practice than the 5 possible stars that the cars are rated at.
3) By varying the time they have their “foot on the gas and brake”. Again, this is visible on Baby Park when you lap someone. If you watch, you will see them move forward in fits and starts as if they are only “hitting the button” intermittently. It’s a nice effect that makes them seem unsure of themselves.

However, the above isn’t rubber banding – it’s just spreading out the pack. As you improve in your skills throughout the game, you will notice that you will usually have a fair amount of company… within reason. If you stop dead in the middle of the track for a minute, don’t expect the AI racers to be sitting around having coffee waiting for you to catch up. However, there will be some noticeable slow-down of the entire pack. Likewise, if you are good, the whole pack will be slightly better than normal. One way of noticing this is if you have two human players of differing ability. You will see such things as the pack stringing out more than usual to accommodate the different players, the lead player running away with the race as the pack holds back or the poor player getting completely skunked as the lead player pulls the pack along with him. I’ve spent too much time racing and not enough time testing this phenomenon, however.

Another method of rubber banding is one that people refer to as “cheating.” (This is likely because it is frustrating… imagine that.) If you are in the back of the pack, you can plan on getting better “stuff” from the boxes. If you are in last, you will be fed a steady diet of mushrooms, stars, lightning bolts and blue shells. If you are in front, however, expect to get green shells, fake blocks and the occasional potassium fix from bananas. It should come as no surprise, therefore, that the AI racers in the back of the pack are the ones getting the lightning bolts and the blue shells. (One note, it IS possible to have a blue shell by accident when you are in front… which means you get to hit yourself with your own blue shell!) If you watch on Baby Park, or keep your eyes on who is the one not getting zapped by the lightning bolt, you will see that the AI is getting much the same load of goodies that you are. I concede that it is possible that they are getting more aggressive stuff, but it is not outright “cheating” in the AI sense.

Now, there does seem to be a change in that algorithm as the race progresses. If you are in last on the first lap, there isn’t as much of a sense of urgency. If you are in first on the first lap, you won’t be getting assaulted non-stop. However, in both of those positions, things seem to change as the race wears on. If it has been smooth sailing for the first two laps, you can expect to have attracted a bit of attention on the third one. Perhaps it is this phenomenon (and the resultant indignation that ensues) that causes people to cry foul. However, once you have been in the position of playing catch-up on the final lap, you will realize that the game is more than happy to dispense one killer weapon after another in order to help facilitate retribution upon the AI. This is even in play on a multi-player race without the AI even being present. So again, this is a game design decision in order to further exciting races.

In the Pursuit of High Drama…

A couple of notes on artificially generated excitement… I can’t tell you how many times (probably because it is now into 4 digits) I have been on the final lap, in 2nd place and within striking distance of the 1st place car, but seemingly without hope… and it has driven straight into the only banana on the entire planet. It is almost as if the AI has gone out of its way to encounter the treacherous fruit leavings! Sometimes that is enough for me to make that last pass to win. Other times it is only enough to make the ending that much more exciting. Is the AI hitting that banana on purpose? Is it simply that the object was dropped onto one of the invisible paths? Does the AI drop objects onto the paths on purpose? This I can’t tell you.

Another observation I have made in this vein is that things that green shells don’t seem to have studied for their Physics 101 final. I swear that green shells, upon hitting walls or other obstacles, will uncannily bounce so as to cross in front of you. It happens too often to be coincidental. Similarly, I have seen green shells bounce off of objects at unlikely angles to strike the AI car in front of me a la the “lone banana” phenomenon above. I know that this is not a hard computation to make… just a little quick vector math based on the path of your car. Therefore, it is my estimation that this is a subtle trick to make the game environment a little busier in the right way. Make it look like things were really dangerous – especially when my back-seat sister forgets what she’s doing and throws green shells forwards instead of backwards.

Things That Work…

In general, Double Dash is a very well done game from the point of AI. I remember way back when we started, I never felt hopeless (until I hit Rainbow Road for the first time and fell off so many times I started laughing until I cried). On the other hand, now that I can’t even beat my own best times any more and have therefore maxed out my own (rather capable) abilities, I still run the risk of not finishing first on some of the races. I prefer winning games only about half the time, and, even after all these years, Double Dash hasn’t slumped back into the role of being a pillow for me to beat on mercilessly. While I tend to finish first on most of the races (80%?), getting a perfect 160 is still a goal rather than a given. I attribute this to the excellent rubber banding in the AI and design decisions.

The characters use their weapons well and intelligently for the most part. The driving makes sense, even when it wanders around the track. The character animations are engaging and amusing at times. (Being a Yoshi player, I am always tickled when he stands on the back of the kart looking “vigilant” glancing left and right to see what’s up.)

Things That Could Improve…

Sometimes, I wish that the AI states were just a little more obscure. It isn’t distracting or annoying, but I want there to be a little more subtlety to them. This is not that big of a deal, however, especially since we aren’t dealing with life-like, human characters. The effect goes quite well with the cartoony feel that is a trademark of the Mario games.

All in all, for the style of game that Double Dash is, the AI worked very well. Otherwise it wouldn’t be one of the top Game Cube games in the history of ever… still. And I wouldn’t still be playing it!

So… is there anything that you have experienced that I may have missed? Is there anything I said in here that is completely out of whack? Drop in a comment! One thing I would be very amused to find out is that I have chalked some effect up to the AI when it wasn’t really there in the first place. Now THAT is the sign of a good design (or an AI programmer who wants to believe in things waaayyy too badly!).