Games and Simulations

I find it funny how some people don't see the relation between games and simulation. Even before the internet existed or even electricity, people played games. So computer simulations are highly based on the pre-existing concept of games. Let's start with a common game: Chess. Well, Chess is a turn-based game (each player has their turn), it is also a multiplayer game and one of the first games that were reproduced in a computer.

(Game as simulation)
Well, one of the definitions of simulation is an environment that evolves based on actions. So, assuming the Chess Board is the environment it changes every time a player takes an action, so one could say it is a simulation.

(Simulation as a game)
Now let's take a common simulation environment in AI: the Wumpus World. In this world, an agent has to do the allowed actions in order to find the treasure and flee the bad guy(s): Wumpus. Well, on AI it is common to have a decision-making process to decide the agent actions, but as long as there is a human deciding instead of software, it could be treated as a game.

(Discrete-Simulation games)
Nowadays it is common, specially in Mobile Games, to have turn-based combat. This kind of combat is like a discrete-step simulation. Assuming:

$s_0$ : The initial state of the environment (or game board, or scenario, or battlefield);
$A$ : The allowed game actions $(a_1, a_2, a_3, ...)$;
$f(s_i,a) = s_{i+1}$: A turn-function that given a scenario $s_i$ and an action $a$, results in $s_{i+1}$ .

Using a more programmer-like language, the game board is an instance of the data structure that represents the game board, the game actions are the function calls (using the Command Design Pattern is highly recommended) and the turn-function is basically just invoking the game actions passing the game board as a parameter.

The game board only evolves based on an action every single time. No action = same board. Every action on the same game board will result in the same evolved game board (assuming same action internal parameters, which could be a pseudo-random seed).

Well, this is basically a discrete-step simulation where the user (player) chooses the actions. That is why it is so easy to have "auto-battle" features in these kinds of games, it basically just takes the decision-making process for the action from the player and gives to an AI. Here, many AI techniques can be used, like planning, utility systems, min-max and many, many others. Since the time between turns can vary, we (or the AI) can take all the time it needs to reason about the best or more fun choice of actions.

If you want some variation, just think about an asynchronous running timer that chooses action to be executed on the board independently from the user actions, so even if the user chooses to do nothing, something will happen.

(Continuous-Simulation games)
In these type of games, there is no "turn", for example, Fighting games, Sports games, RTSs, FPSs, etc... Previously we didn't have many of these games on mobile, but from some time ago many have appeared, but we always had these on consoles and computer.
In the academy, we have many subjects that study Continuous-Time simulations (temporal logic, temporal planning).

Here everything gets way more complex, as decisions have to be taken in real time, the game board evolution is based not only on the current state and the actions but also on the time passed.

I'm not going to go in-depth here as it would get way more complex, but a quick tip is that you can snapshot the current state of the game board and the current actions being executed when choosing the best action.


Popular posts from this blog

Tools and Property Drawers

PCG and Data Analysis - Two sides of the same coin? Also, GANs?

Unity/C# - Grids - Simple Grid Segment struct