ing languages are often part of IDEs
(such as the one shown in Figure 1)
that provide forms for quickly modifying these attributes. The scripting languages themselves, however, are fairly
conventional. Many companies use
traditional scripting languages such as
Lua or Python for scripting. Even companies that design their own languages
usually stick with traditional format
and control structures. Little effort has
been spent tailoring these scripting
languages for games.
One of the major problems with traditional scripting languages is that the
programmer must be explicitly aware
of low-level processing issues that have
little to do with gameplay. Performance
is a classic example of such a low-level
issue. Animation frame rate is so important to developers that they optimize by counting the number of multiplies or adds in their code. This type
of analysis is beyond the skill of most
designers, however. Furthermore, existing languages provide almost no
tools to help designers improve script
performance.
Designers must also take performance into account when creating content. If the game runs too slowly, they
may be forced to reduce the number of
objects in the game, which in turn can
significantly alter the playing experience. This is what occurred when The
Sims was ported to consoles. In this
game, a player indirectly controls a
character (Sim) by purchasing furniture
or other possessions for it. Each piece
of furniture is scripted to advertise its
capabilities to the Sim periodically. The
Sim then compares these capabilities
with its needs in order to determine its
next action. Furniture does not exist in
isolation, however; a couch in front of a
television is much more versatile than
one alone in a room. Therefore, pieces
of furniture also periodically poll the
other furniture in the room to update
their capabilities. As each piece of furniture may communicate with other
pieces of furniture, the cost of processing a room can grow quadratically with
the number of objects in the room.
When the title was ported to consoles,
the performance issue became so pronounced that the designers had to introduce a “feng shui meter” to prevent
players from filling rooms with too
many possessions.
Game developers have many techniques available to them for improving
performance. Spatial indexes are one
popular way of handling interactions
between game objects at less than quadratic cost. Parallel execution is another possibility; many games are embarrassingly parallel, and developers
leverage this fact for multicore CPUs
and distributed multiplayer environments. These techniques are beyond
the skill of the typical game designer,
however, and are left to the software
engineers.
Another low-level issue with scripting languages is the lack of transac-
tion support for massively multiplayer
games. Individual scripts are often executed concurrently, particularly in massively multiplayer games, so designers
need some form of transaction to avoid
inconsistent updates to the game state.
Indeed, script-level concurrency violations are one of the major causes of
bugs in multiplayer environments.
To make scripting easier for designers, we have to provide them with simple tools for addressing these low-level
issues. None of these problems is really
new; many programming languages
have been developed over the years to
address them, but most of these languages make programming more difficult, not easier. Fortunately, designers
do not need an arbitrary scripting language; they just need a language that
helps them write games.
from Patterns to
Language features
Despite these problems, games are being developed. Game developers have
come up with many ideas that, if not
complete solutions, do ameliorate the
problems. These ideas typically come in
the form of programming patterns that
have proven over time to be successful.
Though developers use these programming patterns in creating game behavior, the scripting languages usually do
not support them explicitly. One of the
reasons object-oriented programming
languages have been so successful is
that object-oriented programming patterns existed long before the languages
that supported them. Similarly, by examining existing programming practices in game development, we can design scripting languages that require
very little retraining of developers. The
challenge in developing a scripting language is identifying those patterns and
creating language features to support
them most effectively.
figure 1. the neverwinter nights 2 toolset is an extensive iDe that allows users to create
new content for the game.
the state-effect Pattern
One popular pattern in game development is the state-effect pattern. Every
game consists of a long-running simulation loop. The responsiveness of the
game to player input depends entirely
on the speed at which the simulation
loop can be processed. In the state-effect pattern, each iteration of the simulation loop consists of two phases:
effect and update. In the effect phase,