Game Development Community

Be the Dinosaur - AI Postmortem

by James Ford · 05/24/2008 (2:12 am) · 18 comments


Be The Dinosaur
AI Postmortem


farm3.static.flickr.com/2208/2516680917_055d79d5e3.jpg


This was originally going to be a blog post but it got way, way too long. For the complete pdf doc, click here. The rest of this post contains no information not in the full version. Go ahead and click it.

Introduction

Be The Dinosaur (BtD) is a museum exhibit featuring an interactive simulation in which the visitor takes first-person control of a dinosaur in the late Cretaceous period. The exhibit may contain 1 - 32 machines together on the same network. Currently the two playable dinosaurs are the Triceratops (trike) and Tyrannosaurus rex (trex). Visitors will interact with each other in the simulation and with AI controlled dinos (DinoAgents). The most important activities are finding food, water, and defending yourself from other dinos.

This project is produced by Eureka Exhibits and developed by us at Sickhead. The Sickhead team consists of Tom Spilman, Russell Fincher, Ross Pawley, and James Ford (me). We began work on this project October 1st; 2000+ svn commits and 7 months later we emerge having finished the first project phase.

The focus of this paper, however, is the ai in BtD. Serious work on the AI began ~February 25, 2008. This paper reflects work done from then until May 19, 2008. This means approximately 2.5 months of full time work by an individual (me) was done for the BtD AI as it is now.

Reasons for this Paper

  • Spend some time reflecting on what we have done, and what to do next.
  • Let the community know what we are up to here at Sickhead.
  • Give something back to the community; there might be something useful for you in here.
AI Development Cycle

The first BtD museum exhibit opened on Feb.3, 2008. At that time there was no dinosaur AI except for a random wander behavior which did not perform pathfinding or obstacle avoidance. Since multiple players were not always available and not reliable for "modeling correct dinosaur behavior", improvements to the AI were a high priority for both improving the educational value and overall visitor experience.

After completing work on other core issues I began working exclusively on the AI around February 25th. The simulation was already on exhibit and the museum was promised on-going improvements throughout the duration of the exhibit. Also, visiting publicists and agents from other museums would be visiting and we needed to maximize the chance of booking future exhibits. If you are getting worried, we did make all deadlines, a good impression, and everyone was happy. At this time the exhibit has moved to the Louisville Science Center in Kentucky and we are in preparation for beginning a second BtD contract, which will include more AI improvements.

Since the simulation was already on exhibit when real work on the AI began it was important to implement features that would make the biggest different in gameplay first. We did not have an allocated amount of time for a design phase or time to develop a complex architecture. I also had very little AI programming experience. This should set the tone for you, and I thought it worthwhile to mention that time constrains played a large role in the AI development.

Resources and Acknowledgements

The most valuable resource turned out to be ImmersiveAI provided by Gavin Bunney.
www.garagegames.com/blogs/64167/12423

The book Programming Game AI by Example by Mat Buckland.
www.ai-junkie.com/books/toc_pgaibe.html

And the AI Game Programming Wisdom series of books.
www.aiwisdom.com

Thank you Gavin for making iAI available to the public, and excellent work! We had to make a decision early on whether to make our own architecture from scratch or try integrating an ai resource. We looked at GOAP (goal oriented action planning used in F.E.A.R.) and would have loved to implement it in Torque, but we just didn't have the time. iAI turned out to be a perfect starting framework for A* pathfinding and goal-based behaviors.

Also very useful and often consulted was the book Programming Game AI by Example, thanks Mat Buckland for writing the most practical, and best overview, ai book ever. In particular, the steering behavior code formed the basis of our SteeringManager class.

The AI Game Programming Wisdom books were also excellent for providing general education of contemporary ai techniques. Obviously not all the papers could apply to this project, and in fact source code from only one or two papers made it into BtD. Some of the more tantalizing ideas and techniques we just did not have time to mess with. However, I consider myself a much better educated ai programmer for having read them and that will help solve any problem.


farm3.static.flickr.com/2244/2517200060_43ed94f1e3.jpg

BtD AI Architecture Overview

Brief list of components:

  • Steering Behaviors for managing short range movements and obstacle avoidance.
  • Procedural node generation based on empirical testing and A* pathfinding.
  • A prioritized goal architecture for defining dino behaviors.
  • A DinoAgent class completely separate from the Player class, which can be attached and detached.
  • A DinoAgentManager class to handle updating agents, propagating sound events, and other operations that affect all or multiple DinoAgents.
Brief list of DinoAgent behaviors:

All Dinos:

  • Find and drink water.
  • Prefer to remain near their pack.
  • Interact with friendly dinos (eg. vocalization).
  • Respond appropriately to overly aggressive "friendly" dinos.
Trike:

  • Find and eat edible plants.
  • Use a variety of tactics while in combat ( eg. charge, defend, flee ).
Trex:

  • Find and eat dino carcasses.
  • Hunt and kill prey dinos using a variety of tactics ( eg. stalk, charge, circle, flee ).

farm3.static.flickr.com/2220/2517197552_6010ba98df.jpg


A few AI topics covered in the pdf:

Interesting techniques...

  • Integrating dynamic and static obstacle avoidance ... what didn't work, what else didn't, and what did
  • Precomputing paths to solve problems ... finding the closest water or plants to a dinos position
  • Handling goal failure and avoiding goals ... don't repeat the same mistake
Areas for BtD AI to improve...

  • Making Dino AIs more responsive to the player ... more interaction options, re-prioritizing interaction goals
  • Improvements to handling goal failure ... better failure tests, more custom code in goal-fail callbacks
  • Improvements to the goal architecture ... goal subclassing, dynamic goal priority ...
---

The rest you can read in the PDF. Also our client put a few videos on YouTube.

Enjoy!

farm3.static.flickr.com/2138/2516376003_24a6140b08.jpg

#1
05/24/2008 (3:04 am)
Amazing work. It must have been a real thrill to have worked on this project.
#2
05/24/2008 (3:19 am)
Very insightful paper. Thanks for sharing.
#3
05/24/2008 (7:17 am)
Awesome looking game and good work with the AI. I'd really love to get my hands on playing this game!
#4
05/24/2008 (8:46 am)
Great write up and the screenshots look amazing, I'll be sure to have a read in more detail when I've got the time.
#5
05/24/2008 (9:04 am)
James, can I recommend you join the forums at www.aigamedev.com

I'd also recommend Mat Bucklands book, its actually pretty good as a first step. I'd recommend looking up "Behavior Trees" if youre interested in AI, as its something a lot of us are using (its almost like bucklands goal system, but a lot cleaner to implement).
#6
05/24/2008 (1:39 pm)
This game looks really awesome!
#7
05/24/2008 (4:30 pm)
Awesome postmortem! There's a great deal of good info in there!

One quick note on the debug rendering. An alternative to adding the DinoAgents to the client scene graph would be to create a new RenderBin that would loop over your DinoAgents (since you've got this list already) and call the render method directly. (Like the RenderObjectManager does). That way you wouldn't need to transmit any info over the wire to support debug rendering, you'd have full access to the server side version of the dino. (Assuming you're running everything on one box of course! heh).
#8
05/24/2008 (5:36 pm)
Awesome work and thanks for the write up!
#9
05/25/2008 (5:30 am)
I've started researching the AI for my RTS. And I too have found Mat Bucklands book useful. Thanks for writing such a detailed pdf. The way you deal with dynamic obstacle avoidance should work well with the quad tree based A* I plan to implement. Finding the closest "nodes" will already be done in most cases since the rendering, and collision will run off the same quad tree (I already have the former two working, and I assume the pathfinding will plug in without too much trouble). It's definitely nice to hear how the book transferred into your game and I'll read your postmortem in depth before I start programming.

Hopefully the exhibit will make its way over to the Seattle Science Center, I'll certainly go if it does.
#10
05/25/2008 (7:20 am)
FYI. The exhibit is currently showing at the Louisville Science Center. If anyone gets to swing by let us know what you thought.
#11
05/25/2008 (11:02 pm)
Looks bloody stunning and sounds great!
#12
05/26/2008 (11:28 pm)
Outstanding!!!
I like the dino animations. Very talented animator.
Very original.
Great work.
#13
05/27/2008 (3:22 am)
Also, check out an early video of Tom working on the prototype controls. Not AI-related, though.
#14
05/27/2008 (6:59 pm)
Very Impressive. Looks fantastic.
#15
05/27/2008 (6:59 pm)
When I was in elementary school, we went to a museum in Salt Lake City that had a dinosaur exhibit. That trip is still extremely vivid and memorable for me. I think this exhibit is going to do the same thing for the children who live around Louisville. Great work, guys!
#16
05/28/2008 (2:20 am)
Awesome!
#17
06/01/2008 (8:19 am)
Beautiful work guys and great post James. Can't wait to see what Sickhead does next!
#18
06/01/2008 (5:08 pm)
Awesome work guys - this is truely genius work. You should definitely get some sort of accolade or award for this.