A video game based on elementary differential equations
Marco Giacinti
Dipartimento
di Scienze Sociali “D. Serrani", Università Politecnica delle Marche
Piazza
Martelli 8, 60121 Ancona, Italy
Ph. n.+39-071-2207162 , FAX n.+39-071-2207058,
E-mail:m.giacinti@univpm.it
Francesca
Mariani*
CERI-
Centro di Ricerca “Previsione
Prevenzione e Controllo dei Rischi Geologici"
Università
di Roma “
Ph. n.+39-06-959938299, FAX n.+39-06-959938207,
E-mail:fra_mariani@libero.it
Maria Cristina
Recchioni
Dipartimento
di Scienze Sociali “D. Serrani", Università Politecnica delle Marche
Piazza
Martelli 8, 60121 Ancona, Italy
Ph. n.+39-071-2207066 , FAX n.+39-071-2207058,
E-mail:m.c.recchioni@univpm.it
Francesco Zirilli
CERI
- Centro di Ricerca “Previsione, Prevenzione e Controllo dei Rischi
Geologici"
Università
di Roma “
Ph.
n.+39-06-959938229 , FAX n.+39-06-959938207, E-mail:f.zirilli@caspur.it
Click here to download the video
game
Abstract
The aim of paper [1] and of
this website is to show an example of how elementary mathematics
can be used to simulate
intelligent behaviour. We present a video-game where a prey that tries to reach
a location in space (i.e.: its “home”) is chased by two predators. The prey is
animated by a human player (using a joypad), the predators are automated
players whose behaviour is decided by the video game engine. The game can be
interpreted as a “rendez vous” problem. The rendez vous problem can be modeled
as an optimal control problem or as a differential game. The engine of the video-game computes a
suboptimal solution of the mathematical models of the “rendez vous"
problem using a set of ordinary differential equations that can be solved
explicitly with elementary formulae. These differential equations are motivated
by classical mechanics and describe the dynamics of a set of point masses
subject to a force chosen by the human player, to elastic forces and to friction.
The software that implements the video game is written in the languages C++ and
The Video Game
Let us give a brief description
of the video game that can be downloaded from this website. We advise the user
to read the file readme.txt to install the video game.
The video game has been
developed having in mind human players aged between four and ten years and
consists in the chase by two predators of a prey animated by a human player
using a joypad. The prey to save his life and to increase his point score must
reach a target represented by a cross
on the screen (i.e.: the prey home). The game field W is chosen to be the whole plane and the prey is always on the screen,
that is the screen window scrolls up, down, left, right according with the
movement of the prey.
The prey is represented as a
black disk and its movement is implicitly defined by a system of ordinary
differential equations (see [1]) that depends on a function (i.e. a force acting
on the prey) chosen by the human player using the joypad.
The predators are represented
as red disks and their dynamics is described by a system of ordinary
differential equations that depends on the position of the prey (see [1]).
The systems of differential
equations used are inspired by classical mechanics, the prey and the predators
are point masses subject to forces and the differential equations considered
express
The game runs through an executable
code that opens a graphical window. In this window the prey (a black disk), the
predators (two red disks) and the prey home (a red cross) appear (see Figure 1 and Video 1).
In particular when the player
clicks on the executable file a graphical window is opened. This window alerts
the human player that the game is calibrating some internal parameters on the
hardware that is actually used to run the game.
After the completion of the
parameter calibration procedure the initial scene of the game, that is the prey
(black disk), the prey home (red cross) and the predators (red disks), appears
in the graphical window. The game starts when the player presses the start
button of the joypad. During the game, the game engine receives data from the
joypad and on the basis of these data calculates the new positions of the prey
and of the predators. These positions are returned to the interface that clears
the graphical window and draws a new image in the graphical window representing
the new positions of the prey (black disk) and of the predators (red disks). Of
course the position of the prey home (red cross) remains unchanged.
The graphical window has no
boundaries and the prey is always visible in the graphical window. On the contrary, during the game as a consequence
of the movement the prey home and the predators can exit from the window. In
the left bottom corner of the screen there is an arrow that indicates the
direction of the prey home. Note that when the prey home is not visible in the
window the arrow indicating the direction where the prey can find its home can
be used by the human player to conduct the game.
After pushing the “start”
button to start playing the human player to move the prey must use the washer on the left of the joypad
to choose the active force applied to the prey that will determine the movement
of prey (i.e. this corresponds to choose the control function appearing in the
differential equations that describe the prey dynamics [1]). The movement of
the (left) washer to the right provides a force that pushes the prey to the
right on the screen, the movement of the washer up provides a force that pushes
the prey upwards on the screen and so on.
The magnitude of the force is
directly proportional to the washer slope. The player can terminate the game at
any time pressing the “back" button of the joypad, and can pause the game
pressing the “green" button. To restart the game paused, just press the “green"
button again. For all practical purposes the time horizon of the game is infinite,
that is a game continues indefinitely until the victory of the prey or of the
predators.
The game stops when the prey
reaches its home (victory of the prey) or when the predators reach the prey
(victory of the predators).
The game consists in three levels
of increasing difficulty, level 1 is the easiest level of the game, level 2 is
the intermediate level of the game and level 3 is the most difficult level of
the game. The predators of the three levels of the game are different. Predators
of increasing effectiveness in chasing the prey correspond to increasing levels
of the game. The differences in effectiveness between the predators of the
three levels of the game are obtained changing the values of the parameters
that appear in the equations of motion that define the behaviour of the
predators [1].
The human player (prey) to
move from one level to the next level of the game in increasing difficulty must
reach the target (that is the prey home) ten consecutive times. Each time the
human player reaches the target his point score increases of an amount (1-2-3
points) equal to the level where he is and a counter calculates the number of
consecutive times that the player has reached the target. When the player
reaches the target a graphical window appears on the screen stating that the
target has been reached and the game stops. The player must press the OK button
to continue to play. Once the OK button has been pressed a new target appears
on the screen, prey and predators are repositioned and the game starts again. The
repositioning of the target, of the prey and of the predators on the screen is
random and is done using a random number generator. When at least one of the
predators reaches the prey, that is when the rendez vous takes place, the
counter of consecutive wins of the player is cleared and the player must start
all over again his climb to the next level of the game. In this case a
graphical window that states the defeat of the prey appears on the screen and
the game stops. To continue to play after a defeat of the prey the player must
press the OK button. After pressing the OK button a new target appears on the
screen, prey and predators are repositioned and the game starts again.
If the predators reach the prey three consecutive times the game ends with
the message “GAME OVER" and the player's final score is displayed. When
the player reaches the target ten consecutive times he receives a bonus of 1000
points and goes to the next level of the game. In this case a graphical window
appears on the screen declaring the level of the game that has been reached and
the game stops. To continue to play the player must press the OK button. After
pressing the OK button a new target appears on the screen, prey and predators
are repositioned and the game starts again at the new level reached.
In the third level of the
game the player can play indefinitely until he loses three consecutive games.
If the player wants to stop
the game before reaching a condition that generates the “GAME OVER" signal
he can press the BACK button on the joypad.
Software implementation of the video game
The
software implementation of the video-game consists of three parts:
i) the joypad interface (XboxGamepads.dll) that handles the
communications between the joypad and the game engine;
ii) the game
engine that computes the displacement of the prey and of the predators;
iii) the graphical
interface (XboxGame.dll) that handles the communications between the game
engine and the computer screen.

Figure 1: A
scene taken from the video game
The two
interfaces are implemented as dll codes written in
The
archive VideoGame.zip contains the following files:
·
game.exe: this is the executable file. The user must
click on this file to play;
·
XboxGamepads.dll: this is the interface that handles
the communication between the game engine and the joypad;
·
XboxGame.dll: this is the interface that handles the communication
between the game engine and the graphical window;
·
xinput1_3.dll: this is a Windows XP dll needed to use
the controller;
·
readme.txt: this is the file containing the
instructions needed to install the video game. Note that the minimal hardware requirements
needed to play with the video game are declared in readme.txt.
Video 1: click here to see a video
clip that shows the video game in action
Click here to download the video game
References
[1] M.
Giacinti, F. Mariani, M.C. Recchioni, F. Zirilli, “A video game based on
elementary differential equations”, submitted to IEEE Transactions on Computational
Intelligence and AI in Games.
[2] M. Athans: “On
optimal allocation and guidance laws for linear interception and rendez vous
problems", IEEE Transactions on Aerospace and Electronics Systems AES7,
(1971), 843-853.
Entry number:
* The work of F.M. was
partially supported by SELEX Sistemi Integrati s.p.a. (