There's more...

We can use this technique to build an infinite runner with the following train of thought:

  1. Store the key levels (change of world or difficulty)
  2. Assign them a higher-level director to the current level builder
  3. Swap initial generated levels with the new ones, or keep using pattern levels to generate more until the game finishes

As demonstrated in the research cited in the following section, this technique works well with 3-grams (as used in the recipe).

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.