Procedural Terrain Generator For Platform Games Using Markov Chain
Procedural Terrain Generator For Platform Games Using Markov Chain
Abstract— The game design is a complex and huge task and need a training data instead of domain knowledge to
game companies spend much time to create a beautiful and generate a new map.
exquisite design for a video game. The terrain is the most The objective of this work is present a methodology for
extensive part of a game. Some games need to present procedural terrain generation for 2D platform games. The
different terrains on each level so that the game does not approach developed was based on the use of Markov
become repetitive to the players. Procedural Terrain models, specifically the hidden Markov chains, to produce
Generation is a technique that can streamline much of this new terrain probabilistically.
work using algorithms to create new terrain randomly. This The game designer can define the terrain behavior of the
work presents a methodology for procedural terrain
game by reporting a transition matrix, where each state is a
generation for 2D platform games. The approach developed
was based on the use of Markov models, specifically the
terrain element.
hidden Markov chains, to produce new terrain Finally, a filtering method was applied to verify the
probabilistically. The results show that the technique consistency and viability of the terrain generated. Therefore,
presented here is able to generate a 2D platform game terrain. such tool may aid the game designer during the game
development and improve the overall quality of the game.
Keywords- 2D platform game; procedural terrain In the next section, we present the fundamental concepts
generation; Markov models; hidden Markov chains to understand the developed methodology. In Section III the
PTG methodology developed are presented. Section IV
I. INTRODUCTION discusses the obtained results. The Section V shows the
conclusions and future works.
The game design is a complex and huge task, it requires
putting in a lot of manpower and material resources and
spend some time in order to create a beautiful and exquisite II. BACKGROUND
design of good games.
One of the most essential aspects of most video games A. 2D Platform Game
is the terrain that the player will traverse. Procedural Terrain Platform games originated in the early 1980s, with 3D
Generation (PTG) can streamline much of this work using successors popularized in the mid-1990s. The term
pseudo-random algorithms. The term PTG refers to the describes games where jumping on platforms is an integral
creation of content by an automated system, rather than
part of the gameplay and came into use after the genre had
being produced manually [1].
been established [7].
There are many of effective techniques currently that
can be applied to procedural game content generation. One of the most famous platform game is “Super Mario
However, the main algorithms are based on noise function. World” (SMW). This game was launched in 1990, and now
The Diamond-Square Algorithm proposed by [2] have is a classic and successful game. SMW is still used as a
fractal nature based on recursive subdivision. In [3], several template for many games titles of the same genre. It is a
noise functions are compared to generating terrain texture: platform-based game, where the main character must
Value Noise, Perlin Noise, Simplex Noise and Whorley follow a path picking items and destroying or deviating
Noise. The authors conclude that each technique present a enemies.
weak point, e.g., Simplex Noise is very difficult to The return of 2D games would be related to aspects of
implement in a game context, Value Noise are very simple, nostalgia or aesthetics. The 2D style is not necessarily a
but need a secondary interpolation function based on technical limitation, since just as hardware has evolved and
fractional Brownian motion to generate a good result. transformed the 3D gaming experience, these techniques
2D platform games are on the rise due to recent big hits may well be applied in two-dimensions [8].
in mobile operating systems, e.g., Angry Birds and Super According to [9], mobile games emerge as the favorite
Mario Run, each with more than 100 bi downloads [4][5]. of the public, with 43.6% choosing smartphones as best to
A platform game is a video game genre of action game play. In them, the games need to be very "light", which does
where the player controls a character or avatar to jump not mean that they must be simple, but that they cannot use
between suspended platforms and avoid obstacles. high realism to be accepted in the market. This combination
In [6], the authors presented a hierarchical approach to of factors enabled the return of 2D games, in particular
generating 2D platform video game maps using multi-
platform games.
dimensional Markov chains for learning, sampling and
clustering for finding high-level structures. Their approach
B. Procedural Terrain Generation (PTG) The evolution of the Markov process can be presented by
Player demand for more content is increasing as games a state transition graph that shows the structure of the
grow in complexity and scope. Traditionally developers process according to the following rules [14]:
have hand-crafted content for games, requiring a States are represented by nodes that belong to the
substantial investment of time and resources. alphabet ‘S’ of states, S = {s1, s2, …, sn);
Procedural content generation methods are used to The transitions (possibilities of passing from one
create content algorithmically instead of manually [10]. state to the other state) are represented by (directed)
PTG are specific techniques for the generation of terrain. edges, they are weighted by their probabilities. The
Virtual terrains have an important role in computer probabilities are grouped in a transition matrix ‘A’:
graphics, and their applications range from landscape 𝐴 = {𝑎𝑖,𝑗 = 𝑃(𝑠𝑖 |𝑠𝑗 )}, 𝑤ℎ𝑒𝑟𝑒 ∑𝑁 𝑗=1 𝑎𝑖,𝑗 = 1 (1)
design and flight simulators to movies and computer The starting probabilities are the probabilities of
games. A terrain is the dominant visual element of the starting in one state or another. They are grouped
scene, or it plays a central part in the application. into a startup vector ‘∏’:
Procedural techniques are a popular choice in game ∏ = {𝜋𝑖 = 𝑃(𝑠𝑖 )}, 𝑤ℎ𝑒𝑟𝑒 ∑𝑁 𝑖=1 𝜋𝑖 = 1 (2)
development because of the simple implementation and
wide range of terrains they provide when a few parameters A model λ is observable because states are directly
are changed [11]. observable, and a transition matrix A and an initialization
The desire for automatic terrain generation stems from vector ∏ characterize the model, where:
the goal of provide a new content to player without a large 𝜆 = {∏, 𝐴} (3)
investment of developer resources.
In [12], the authors cite the properties of a PTG 2) Hidden Markov chain
technique: In a Hidden Markov Model (HMM) the states S = {s1,
Novelty: contains an element of randomness and s2, …, sn), are not observable. However, they emit
unpredictability; observable signals O = {o1, o2, …, ot) that are weighted by
Structure: is not merely random noise, but contains their probabilities.
larger structures; An HMM is characterized by Eq. (5), a transition matrix
Interest: has a combination of randomness and A, an initialization vector ∏ and an emission matrix B,
structure that players find engaging; defined by:
Speed: can be quickly generated; 𝐵 = {𝑏𝑖 (𝑜𝑘 ) = 𝑃(𝑜𝑘 |𝑠𝑖 )}, 𝑤ℎ𝑒𝑟𝑒 ∑𝑇𝑗=1 𝑏𝑖 (𝑜𝑗 ) = 1 (4)
Controllability: can be generated according to a set where, bi is probability of the state si to emit the signal ok.
of natural designer-centric parameters. 𝜆 = {∏, 𝐴 , 𝐵} (5)
IV. RESULTS
The decorative elements selected to experiments are
The methodology was implemented in Unity game showed in Figure 2.
engine [15]. An experiment was conducted with 12
different possible states. The states can be seen in Figure 1.
1 2 3 4 5 6 7 8 9 10 11 12
8 0 0.5 0 0 0 0 0 0 0 0 0 0.5
Figure 3. Sample of generated level by Markov chain.
Thus, advances must be made to improve the use of
hidden Markov chains, because despite obtaining a useful
result, some errors occur, e.g., the instance of elements in
places that should not exist, as in the case of the instance of
a decorative element on top of an empty terrain segment.
REFERENCES