The Formal Approach
to Computer Game Rule
Development Automation
Elena Pavlova
Moscow Engineering-Physics Institute (National
Nuclear Research University), PhD student
05.13.11
Agenda
• Game rule development: automation
problem
• Turn-based strategy game rule description
language
• Formal game rule verification method
• Prototype rules development environment
• Summary
Game rules
Game rules include the definition of
• specific game world entities
• entity interaction rules
• the main goal of the game and secondary goals
• start conditions and winning conditions
• player state definition
Rule examples:
• A troop, moved to a map cell with an enemy’s
town, must fight or run away
• Building a castle requires 3000 stones and
100 bars of gold
Game rules development
Game designer
Game designer
Rules design
Design results
verification
Text editor, spreadsheet
Game designer,
programmers
Rule-based game
prototype
implementation
General-purpose development
environment
Object
The object of this paper is to develop an
approach to game rule development
allowing
• formal visual rule design
• automated rule verification
• rule-based code and data generation
• Game class specificity consideration
Rules description language
The language allows to describe
• specific game domain entities (entity
data and behavior)
• entity behavior constraints
• entity relations
• the reaction of entities to another
entity behavior
Game rule example “The town attack”
An army may attack a town if
• it is an enemy’s town
• army move’s count is greater than 0 (the
army still can make a move)
When the army attacks the town, the army
move’s count is decreased by 1.
The population of the town may defend it.
The player who possesses the town should be
informed about the attack.
Rules model
Rules in the language textual notation
army = Army,
playerID : 1,
movepoints : 5,
attackCity ( city : City )
{ ((army.playerID != city.playerID) and ( army.movepoints > 0 ))
attackCityBody
(army.movepoints = army.movepoints - 1) } ;
player = Player,
playerID : 1,
cityAttackDetected ( city : City )
{ cityAttackDetectedPrecondition Body cityAttackDetectedPostCondition } ;
city = City,
playerID : 1,
autoDefend ()
{ autoDefendPrecondition autoDefendBody autoDefendPostCondition } ;
AddReactor ( army.attackCity, city.autoDefend);
AddReactor (army.attackCity, player.cityAttackDetected);
Type System
• Static typing
• Type inference
Language library includes
• simple types for behavior constraints
• types for turn-based strategy domain
Object cloning
The language is prototype-based
Object_1
Object_1_Clone
ObjectType
ObjectType
Attribute_1
int
3
Method1 ()
Method1
code
Attribute_1
int
3
Attribute_2
string
ab
Method1 ()
Method2 ()
Method1
new code
Method2
code
Language semantics
• Denotational semantics
• λς – calculus for denotats
• Hoare Logic elements for methods’
preconditions and postconditions
evaluate
object
env
evaluate (typeIdentifier attributeIdentifierj : attributeBody j j1..k
methodIdentifieri methodi i1..n ) env
[t j ( x j : Aj )a j : Aj j1..k , li ( xi : Ai )mi : M i i1..n ] ,
Rules model verification
• Rules model consistency – static analysis
Syntactic model consistency
Semantic model consistency
• Static balance – formal properties monitoring
Superior side detection
Invincible troops detection
First turn superiority detection
• Dynamic balance - automated theorem
proving
Turn result superiority detection
Consistency
• Syntactic consistency
I
I
req
ij
i, j
pr
ij
i, j
pr
1
I
I
req
1
I
O1
I
req
2
pr
2
O2
• Semantic consistency
object1 , object2 :
req
1
( DI ( I
, I 2 ) True) &
pr
( DI ( I 2 , I1 ) True)
req
pr
( DI ( I req , I pr ) True) m1 I req m2 I pr : Dm (m1 , m2 ) True
( Dm (m1 , m2 ) True) ((Q2 Q1 ) & ( R1 R2 ) True)&(m1 m2 )
Dynamic balance
Dynamic balance Each turn the game is fair.
• The turn invariant is placed into appropriate
methods (related to the end of turn event)
• Rule model described in the formal language
designed is converted into the automatic
theorem prover input format (ESC/Java)
• The theorem prover attempts to verify the model
Summary
The approach to game rule development was
suggested. The approach allows
•
•
•
•
formal visual rule design
rule verification
rule-based code and data generation
game class specificity consideration
References
•
•
•
•
•
•
TorqueEngineAdvanced – http://www.garagegames.com/products/torque/tgea/features/
FPS Creator – http://www.darkgamestudio.com/
NeoAxisEngine – http://www.neoaxisgroup.com/description.htm
Offset Engine – http://www.projectoffset.com/game.html
Unreal Engine – http://www.unrealtechnology.com/html/technology/ue30.shtml
C4 Engine – http://www.terathon.com/c4engine/features.php
•
Moreno-Ger P., Martinez-Ortiz I., Sierra J. L., Fernandez-Manjon B. Language-Driven Development
of Videogames: The <e-Game> Experience // Entertainment Computing - ICEC 2006. – Berlin:
Springer, 2006, pp 153-164
Moreno-Ger P., Sierra J. L., Martinez-Ortiz I., Fernandez-Manjon B. A documental approach to
adventure game development // Science of Computer Programming. Volume 67 , Issue 1 (June
2007). – Amsterdam, The Netherlands: Elsevier North-Holland, Inc, 2007, pp 3-31
Hu W. A Reusable Eduventure Game Framework // Transactions on Edutainment I . – Berlin:
Springer, 2008, pp 74-85
Furtado A. W. B., Santos A. L. M., Ramalho G. L. A Computer Games Software Factory and
Edutainment Platform for Microsoft .NET // IET Software. Volume 1, Issue 6, December 2007. –
IEEE, 2007, pp 280 - 293
Amory A. Game object model version II: a theoretical framework for educational game development
// Educational Technology Research and Development. Volume 55, Number 1 / February, 2007 –
Boston: Springer, 2007, pp 51 - 77
•
•
•
•
•
•
Rollings A., Morris D. Game Architecture and Design. A New Edition.– Indianapolis: New Riders
Publishing, 2004
•
Wihlidal G. Game Engine Toolset Development.– Boston, MA: Thomson Course Technology PTR, 2006
References 2
•
•
•
•
•
•
•
•
Clarke E. M., Grumberg O., Peled D. A. Model Checking. - The MIT Press, 1999
V. V. Kulyamin, “Software verification methods,” Russian State Analytical-Review
Articles Contest for Priority Concept “Information-Telecommunication Systems, 2008.
(in Russian.).
Baier Ch., Katoen J.-P., Larsen K. G. Principles of Model Checking. - The MIT Press,
2008
Mosses P. D. Fundamental Concepts and Formal Semantics of Programming
Languages – An Introductory Course. – http://wiki.daimi.au.dk/dSprogSem-01, 2002
Abadi M., Cardelli L. A Theory of Objects. – New York: Springer, 1996
Hoare C. An Axiomatic Basis of Computer Programming. Communications of the
ACM, v.12. – New York: ACM Press, 1969
A. V. Gavrilov, E. A. Pavlova, “Functional interface analysis for formalization of
complex information system design,” Information Technologies, #9, pp. 9-15, 2008.
(in Russian).
E. A. Pavlova, “Design of formal domain-specific language for computer game rules
development for turn-based strategy game genre,” Computer and Information
Technology Reporter #4, April. 2009. (in Russian).
Summary
The approach to game rule development was
suggested. The approach allows
•
•
•
•
formal visual rule design
rule verification
rule-based code and data generation
game class specificity consideration
[email protected]
A type system is a tractable
syntactic method for proving the
absence of certain program
behaviors by classifying phrases
according to the kinds of values
they compute.
Benjamin Pierce ”Types and
Programming Languages”
Object
unit = Unit,
power : 2,
arrows_count : 5,
attackMethod ( unit_to_attack : Unit, cell :
Cell )
{ precondition methodBody postcondition };
Method
attackMethod ( unit_to_attack : Unit,
cell : Cell )
{
( arrows_count > 0 ) and ( power > 1)
methodBody
( arrows_count = arrows_count – 1) and
( power = power – 2 )
};
Reactor method
AddReactor (unit.AttackMethod, army2.OnAttack)
State0
Postcondition
check
Precondition
check
unit.AttackMethod
No
No
State0
State1
Postcondition check
Precondition
check
Army2.OnAttack
No
No
State1
State2
Reactors
AddReactor ( unit.AttackMethod, map.UnitMoved)
AddReactor ( unit.Attackmethod , army2.OnAttack)
State0
unit.AttackMethod
No
No
State1
State0
map.UnitMoved
No
No
State1
State2
army2.OnAttack
No No
State1
State2
No
No
State1
State2
State3
Static balance
• Superior side detection
• Invincible troops detection
• First turn superiority detection
The game is played according to the rules
defined. Players are represented by
simple AI module.
Computer game is a game
represented by a program for
personal computer.
Thus, we don’t consider games for mobile
devices, consoles, etc.
© Copyright 2026 Paperzz