Home Creators Posts Import Register Favorites Logout

Content

CHAPTER 98: The City That Pretends to Be Alive

No NPC of Los Santos was a person.

They were routines. Sequences of instructions that told a 3D model where to walk, when to turn, what to do on reaching a destination, and how to react if something unexpected happened. They had no memory or desires or the internal complexity of a being that thinks. They were actors on a stage who didn't know they were acting.

But they had to look like people. That was the only requirement: to look like it, not to be it. Because Los Santos wasn't a real world: it was a world that had to feel real during the 35 hours the player spent in it, and feeling real meant that the beings who inhabited the streets had to move with purpose, react with logic, and exist in ways the player could believe without effort.

George designed the NPC AI with the philosophy he had applied to every system of NGN: simple on the inside, convincing on the outside. The AI needed to be believable, not intelligent.

*

Every civilian NPC of Los Santos had a daily routine programmed in five steps.

Step one: spawn. The NPC appeared at a point on the map when the chunk loaded by streaming. It didn't exist before the player approached. It had no prior history. It was born from the hard drive when the streaming invoked it and died when the chunk unloaded. Its entire life lasted the minutes the player spent nearby.

Step two: destination. On spawning, the NPC received a random destination within its chunk: a store, a corner, a bus stop, a bench. The destination determined the direction of its walk.

Step three: walk. The NPC walked toward its destination along the sidewalk, following a network of navigation nodes George had designed as an invisible mesh that covered all the sidewalks of Los Santos. The nodes were connected by edges that represented walkable paths. The path-finding of each NPC calculated the shortest route between its current position and its destination using a simplified implementation of A* George had optimized to run in less than a millisecond per NPC.

Step four: arrive. On reaching its destination, the NPC executed a contextual action: sit on the bench if the destination was a bench, enter the store if it was a store (disappear from the map because the interior of the store wasn't rendered), stand on the corner and look at the phone if it was a corner. The action lasted between 30 and 120 seconds of game time.

Step five: new destination. After the action, the NPC received a new destination and started walking again. The cycle repeated until the chunk unloaded and the NPC stopped existing.

Five steps. The same structure for the five hundred NPCs of PC, the three hundred of Xbox, and the hundred fifty of PS2. The difference between a world that seemed empty and one that seemed inhabited was the number of NPCs executing these five steps simultaneously and the variety of the contextual actions of step four.

*

Each NPC had three properties that defined how it interacted with the world and with CJ.

The first was the type: civilian, gang member, or cop. The civilians walked, the gang members patrolled territories, and the cops traveled predefined routes in cars or on foot. The type determined the set of available behaviors.

The second was the aggression: a number from 0 to 1 that determined the NPC's reaction to danger. An NPC with aggression 0 fled on hearing a gunshot. One with aggression 0.5 crouched and took cover. One with aggression 1.0 drew a weapon and fired back. The civilians had aggression between 0 and 0.3. The gang members between 0.6 and 1.0. The cops had aggression 1.0 always.

The third was the reaction to CJ: a parameter that depended on the district, CJ's clothes, and gang affiliation. A Grove Street NPC with CJ dressed in green greeted him. The same NPC with CJ dressed in purple insulted him. A Ballas territory NPC attacked CJ if it saw him in Grove Street colors. A Hollywood Hills NPC ignored CJ unless CJ did something hostile. A cop NPC looked at him with suspicion if CJ wore gang clothes and ignored him if he wore a suit.

The three properties created the illusion of a city where each person had an attitude. The player who walked through Grove Street in green was welcome: the NPCs greeted him, made gestures of respect, moved aside to let him pass. The same player walking through Ballas territory was hostile: the NPCs looked at him with contempt, shouted insults at him, and finally attacked him if he stayed too long. The player didn't think in numbers of aggression or reaction parameters. He thought: ‘this neighborhood loves me and that neighborhood hates me’. And that was enough.

*

The NPCs' cars followed traffic rules George implemented as a finite-state system with six states.

Drive straight: the car followed a predefined lane of the road network at the speed of the traffic (40 km/h on residential streets, 80 on avenues, 100 on the freeway). Turn: on reaching an intersection, the car randomly decided whether to go straight, turn left, or turn right, with probabilities weighted by the traffic density in each direction.

Stop at red: the traffic lights had cycles of 30 seconds and the cars stopped with a braking distance proportional to their speed. Yield: if a pedestrian crossed the street, the cars stopped (sometimes: the probability of yielding was 80%, which meant one in five cars didn't yield and the pedestrian had to run, a detail George added for realism and that produced comic situations).

Honk: if the player blocked the traffic with his car, the NPCs waited 3 seconds and then honked. If the block continued, they tried to go around the player. If they couldn't, they stayed honking indefinitely with an increasing frequency that was the vehicular equivalent of an insult.

And flee: if the player fired near an NPC's car or crashed into it at high speed, the NPC abandoned the traffic rules and drove erratically to get away. The cars that fled ignored the traffic lights, invaded oncoming lanes, and sometimes crashed into other cars or into poles, which produced an emergent chain-chaos effect: a single shot could cause three accidents at an intersection because the cars that fled collided with the ones that followed the rules.

Tomás tested the traffic for a week and reported that the chain crashes were his favorite emergent effect in the game. "I fire once into the air at an intersection and in 5 seconds there are three crashed cars, a pedestrian running, and a streetlight on the ground. You didn't design that. It happened on its own. And it happens differently every time."

*

The gang members didn't walk. They patrolled.

George implemented the territory system with a map layer that assigned each block to a gang: Grove Street Families (green), Ballas (purple), or Vagos (yellow). The blocks that belonged to no gang were neutral. The gang members of each faction spawned exclusively within their territory and didn't leave it: a Grove Street gang member never walked to Ballas territory. If the streaming tried to put him there, the NPC redirected to the nearest border of his territory and patrolled the edge.

The patrols were different from the civilian walks. The gang members didn't go to destinations. They went to corners. They stood in groups of 2 to 4 at the intersections of their territory, smoked, talked among themselves with ambient dialogues the writer had written as fragments of conversation, and looked at the NPCs that passed evaluating whether they were friends or enemies.

If CJ entered Ballas territory dressed in green, the gang members detected him by two mechanisms: line of sight (a 90-degree cone in front of the NPC with a range of 30 meters) and clothing color (the system compared the texture of CJ's clothes with a table of gang colors). If both conditions were met, the gang member entered a state of alert: he looked at CJ, pointed him out to his companions, and if CJ didn't leave in 5 seconds, the gang members drew weapons and fired.

The border between territories was where the tension concentrated. George designed the borders as streets where both gangs had a presence: gang members in green on one sidewalk and gang members in purple on the other, looking at each other with the passive hostility of two groups that don't attack each other unless someone crosses the line. If CJ walked along the border, both sides evaluated him. If CJ fired, both sides reacted: those of his gang joined him and the rivals attacked him. The civilians who were on the street fled.

The territory could change. The Act 1 missions involved recovering blocks from the Ballas for Grove Street: completing a territory mission changed the color of the block on the map and the gang members that spawned there changed from purple to green. The player saw the transformation: a block that had been hostile became friendly, with NPCs in green greeting him where before NPCs in purple shot at him. It was the most tangible mechanic of territorial progression in the game.

*

The police of Los Santos were the most complex AI system in the game.

The cops didn't follow civilian routines or gang patrols. They followed response protocols that escalated with the player's wanted level.

At zero stars, the cops walked the streets or drove patrol cars on predefined routes. They detected crimes by two means: direct sight (if a cop saw the player commit a crime within his vision cone of 60 degrees and 50 meters) and civilian report (if a civilian NPC saw the crime and the NPC was of the "reporter" type, which was 30% of the civilians, the NPC simulated calling the police and the wanted level rose after a delay of 10 seconds that represented the time of the call).

The cops' detection cone was narrower than the gang members' (60 degrees vs 90) but their range was greater (50 meters vs 30). And the cops detected by sound in addition to sight: a gunshot generated an audio event with a radius of 200 meters that alerted all the cops within that radius, even without line of sight. The player could fire in an alley where no cop saw him and still get a star because the sound of the shot traveled farther than the walls blocked it.

George implemented the sound of the police detection with a simplified propagation: the radius of the sound was reduced 50% if there was a building between the source and the cop. A shot in the open alerted cops at 200 meters. A shot inside a building alerted cops at 100 meters. A shot with a silencer (a weapon obtainable in Act 2) reduced the radius to 30 meters.

"Do the cops have ears?" Tomás asked when he saw the sound-detection system.

"The cops have a vision cone of 60 degrees and a hearing sphere of 200 meters. The ears are a crude approximation of the sphere."

"So if I fire inside a building with the windows closed..."

"The sound attenuates 50% from the wall. But if there's a cop within 100 meters, he hears you through the wall. Because the walls of the Los Santos buildings don't block the sound completely. They muffle."

"And if I'm in a basement?"

"There are no basements in Los Santos. Just ground floors. I could add vertical attenuation but..."

"George, you're overthinking the cops' ears."

George stopped. Tomás was right. The sound-detection system didn't need to simulate the acoustics of a building. It needed to produce the sensation that firing in a zone with cops nearby was dangerous and that moving away from the cops or using a silencer reduced the risk. The system did that. The details of the acoustic propagation were engineering no player was going to measure.

*

At the end of October, Marcus finished the first real buildings of Grove Street.

Not the test cubes that had inhabited the space since the early days of NGN. Buildings. Houses from the sixties with stucco facades, windows with aluminum frames, front yards with dry grass and exposed dirt, bars on the ground-floor windows, awnings over the doors that cast shadows the lighting system calculated in real time.

Each house was different from its neighbors: Marcus had drawn the textures individually, varying the colors of the stucco (beige, cream, light gray, faded salmon), the condition of the paint (new on the well-maintained houses, peeling on the abandoned ones), and the details of each yard (a rusted tricycle here, a plastic chair there, a car on blocks next to a house that Marcus had drawn knowing that a car on blocks is the symbol of a mechanic who hasn't finished his project, more than of poverty).

George replaced the cubes of Grove Street with the buildings one Friday at eight at night. The swap was technical: changing the geometry and texture files in the chunk and reloading. But the result was emotional.

The cubes disappeared. The houses appeared. And Grove Street stopped being a technical test and became a neighborhood.

George drove the sedan down Grove Street with the buildings on the sides. The streetlamps turned on at sunset with their random delay. The shadows of the buildings cast onto the asphalt with the length of the six-in-the-afternoon sun. An NPC walked down the sidewalk with the five-step routine: spawn, destination, walk, stand on the corner, new destination. Another NPC crossed the street and an NPC car stopped to let it pass because it was of the 80% that yielded.

And at the end of the street, where the cubes ended in an empty space, there was now a house with a dry yard and a porch with concrete steps and a wooden door with peeling paint. CJ's house. Marcus had designed it as the best-kept house on the street but not by much: the paint was slightly better, the yard had a bush the others didn't have, and on the porch there was a wooden chair that suggested someone sat there to watch the neighborhood go by. It was CJ's mother's house. The house where CJ had grown up. The house CJ was coming back to.

George parked the sedan in front of CJ's house. He turned off the engine. He stayed looking at the facade through the windshield with the sunset painting the stucco of the house an orange that was warmer than the smog's because it was that of the direct sun on a wall that faced west.

Ten months of engine. Eleven systems completed. Two remained: the positional audio and the visual post-processing. And the cubes were a thing of the past. Los Santos had buildings. And the first building was the house where CJ was going to begin his story.

George got out of the car. The gray mannequin of CJ stood in front of his mother's house. The IK feet touched the porch steps. The legs bent to climb. The shadows of the streetlamps lengthened across the dry grass of the yard.

It was a home, not a pile of cubes. And it felt like a home because every system of NGN, from the lighting to the AI to the streaming to the suspension of the car George had just parked, worked together to create the oldest illusion in art: that what you're looking at is real.

End of Chapter 98

Comments

No comments found for this post.