Wednesday, February 24, 2016

The Complexity of GTA V

I've been playing Grand Theft Auto 5 for about 80 hours now. I've beaten the game on story mode. But when I first started playing, was was absolutely blown away by the graphics and the amount of just pure stuff that was in the game. People talk to each other and interact on the streets, buildings are more than just storefronts, the island is a gradient from wealthy to poor, etc. But it got me thinking, how do certain things in this game actually behave? Is it random? Or is there some basic AI behind it? I decided to find out.


I started by following a single car. The car just looped around my starting point, Michael's home. However, after accidentally tapping the car a few times, the driver seemed to want to get away from me as quickly as possible. She began to speed up, driving through red lights, around cars, and often in the on-coming traffic lane. The chase concluded with her running into a food truck, her getting out, and then I lost her on foot. When I got back to the road, her car was gone. Here's the path she took from start to end:
I wanted to see if anybody else would do the same thing, so I followed another car. Unfortunately that car drove into a parking lot and was freaked out by either me or the sirens around the area (people were trying to steal cars), so drove off of the parking lot and into the mall-type area. He couldn't drive out, so he got out and ran down the steep hill on foot. He was able to go faster than I, so he almost got away. I took a bike and caught up with him but he had calmed down. This behavior was really interesting. I tailed a third car just to be sure that this was indeed what was causing it. Alas, he did not notice me behind him. The panic kicks in when you hit their car more than twice. They get out of their car when they can't figure out a way to drive away. If their car goes out of sight, the car disappears (and so does anybody inside, only the driver gets out.)

The next thing I wanted to test was to see was what happened when the police were done with a crime? Or what happened to the criminal if they beat the cops. I drove around listening for sirens until I finally found some. I followed a cop car grind its nose off in the back of a pickup truck. The police won, so I decided to follow this single cop car to see how much more damage it could take before exploding, and what would happen when it did. The cops had to find only one more chase to make the car explode. When the car was ready to blow, the cops got out and one of them stole a civilian car. The loud speaker was still thing and the cop left his partner both before and after the shootout. After the solitary cop won, he left in the stolen car because the cop car had disappeared. The cop then began pursuit of another vehicle, but with no lights or sirens. Just the loudspeaker. In the course of another shootout, the cop fell down into a place he couldn't recover from. He just stayed in his car and continued to try and get out by driving up the hill but he was stuck. If it weren't for me irritating him, he would have been deleted. But he got irritated with how close I was and shot me dead.

I wanted to see if this behavior of driving around aimlessly until we find a target applied to the fire department and the paramedics. Unfortunately it doesn't apply to them.

I decided to open the game up and see what kind of stuff I could find. Just poking through the data, I found loads of XML files that contained stuff like reactions to behaviors, group interactions, almost anything. But what I was really after was the textures.

I found a whole bunch of them, basically. It's ridiculous how much art went into this game. I pulled out some things that I found interesting.


Here, we have the animation frames of the raindrops as they hit the ground as well as the distortion they cause in the surrounding environment. I think this is really neat, as I have never seen this kind of thing done before. I always wondered how even the smallest of detail was correct. Turns out this is how.

Another interesting thing is how they do the car sounds. This is probably common practice and should come as no surprise, but GTA V (and most racing games) use sound grains to create the sounds of a car. So, for example, if you're speeding a vehicle up, the sound plays through, then if you stop speeding up and maintain a perfect acceleration, then it repeats a short section of the sound. When you decelerate, another sound plays with the deceleration noise. GTA V doesn't have specific car noises, rather each car has a category and uses those sounds (4 Cylinder Sports Car, etc.)

The radio also has a ridiculous amount of work put into it. The hip hop channel alone has 14 station identification tracks, 21 DJ interjections for between songs, and 60 different song introductions. There are also 132 sounds for breaking news. Then you have the voice acting for characters. It's divided up by role and by race. For a single white cop (there are 4 sound sets to chose from), there are about 200 short phrases for him. 

There is just too much for me to go over in this one blog entry. So if you want to look into what GTA V's resources look like, grab a copy for PC (it's worth it if you haven't played it) and grap "OpenIV" which can read all of the resource archives. Everything pictured here belongs to Rockstar Games, all rights go to them and their awesome game.

No comments:

Post a Comment