Algorithms and Networking for Computer Games



Model
Synthetic
Driver
Input
device
device
Output
Synthetic
player
Action
State instance
Core structures
Control logic
Proto-view
Configuration
Rendering
Instance data
Script
Options
Human player
Perception
Controller
View
view
Figure 1.2 Model, View, and Controller in a computer game.
(Krasner and Pope 1988) and later on it has been adopted as a basis for object-oriented
programming in general (Gamma et al. 1995). The basic idea is that the representation
of the underlying application domain (Model) should be separated from the way it is pre-
sented to the user (View) and from the way the user interacts with it (Controller). Figure 1.2
illustrates the MVC components and the data flow in a computer game.

The Model part includes software components that are responsible for the coordination
role (e.g. evaluating the rules and upholding the game state). The rules and basic entity
information (e.g. physical laws) form the core structures. It remains unchanged while the
state instance is created and configured for each game process. The core structures need
not cover all the rules, because they can be instantiated. For example, the core structures
can define the basic mechanism and properties of playing cards (e.g. suits and values) and
the instance data can provide the additional structures required for a game of poker (e.g.
ranking of the hands, staking, and resolving ties).

The View part handles the illustration role. A proto-view provides an interface into the