Data-Oriented Behavior Tree Overview

My last blog post about data-oriented behavior trees was/is too long for many to find the time necessary to read it. I myself would have problems to block enough time and concentration to fully delve into it. Therefore here is the high level overview of it stripped of the description of my attempt to follow data-oriented design practices.

This is an #AltDevBlogADay article I first posted here.

Read the rest of this post »

Shocker: Naive Object-Oriented Behavior Tree Isn't Data-Oriented

Todays episode about my behavior tree experiment crashes you into menacing hardware walls, starts a wild flirt with data-oriented design to soothe the pain, and all of that just because of my nagging problems with a naive object-oriented behavior tree sketch. Oh, and in the dramatic end I'll interrogate - aeh - ask you questions, too!

Read the rest of this post »

Introduction to Behavior Trees

What is a behavior tree? How does it work and what is its role in game AI?

The mis-behaving Whomping Willow tree from the movie Harry Potter and the Prisoner of Azkaban - picture hosted by the Harry Potter Wiki

Welcome to a series of blog articles about my experiment (read: stumbling around) of marrying data-oriented, memory-streamlined behavior trees with a second representation to ease creation and modification during development. I write it to document my findings and decisions and to ask for your invaluable feedback to build a BSD licensed BT toolkit that is truly useful.

Read the rest of this post »

Paris Game AI Conference 2011 - Call for Presentation Proposals

The Paris Game AI Conference for everyone working or being interested in the field of game AI will be back in 2011.

While meeting and talking with the great bunch of people that will attend is awesome in itself, there is also the chance to present something you are doing in the industry or as personal or academic research and development – the call for presentation proposals just went online here: http://gameaiconf.com/2011/upcoming/call-for-proposals-now-open/

Notes from Paris Game AI Conference 2010

  • Update on July 08, 2010 – Added link to the official conference coverage on AiGameDev.com with photos, slides, and session summaries.
  • Update on July 07, 2010 – Added link to Mikko Mononen’s blog entry about his talk with sources and “slides”.
  • Update on July 02, 2010 – Bertrand Faure informed me that he was the fourth panelist of the crowd simulation panel.
  • Update on June 29, 2010 – Added a paragraph to the Navigation Loop section based on a comment by Mikko Mononen.

Paris Game AI Conference 2010 was a blast! Fantastic presentations, a great bunch of people, a lot to learn and laugh during break-time discussions, and joyful parties at nights!

Alex Champandard, the main organizer and master mind of the conference (you might know him from films like “One Behavior Tree to Rule Them All” or “Three Animation Blends for a Hallelujah”), announced at the beginning of the first day that most presentation slides will be available for download subsequently on AiGameDev.com. Because of this I only took very few notes as I mainly wanted to concentrate on the presentations and panels instead of writing until my fingers would bleed.

My biggest take away from the conference is that the first question to ask before starting to develop the AI for a game should always be: what do you want the player to experience. Technology is mainly a means to this end. Cool tech doesn’t make a great game - caring for entertaining the player is the key.

Updated on July 08, 2010: Alex Champandard published the official conference coverage on AiGameDev.com with session summaries, photos, and slides here: http://aigamedev.com/open/coverage/paris10-report/. Kudos to Alex who is officially in his well-earned holiday!

Following are my edited notes and some more notes from my leaking memory.

Tales from the Design Trenches

Panel discussion with Stephane Bura, Noah Falstein, and Jurie Horneman from Mi'pu'mi Games about game design and how designers and programmers manage to work together.

  • Falstein: make the simplest artificial intelligence (AI) solution you can think of, even it it seems too primitive, and start iterating from that
  • Horneman: Start with what the player wants to do / should do - sophisticated tech is not a game in itself.
  • Horneman: Tools to help in balancing gameplay would be cool.
  • Falstein: Serious games have a need for more AI.

The panelists recommended a book by Jesse Schell: “The Art of Game Design: A Book of Lenses” as it shows how game designers think. I didn’t get another book title they mentioned but Simon Barratt from Four Door Lemon (one of the conference sponsors) recommended “Game Design Workshop: A Playcentric Approach to Creating Innovative Games” by Tracy Fullerton to me.

Talking to Stephane and Jurie afterwards during the coffee breaks was a pure joy.

Intimate Conversions with Interactive Animated Characters

This presentation by Bruce Blumberg was the first keynote of the conference in which Bruce talked about the game World of Zoo and how to create magic moments when the player interacts with the games animals.

  • Main question asked to create World of Zoo: “How to create the illusion of interacting with a sentient being/pet”?
  • Communicate to the player that he is in the focus of attention.
  • Interaction means conversation.
  • Character should show sentience, attention, engagement.
  • Playing fetch in a demo of a puppy build of boxes is meaningful to us - “because of you the dog is happy”.
  • It’s about what you want the player to experience!

Bruce Blumberg is a fantastic and energizing speaker - if you ever get the chance to listen to him: run, don’t walk.

Navigation Loop: Avoid Turning in Circles with Local Navigation

Mikko Mononen walked us live through a demo application to share his immense insights into getting local steering and navigation right and robust with a strikingly simple concept you only reach after many hours of deep thought, prototyping, and a distaste for solutions that explode into hard to maintain special cases. Mikko combined velocity obstacles with a adaptive sampling of local space to navigate single and multiple agents through dynamic environments based on paths from a navigation-mesh.

  • Navigation loop: find path, find corner, steer, move and collide, done or adjust corridor and loop to find corner again (and so on).
  • Robust collision system as basis for moving/steering is crucial.
  • Corridor found by pathfinding system, by moving it is getting smaller (cut where you have been) or expands.
  • Keyword: robust movement system.
  • Multi-agent navigation is hard - attack it with a combination of global and reactive solutions.
  • Mikko’s choice: Reactive obstacle avoidance with velocity obstacles.
  • Classical steering behaviors are impossible to tune, VOs (velocity obstacles) are hard but possible to tune.
  • Avoidance velocity selection: discretize and sample: don’t build the VO cone geometrically but via sampling.
  • Adaptive sampling (quad tree alike structure) to save memory.
  • Geometric VO representations are more efficient but sampling is easier to understand and therefore easier to tune and combine with other influences affecting navigation.
  • Put obstacle avoidance behind the steer stage and before the move and collide stage in the navigation loop.
  • His main focus: creating a practical VO implementation. With a robust dynamic and reactive navigation component the higher-level path planning might be able to use less detailed level representations.

During the presentation I wondered how agents handle situations where they are completely blocked from moving - would they re-plan their path? Looking at the demo it become clear that they will just wait till the block has been resolved and will go on to their target. Adding a “blockage-detection” shouldn’t be a problem though either.

Mikko recommended the following papers to learn more about velocity obstacles:

As a long-time contributor to OpenSteer, a steering behavior library and demo by Craig Reynolds, this was easily my favorite talk. Mikko’s insistence to create robust, very focused and simple to use technology is enlightening. Player experience might come first but technology that enables certain gameplay and is tune-able without too many headaches is a feast in itself.

The only problem of Mikko’s approach of sampling VOs might be (this is hypothetical) that it is too slow to handle huge crowds of agents. Simpler and therefore faster techniques might be more usable in these scenarios. Thanks to William Ledoux for discussing this with me.

Mikko announced to publish his work and code – follow his blog not to miss it: Digesting Duck

Updated on June 29, 2010: Mikko chimed in with a comment below the article stating that his work is specifically targeted at providing navigation for groups of around 20 to 25 agents. Agent navigation and movement needs to be of higher quality for such small groups than it is needed for huge crowds as players will see more of each agent and will spot non-human-like or wrong-looking behavior easily. He emphasizes my main takeaway of the conference – decide first upon the player experience, e.g. let the player engage with a certain number of agents, and based on that decision, select the best technology for it.

Updated on July 07, 2001: Mikko has blogged about his talk with pictures from his presentation material and code here: http://digestingduck.blogspot.com/2010/07/my-paris-game-ai-conference.html.

Crowds and Pedestrians without Bumper Car Syndrome

Panel with Mikko Mononen, Ken Perlin, and Jean-Charles Perrier and Bertrand Faure from Quantic Dream discussed tips and tricks and the technology behind in-game crowd simulation.

  • Question from audience: Is it ok to model a person as a point in space? Perlin: yes. Start out as simple as possible to get traction on the problem.

  • Question of mine: How do we perceive crowds? Via flow fields? (Unasked: I read that there are difference between people - Asians perceive relationships by space between objects, westerns see the objects and not the space separating them.) I don’t remember (bad memory, bad, bad memory) getting a direct answer to that other than that there should be lots of literature in the field of cognitive science.

  • Heavy Rain crowd simulation used flow field approach based on ATIs Froblins paper.

  • Heavy Rain devs: We prototyped a lot. Reynolds steering behaviors didn’t work for huge crowds - too computational intensive, flow fields better suited and specifically used for crowd scenes. The implementation creates a bubble of people centered around player.

  • Mikko: couple flow fields with local steering

  • Perlin: With few characters on screen their relationships and details are important and need a solution - crowds are different and need a different solution.
  • Perlin: Ask why you have a crowd in your game - a crowd is a dramatic character which should behave based on the scenes needs.

Psychology Profiling in SILENT HILL: SHATTERED MEMORIES

Presentation by Gwaredd Mountain of Climax Studios who talked freely (didn’t need to look at his own slides or even at notes) how Climax analyzes the player psychology to change the game to reflect the players fears and attitudes.

I didn’t take any notes during this talk not to be distracted by typing and am waiting impatiently for the slides. Main point for me: profiling a player is hard and weaving the profile into the gameplay is even harder. Silent Hill: Shattered Memories (SH:SM) created a game which plays like episodes with a psychologist who asks the player to learn about her traits and then dives into the gameplay where street signs, character models and behaviors, and colors of settings then mirror what has been learned about the player. Art creation can become a bottleneck with this technique. To really be able to scare the player based on his profile it would have been great to find a way to diagnose the players neuroses - but it’s unclear how to do that.

Physics-based Racing AI in SUPERBIKE 2010 and SUPERSTARS V8

Paolo Maninetti from Milestone talked us through the iterations on the smart representation of racing game tracks and tuning the track infos and the racing AI to enable agents to drive the same physics controlled vehicles as the player in SUPERBIKE 2010 and SUPERSTARS V8. A very hands, pragmatic and usable approach. Impressive. I was too focused listening and forgot to take notes.

The Evolution of BATTLEFIELD: BAD COMAPANY’s AI

In the second keynote of the Paris Game AI Conference Mikael Hedberg from DICE led us into the world of open-world battlefield AI which copes with destruction all around it while entertaining the player to the max. This was another talk where I was listening instead of taking notes to get all the awesomeness that is the Battlefield Bad Company 2 (BFBC2) AI.

My main take aways: entertaining and challenging the player is of primary concern. Cheat to put the player directly into a cinematic battlefield experience. Keep your AI simple and robust so it is able to cooperate against or in support of the player and is able to navigate and exploit the dynamic and destructible environments. The AI is able to carry 80% of the experience on its basic (bulk) capabilities while special situational AI provides memorable moments in 20% of the game time.

What is AI? AI is the fusion of everything needed to experience non-player characters - animations, scripting, voice overs, behavior and decision making. BFBC2’s AI is completely reactive and doesn’t plan. That is, it is reactive if it isn’t scripted for intense and memorable player moments. At its base you’ll find layers of ordered behavior lists (aka simplified behavior trees).

Death animations provide a lot of bang for the buck in communicating the waging war to the player.

Oh, one more thing: flying helicopters is hard even for non-player characters (I personally crash BFBC2 helis in a question of seconds) ;–)

Get Mikael’s slides at DICE’s official publication website: http://publications.dice.se/.

Building Virtual Toys that Don’t Break

Bruce Blumberg, Ulf Johansen from IO Interactive, Mikael Hedberg, and someone from The Creative Assembly (De Caster?) discussed the secrets of working AI for sandbox-style games.

  • De Caster: In the Total War games it is hard to decide when to cancel an invasion. Total War uses a Belief-Desire-Intentions architecture for campaign control.
  • Johansen: Used finite-state machines (FSMs) in Hitman: Bloodmoney, later games are using behavior trees (BTs) now.
  • Blumberg: The AI should detect situation and context to create best fitting decisions.

AI Sandbox Multi-threading

Alex Champandard summarized the experience of parallelizing the AiGameDev.com Sandbox, an AI demonstration, experimentation, and testing framework, and the main solutions used.

I didn’t take notes not to be distracted and because I heard about this in an AiGameDev.com masterclass before. Alex polished and improved the masterclass material tremendously. Following I’ll listen the points I vividly remember of his gripping and important(!) talk. Listening to Alex is always worth it and infects you with tons of ideas to try as soon as possible.

  • Track memory allocations to help identify race conditions, e.g. singleton allocation pattern (brrrr…), in your own and foreign code and libraries.
  • More experienced coders tend to create less but harder to find one in a million bugs.
  • Use a job pool with jobs modeling tasks, dependencies between jobs, jobs that specify following (continuation) jobs, to simplify exploitation of all the cores of the machine you are running the game on.
  • What is needed from a job pool: dependencies: yes, cancellation: no (frame is too short), persistence (jobs running longer than one frame): no (jobs are short to fit into a frame).
  • Game components/systems store queries from the systems user. Queries have a type and pre-allocated input and output buffers. Queries spawn dynamic job trees where some jobs read from the queries input buffer and finally a result is written into the queries output buffer. In a certain sense queries equal the so called “futures” from typical parallel programming.

Human territoriality for Eve’s Online socially smart characters

Charming talk by Claudio Pedica, an Italian academic who worked (works?) in Iceland with CCP Games to make in-game settings with non-player characters (NPCs) more life-like and less like walking around “quest-vending-machines”. This work is targeted to appear in Eve Online “when it’s done”.

  • Todays NPCs might not react to player even if she walks right to them. They look disconnected from the situation, unaware, and don’t react to player interactions other than pressing the “talk to” button.
  • Territories: social structures everywhere affecting all behavior. Think of a space surrounding every person and groups of persons which, based on the current situation, has a certain meaning to us humans. Which meaning? For example, two persons talk to each other, so we don’t interrupt them by moving into their territory other than if we know them and want to enter the discussion.
  • People talking in groups form into so called F-formations (standing pattern). The space in the middle of people is a space for conversation (based on work of Kenndon (??)).
  • Unit of interaction: norms, area of interaction takes space aka territory, an area with certain social meaning.
  • [Scheflen, 1976] : spheres of interaction build territory. Classification of different patterns of F-formations (even nesting) for certain social contexts.
  • Claudio and his colleagues implemented a reactive framework based on perception (vision and proximity), reaction (motivation), motion (point-mass model and head and eyes orientation) to create territoriality behavior.
  • Three social behaviors (norms) which build social interaction: equality, cohesion, distance. Think steering behaviors.
  • Architecture of experimental implementation: action selection, reaction, motion generation.
  • Group dynamics need to be improved yet. Currently only empty environments are supported and time intensive behavior tuning is needed.
  • Evaluation of the method shows that it improves believability of social in-game settings.

My take: social behavior creates new smart territory (aka a smart object in “The Sims” terms) dynamically. The demo implementation of territoriality looked like a huge improvement over typical game NPC social scenarios to me. Discussing Claudio’s talk with Jad Nohra, he commented, that this new technique will push the boundaries of AI further but also needs even more AI as the player starts to expect more human-like behavior and reactions by NPCs. Good point, though I am all for using the demonstrated tech even if AI isn’t prepared for the steps following it ;–)

Modern Procedural Animation

In the last talk and last keynote of the conference Ken Perlin took us on a whirlwind-tour through his research and work on procedurally generated animation. This was an outstanding talk by an outstanding researcher and I didn’t took notes not to miss a single syllable. Here’s what I remember the most:

  • Procedural animation is a tool for a new generation of content creators to do things we never thought off - like using Perlin Noise to create ocean waves in the movie The Perfect Storm.
  • Think of a character to animate as series of acting effectors - first get the acting legs right, then the hip, the chest, the head etc. Layer these effectors. Some layers depend on others, e.g. the legs “look” at the head to decide how to animate themselves.
  • Express feelings and mood of a character via animation.

Ken Perlin talked about many stuff he did recently and “20 years ago” - he is fully aware of his mind-blowing and idea-inspiring work. If this man talks then try to get a place nearby to catch as many inspirations as possible.

Read the rest of this post »

Parallelization of Game AI - Presentation from the Paris Game AI Conference '09

In June 2009 I gave an overview and motivation for Parallelization of Game AI at the Paris Game AI Conference '09. The conference was a blast - great discussions with many interesting people and inspiring presentations - look out for the next installment, I will do so for sure!

Alex and Petra Champandard from AiGameDev.com, the main organizers and master-minds behind the Paris Game AI Conferences, just published the video and audio recordings of my presentation and put it online for AiGameDev.com premium members. Petra did a great job editing the recordings and put in a lot of hard work to synchronize my talk with the downloadable slides.

Video and slides at AiGameDev.com:

Slides with speaker notes can also be found at bjoernknafla.com:

Slides-movie and brief presentation recap

I find it extremely awful to watch and listen to myself / my presentation. I worked very hard on the talk and created slides that were full of animations to explain the presented parallelization concepts - making the slides a kind of script to follow during speaking. A script that needs accurate transitions and explanations under time pressure to stay inside the presentation time slot. This rigid structure to follow in combination with my nervousnes lead to lots of "ahs" and "errs" and let me struggle with my English speaking skills. To amend for th is, I created a quicktime movie from the slides showing the actual animations and added a coarse talk outline below. This in combination with the speaker note extended slides and the video recording at AiGameDev.com should give you much of the useful information of my talk.

(download)

Introduction

  • Why we need parallel programming: parallel hardware, performance.
  • Parallel programming isn't easy - but no rocket-science either:
    • parallel programming errors: race conditions, deadlocks,
    • performance problems: contention,
    • be aware that order of parallel instruction execution isn't deterministic.
  • Parallel hardware dictates how to program for performance:
    • maximize throughput - to fight memory latency,
    • maximize memory locality - to save bandwidth,
    • minimize (false) sharing - to prevent contention,
    • combined: balance maximization of locality vs. minimization of sharing.
  • Artificial intelligence (AI) model referenced in the talk: agent-based AI.

References:

Read the rest of this post »