In this entry Carlos Bordeu talks about a new boulder AI navigation system in RoA 2.
Navigating levels: The boulder AI design
So here's a crazy simulation showing off the result of dozens of AI boulder players trying to navigate a level simultaneously.
Cool, isn't it? So if you wish to know how we're getting these results... read on!
One area which ROA1 could have been better was the boulder's AI. As we went into ROA2, we had to find a system that was both efficient and also easy to use for level designers. After trying different approaches we ended up implementing a path system in which a human player navigates a level to record speed and jump values of how to finish an empty level (no obstacles). The resulting information can be seen represented in the following spline:
As you can see this level (which happens to show a nice preview of the Renaissance art period) has a few jumps and turns and can get quite narrow for a boulder attempting to navigate at top speed. This path shows the most obvious and "safe" path to complete the level, where no risky/difficult jumps have been taken during the recording process.
In the spline you can see how the green vectors are representative of the direction and velocity (given by the vector's length).
However we want our AI to sometimes attempt shortcuts, and for this we record play sessions with riskier routes that require better timed jumps and control, as can be seen in the following two examples.
When the game is running, the AI boulder doesn't simply move through the paths we have predefined - these are there as markers which give a hint to the computer of when to jump and what speed to move. With more prerecorded sessions (done by a human player), the AI has more information to help it know how to navigate the level properly. When knocked away, or even when falling off the level, the AI can re-adjust and use this navigation map to properly move through the level, and that result is the animation at the beginning of this post, which I share here again.
The way the boulder evades obstacles is a different system that works in conjunction with this ...but that is a topic we can talk more about in a future blog post. Hope you enjoyed this quick insight into the development of ROA2. Remember this post when you play the game later on and the AI beats you ;)