Traffic AI Finished

I finished this project a while ago but I never actually posted about it.

This was the AI Masterclass Project where EA Ghost Games set a brief. The task was to create a scalable, autonomous traffic system in Maya using python script which demonstrated the following behaviours:

  • Emergency stop
  • Swerve to avoid
  • ┬áStop, recover and drive away
  • Panic
  • Spin out and crash
  • Low speed drive round obstacle

I chose this particular project because this year I’ve taken a turn in what I want to actually do in the industry, and decided on a more technical art route in games. This is why all my projects this year are much more technical, and AI is something I knew before we had the briefs I was going to do. I hadn’t done any scripting since first year and even then it was a simple bookcase generator so this was going to be a big personal challenge.

Here’s the video of playblasts I submitted after the project was finished to demonstrate the behaviours.

The first clip is all the behaviours working together, and for the others I either isolated behaviours to just demonstrate one, for clarity, or for the swerve video I increased the likelihood that cars will randomly panic and swerve into a crash.

On the surface this doesn’t look like a very exciting project, but I’m quite happy with the outcome. Mainly because of the personal improvements along the way. I started out trying to make an A-star pathfinding program. Once I’d made that I realised it wasn’t what I needed, so I tried several other routes all with varying levels of success until I settled on a flocking system approach. The cars act like boids in a flocking system, so their velocities, forces and mass dictate where their next position will be and this is updated using expressions in Maya. They are confined to the grid generally so will usually be seeking a point to the next junction, this will be overridden when another car is detected (using distance and FOV), or if they come to a traffic light and the car will act accordingly.

The most fun thing to add, which I did at the end, was the swerve behaviour. I’d experimented with just increasing the force and changing the velocity to the opposite of the collision which worked reasonably well, but in the end I made each crashing object an active rigid body in Maya upon impact with initial velocities and trajectories matching its current, boid parameters. This made the program a lot more fun as I could increase the likelihood of a random swerve and the cars would start flying all over the place.

About these ads