Using N-Grams for content generation
In Chapter 8, Learning Techniques, we learned how N-Grams is a probabilistic language model for predicting the next item in a sequence of n-1 elements, and how it can be applied in learning techniques for predicting player behavior. However, it can also be used for procedural content generation—creating new elements by imitating the style of a given set.
In this recipe, we will use the power of N-Grams for creating new levels from a given set, thus imitating the style of the designer.
Getting ready
It's important to remind ourselves about the N-Gram predictor that we developed in ??????Chapter 8, Learning Techniques, as we will use it as a tool for building levels based on the previous design—in this case, a level to be used as the main pattern.
How to do it...
We will develop three different classes: a component for our prefabs, the level predictor, and the level generator that puts everything together.
LevelSlice
is the component to attach to the prefabs...