Step-by-step role-play games developing method based on XML-scripts and finite-state automatas

© A.V.Efremov, K.A.Woroshilov

Saint-Petersburg State University of Information Technologies, Mechanics and Optics

Project documentation (in Russian)
Executable program
Source code


Since role-play games (RPG's) came into life, the most important problem has raised: non-player characters (npc's) behavior programming.

The most common way of solving that kind of problem were behavior scripts, which allows to describe character's action sequences dependant on some factors and events. Such kind of behavior is usually linear and predictable. The probability of making an error during programming those scripts is very high, so sometimes "dead" characters are still making actions, reacting on different events etc...

This work describes behavior scripts developing method according to finite-state automata transition graph, which are vivid specification of objects behavior.

The work contains the description of formal language developed by authors, which helps to write behavior scripts directly from transition graph. Authors has also created an interpreter for this language to execute such scripts. In conclusion a sample of a game has been placed. It clearly shows all the abilities and advantages of the method.

Game world of a sample is based on popular computer game "Heroes of Math and Mechanics", main idea of which is to pass all the examinations of a single semester in "Math and Mechanics" faculty of Saint-Petersburg State University in a short period of time (one week).

Authors has developed a similar game that proposes to player to pass all the examinations of more familiar to authors "Information Technologies and Programming" faculty of Saint-Petersburg State University of Information Technologies, Mechanics and Optics.

The game contains a set of possible places where characters can be (including player's character) and set of actions characters can perform in each place. For example, player's character can prepare for passing some examination (by learning some discipline), communicate with other (non-player) characters, acquiring some knowledge during conversations, pass examinations, and perform other usual actions, such as sleeping etc. Player's character has a set of parameters (knowledge on different disciplines, intelligence, mood, charisma, luck), which can be altered as a result of performing some actions. The game ends if player has managed to pass all the examinations before a predefined time. Otherwise the game is lost. In order to sharpen a gameplay, saving and restoring a game state, as in the prototype, are not implemented.

Interpreter has been developed on .NET platform which grants a good speed and comfort of developing. The program has been written on C# language, the formal language is based on XML technologies.