0% found this document useful (0 votes)
13 views6 pages

Procedural Level Design

Fast Procedural Level Population with Playability Constraints The Eighth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment

Uploaded by

Jonathon Cooper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Procedural Level Design

Fast Procedural Level Population with Playability Constraints The Eighth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment

Uploaded by

Jonathon Cooper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Proceedings, The Eighth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment

Fast Procedural Level Population with Playability Constraints


Ian Horswill and Leif Foged
Northwestern University EECS Department
2133 Sheridan Road, Evanston IL 60208
[email protected], [email protected]

Abstract checker, or even as a component of a dynamic difficulty


We examine the use of constraint propagation for adjustment system (Hunicke and Chapman 2003).
populating indoor game levels with enemies and other
objects. We introduce a notion of path constraints, which
bound some function over the possible paths a player might Example
take, and show how to efficiently place objects while
guaranteeing path constraints. This allows the system to Suppose we need to populate a dungeon with monsters and
guarantee that power-ups are balanced to the number of health packs. As a simple example, we will assign to each
enemies occurring in the level, that they’re placed early room either a monster, a health pack, a treasure, or nothing,
enough to be useful, that keys are not hidden behind the
doors they are intended to unlock, and so on. We describe a subject to the constraints:
constraint solver based on interval methods that allows x There must be at least 2 monsters
natural processing of numeric constraints and show that it is x There can’t be more than 2 health packs
efficient enough to be used even on very low-end platforms.
x There must be between 2 and 5 treasure rooms
x The user has a reasonable chance of surviving,
Introduction regardless of what path they take
The first three of these are straightforward combinatorial
Object placement is an important step of level design. search, which we will solve using constraint propagation.
Objects must be placed not only in the right quantities, but The last constraint (survivability) can also be solved
also in the right spatial relationships if the level is to be using constraint propagation; however formulating the
solvable. In this paper, we describe a class of declarative constraint is trickier, since it requires assumptions about
constraints that allow designers to easily specify certain the kinds of paths the player will take through the level.
notions of playability. We then describe a system for To the extent that many levels are effectively linear (Stout
efficient object placement in indoor levels given these 2012), this can be trivial; however, it can also be done for
constraints. more complicated topologies, as we will discuss shortly.
Previous work (A. M. Smith and Mateas 2010; G. Smith Given some set of likely paths, together with an estimate
et al. 2011) has shown that finite-domain constraint solvers of the number of hit points a player will lose while fighting
can be very effective for procedural content generation a monster, we can determine whether a player is likely to
(PCG). However, finite-domain solvers have difficulty survive a level. Consider some path, ‫ ݌‬ൌ ሺ‫ݒ‬଴ ǡ ‫ݒ‬ଵ ǡ ǥ ǡ ‫ݒ‬௡ ሻ.
handling numeric data. We show that by extending finite- We can model the player’s health ݄ሺ‫ݒ‬௜ ሻ at any node (room)
domain techniques with interval methods (Benhamou and ‫ݒ‬௜ along the path from their initial health at ݄ሺ‫ݒ‬଴ ሻ and the
Granvilliers 2006), we can significantly reduce both the estimated health increase or decrease, ȟሺ‫ݒ‬௜ ሻ, incurred
execution time and the memory footprint of the system, while passing through ‫ݒ‬௜ and the previous nodes:
allowing it to be used even on low-end platforms. Our ௜
system is very fast, making it appropriate not only for full ݄ሺ‫ݒ‬௜ ሻ ൌ ݄ሺ‫ݒ‬଴ ሻ ൅ ෍ ȟሺ˜୨ ሻ
PCG in Rogue-like games, but also as a partial automation
௝ୀଵ
tool for designers (G. Smith et al. 2011), a design rule We can model ȟሺ‫ݒ‬ሻ based the item in the room ‫ ;ݒ‬if the
room contains a health pack, ȟሺ‫ݒ‬ሻ is simply the number of
Copyright © 2012, Association for the Advancement of Artificial HP that the health pack restores; if it contains a monster,
Intelligence (www.aaai.org). All rights reserved.

20
it’s the number of hit points a typical player would lose placement (e.g. ܵ ൌ ሼ‡’–›ǡ‘•–‡”ǡЇƒŽ–Š’ƒ ǡ–”‡ƒ•—”‡ሽ
when fighting the monster. Otherwise, it is zero. in the example above; multiple attributes could be used to
The path is then survivable if ݄ሺ‫ݒ‬ሻ ൐ Ͳ for all ‫ ݒ‬along allow rooms to contain multiple items) or room type (e.g.
the path; the level is survivable if every likely path is ܵ ൌ ሼ”‘‘ǡ ‘””‹†‘”ǡ•–ƒ‹” ƒ•‡ǡ‡Ž‡˜ƒ–‘”ሽ). Real-valued
survivable, or if at least some path is survivable, depending attributes can be used to represent general numeric
on the designer’s taste. The designer can also control properties of rooms, such as the amount of gold in the
difficulty by applying upper bounds to ݄ሺ‫ݒ‬ሻ. room. However, we will focus on using them to represent
We will show that this survivability test can be summary information about the other attributes of rooms
efficiently computed using dynamic programming, and and paths, such as expected health or health deltas.
efficiently integrated into a constraint propagation system A constraint is any relation that is required to hold on
to guide item placement. The survivability criterion is the values of attributes. For finite domain attributes, we
tunable, allowing designers to rebalance levels or games will focus on cardinality constraints, which limit the
to perform dynamic difficulty adjustment based on player number of nodes that can be labeled with a specific value
performance; by increasing or decreasing a monster’s (e.g. there must be exactly one boss, there should be 5-10
estimated damage, or by raising the lowering bounds on ݄, monsters), and point constraints (e.g. the last room must
we can make the level easier or harder. be a boss). For real-valued attributes, we will focus on
Health survivability is one example of a path interval constraints, which limit a single node or all nodes
constraint. The same mechanisms can be used to to lie in a certain range (or a single value, if the lower and
implement other path constraints. For example, we can upper bound are the same), and functional constraints,
define ammo survivability in direct analogy: we score where the value of one attribute is constrained to be some
rooms in terms of how they add to or remove from the function of the value of another attribute.
player’s ammo supply, and then test whether the ammo Finally, a scoring ‫ݏ‬ǣ ‫ ܦ‬՜ ܴ is a mapping from some
expected ammo supply goes negative. finite domain ‫ ܦ‬to a number. We will use scorings to
Lock and key problems (locked doors, special items derive real-valued attributes from finite domain attributes.
required to defeat bosses, etc.) can also be phrased as path Let ܽ be some node attribute, then by abuse of notation we
constraints (one per lock); the key has a score of 2, the lock will use ‫ݏ‬ሺܽሻ to denote some real-valued attribute, ݂,
of -1, and the puzzle is solvable if the path function is non- subject to the functional constraint ݂ሺ‫ݒ‬ሻ ൌ ‫ݏ‬ሺܽሺ‫ݒ‬ሻሻ for all
negative and has a value of 1 at the exit. Similarly, object ‫ݒ‬. In the example above, the attribute ȟ was a scoring of
placement behind locked doors can be forced by defining the item placed in the room where:
a path function summing the number of locked doors that െ݇ଵ ǡ ‹ˆ‫ ݔ‬ൌ ‘•–‡”
have been passed through, and requiring that particular
ȟሺ‫ݔ‬ሻ ൌ ൝ ݇ଶ ‹ˆ‫ ݔ‬ൌ ЇƒŽ–Š’ƒ 
types of objects only be placed in rooms of a given lock
Ͳǡ ‘–Ї”™‹•‡
depth.
Again, these path constraints can be used to drive object for some appropriate ݇ଵ ǡ ݇ଶ ൐ Ͳ chosen by the designer.
placement to guarantee that the desired properties are
satisfied, e.g. that the lock is solvable along some paths, or Path constraints
along all paths, if that is preferable. A path function is some summarization of an attribute
over a path. More formally, let ْ be some (associative,
monotone) operator. We will generally use addition for the
Formal definition operator, but others can be useful too, such as
Let ‫ ܩ‬ൌ ሺܸǡ ‫ܧ‬ሻ be a connected, undirected graph multiplication or the max function, or potentially an
representing the level’s topology. Here ܸ is the set of operator over some other simply-ordered set. A path
rooms, corridors, or other spaces in the level, and ‫ ܧ‬is the function ݂ is then any function of the form:
set of doors or other portals connecting them. An
݂ሺ‫݌‬ሻ ൌ ۩௩‫א‬௣ ܽሺ‫ݒ‬ሻ
attribute ܽ ‫ ܸ ׷‬՜ ܵ is then a labeling of the nodes of the
graph, i.e. a function from nodes to some set, ܵ. where ‫ ݌‬is some path in the graph and ܽ is some numeric
Populating a level is then a problem of solving for some set attribute. In the health example above, ݄ is a path function
of user-specified attributes, given another set of user- for which the summation operator is simply ൅ and the
specified constraints. attribute summed over is ȟ.
We will focus on two types of attributes. Attributes Standard paths
whose values are chosen from some small, finite sets, It’s difficult to make guarantees about truly arbitrary paths
called finite domains in the constraint-programming in arbitrary games. For example, if user insists on
literature, will be used to represent properties such as item repeatedly revisiting a trap that removes 10 hit points each

21
time, there is little the designer can do to make that optimization over paths to finding the value of a derived
survivable, short of removing the trap entirely. So we will attribute at a single vertex, it gives a constraint solver an
only consider paths in which the player is making some efficient way of determining whether a given partial
sort of forward progress, as specified by the designer (e.g. assignment of values to nodes potentially violates the
the notion of “flow distance” in Left 4 Dead (Booth 2009)). constraint, allowing early filtering of candidates in the
In particular, we will assume specific nodes are designated search (see below).
as the entrance and exit, and that expected directions of Handling general topologies
travel are provided for each edge in the graph, in the sense As stated before, standard path DAGs do not exist for
that players will “generally” go from room A to room B, many (in fact most) undirected graphs. The problem
rather than from B to A. A path is then a standard path, if comes from cul-de-sac topologies, such as the following:
it starts at the entrance, ends at the exit, and only follows
edges in their expected directions.
More formally, we will define a connected, directed a
subgraph ‫ܩ‬Ԧ of ‫( ܩ‬the undirected graph) to be a standard
path DAG if every vertex of ‫ ܩ‬lies along a path in ‫ܩ‬Ԧ from
the entrance to the exit, or (equivalently), that ‫ܩ‬Ԧ is rooted start b end
at the entrance, and the exit is reachable from every node.
It should be noted that standard path DAGs are not No standard path can exist through ܽ because ܽ has only
unique, so the designer has some leeway in choosing the one edge. Since the edge can only be assigned one
directions of edges. It should also be noted that many direction, a path through ܽ must violate the edge’s
graphs have no standard path DAGs. We will discuss how direction either entering or exiting the node. More
to extend the method to handle these topologies shortly. generally, a cul-de-sac is any group of nodes not including
In PCG scenarios, standard path DAGs can be generated the entrance and exit, which is linked to the rest of the
as part of the topology generation process. When using the graph by only a single edge.
population algorithm as part of a designer-support tool, the There are two approaches to handling culs-de-sac when
designer may prefer to specify edge direction manually. computing path functions. The first is to assume the player
However, SPDs can also be generated fully automatically, never enters the cul-de-sac and simply remove them from
using the algorithm given in the appendix. the DAG entirely. This amounts to assuming the player is
Bounding path functions over standard paths on a speed run, bypassing any unnecessary nodes.
Given a path function ݂ and a standard path DAG ‫ܩ‬Ԧ , we Enforcing path constraints then amounts to enforcing
can compute the minimum of ݂over any standard path solvability on speed runs.
using dynamic programming. Let ݂ሺ‫݌‬ሻ ൌ ۩௩‫א‬௣ ܽሺ‫ݒ‬ሻ for Alternatively, one may assume the player always enters
some ܽ and ْ, and let: culs-de-sac and fully explores them. We can then treat all
the cul-de-sac nodes as if they were part of the entrance to
ܽሺ‫ݒ‬ሻǡ‹ˆ‫ ݒ‬ൌ ‡–”ƒ ‡‘†‡ the cul-de-sac. The entrance then looks like a normal node
݂ ‹ ሺ‫ݒ‬ሻ ൌ ቊ
ܽሺ‫ݒ‬ሻ ْ ‹൫௩ᇲ ǡ௩൯‫א‬஽ ݂ ‹ ሺ‫ ݒ‬ᇱ ሻ ǡ‘–Ї”™‹•‡ with a lot of items in it. We define the support of a node to
be the node, together with the nodes in the culs-de-sac to
That is, to find the value of ݂ ‹ ሺ‫ݒ‬ሻ, we first find its value which it is an entrance:
at all its predecessors in the standard path DAG ‫ܩ‬Ԧ . We
find its minimum over all the predecessors and add the ܵሺ‫ݒ‬ሻ ൌ ሼ‫ݒ‬ሽ ‫ ׫‬ሼ‫ ݒ‬ᇱ ȁ‫ ݒ‬ᇱ ‹ƒ —ŽǦ†‡Ǧ•ƒ ‘ˆ‫ݒ‬ሽ
value of ܽ at the node ‫ݒ‬. The path function ݂ ƒš is defined We then modify the definition of ݂ ‹ to sum over the
analogously, with mins changed to maxes. support of a node:
Proposition: For any vertex ‫ݒ‬, the smallest and largest ܽሺ‫ݒ‬ሻǡ‹ˆ‫ ݒ‬ൌ ‡–”ƒ ‡‘†‡
values of ݂ over any path in ‫ܩ‬Ԧ from the entrance to ‫ ݒ‬are ݂ ‹ ሺ‫ݒ‬ሻ ൌ ൝
ቀْ௩ ᇲ‫א‬ௌሺ௩ሻ ܽሺ‫ݒ‬Ԣሻቁ ْ ‹ ݂ ‹ ሺ‫ ݒ‬ᇱ ሻ ǡ‘–Ї”™‹•‡
given by ݂ ‹ ሺ‫ݒ‬ሻ and ݂ ƒš ሺ‫ݒ‬ሻ, respectively. ᇲ
ሺ௩ ǡ௩ሻ‫א‬஽

Proof: by induction on the depth of ‫( ݒ‬i.e. its distance For this to be well-defined, ْ must be a commutative
from the entrance). operator, so that order doesn’t matter in the sum.
Corollary: The minimum and maximal values of ݂ over This approach has the weakness of ignoring the order in
all standard paths are given by ݂ ‹ ሺ‫ –‹š‡ݒ‬ሻ and which the player encounters cul-de-sac nodes. That
݂ ƒš ሺ‫ –‹š‡ݒ‬ሻ, respectively. weakness can be handled either by recursively forming a
DAG for the cul-de-sac and applying constraints along it,
This then gives us an efficient way of computing the or by imposing design constraints, e.g. that a cul-de-sac
minimal/maximal values of any path function over may contain either enemies or health packs, but not both.
standard paths. More importantly, by reducing an

22
Constraint solving definite ൌ ሼ࢞ ‫ܺ א‬ȁ࢞ ൌ ሼ݇ሽሽ
if (possible < minimum allowed || definite>maximum)
Constraint satisfaction problems (CSPs) involve finding throw failure
values for some set of variables given some set of if (possible = minimum) // make all possible definite
constraints. In our case, we have one variable for each for each ࢞ᇱ ‫ א‬possible, Narrow(࢞Ԣ, ሼ݇ሽሻ
attribute/node pair. That is, a variable represents the value if (definite = maximum)
of a single variable on a single node of the graph. for each ࢞ᇱ ‫ א‬possible // rule out remaining
We solve the CSP using constraint propagation, which if ࢞ᇱ ‫ ב‬definite, Narrow(࢞Ԣ, ࢞ᇱ െ ሼ݇ሽ)
works by considering entire sets of candidate values for }
each variable. Each variable begins with the largest
possible set of candidates. The algorithm then narrows This requires linear time as written, but can be reduced to
those sets in search of specific solutions. Each time a constant amortized time (at the cost of complicating the
variable is narrowed, the values ruled out are propagated undo logic) by caching the possible and minimum counts.
through the constraints on the variable to rule out values of Constraint propagation requires that sets of possible
the other variables involved in the constraint. Those variable values be represented efficiently. Finite domain
narrowings may, in turn, lead to further narrowings, until variables have been highly studied in large part because
the process reaches fixed point. Then another variable is they can be represented efficiently as bitmasks. However,
chosen for narrowing, until all variables have been this forces finite-domain solvers to quantize numeric
narrowed to unique values. variables into a small set of possible values and operate on
The algorithm used here is a standard backtracking those values as a discrete set.
search, combined with a variant of Mackworth’s AC3 A better choice for numeric values is to approximate sets
algorithm (Mackworth 1977). Space precludes a detailed of reals as closed intervals (i.e. ሾ‫ݔ‬ǡ ‫ݕ‬ሿ ‫ ؝‬ሼ‫ݖ‬ȁ‫ ݔ‬൑ ‫ ݖ‬൑ ‫ݕ‬ሽ).
presentation, but see (Rossi et al. 2006) for an extensive Real intervals are closed under addition, subtraction,
survey of constraint algorithms. The heart of the algorithm multiplication, and all monotone functions, and so are
is the three procedures, Solve, Narrow, and Propagate: precise when constraints are limited to these operations.
The propagate method for the constraint ࢞ଵ ൌ ࢞ଶ ൅ ࢞ଷ is
Solve( ) then simply
choose some variable ࢞ that is not already a singleton
for each ‫࢞ א ݔ‬ // Choose some possible value PropagateAddition(ܿǡ ࢞ሻ {
create a new frame on the undo stack if ࢞ ് ࢞ଵ Narrow(࢞ଵ , ࢞ଶ ൅ ࢞ଷ )
try { Narrow(࢞, ሼ‫ݔ‬ሽ); Solve( ) } if ࢞ ് ࢞ଶ Narrow(࢞ଶ , ࢞ଵ െ ࢞ଷ )
catch (failure) { unwind undo stack frame } if ࢞ ് ࢞ଷ Narrow(࢞ଷ , ࢞ଵ െ ࢞ଶ )
}
Narrow(࢞, ‫)ݏ‬ // Narrow variable ࢞ to set ‫ݏ‬
݊ ൌ࢞‫ݏת‬ // New value of ࢞ Where arithmetic on interval-valued variables is defined by
if ݊ empty throw failure ሾܽǡ ܾሿ ൅ ሾܿǡ ݀ሿ ‫ ؝‬ሾܽ ൅ ܿǡ ܾ ൅ ݀ሿ and ሾܽǡ ܾሿ െ ሾܿǡ ݀ሿ ‫ ؝‬ሾܽ െ
if (݊ ് ࢞) ݀ǡ ܾ െ ܿሿ. Propagation for min and max are defined
save ࢞ on undo stack similarly. See (Benhamou and Granvilliers 2006) for a
old = ࢞ more detailed discussion of interval methods in constraint
࢞ؔ݊ processing.
for each constraint ܿ applied to ࢞
Propagate(ܿ, ࢞)
Experimentation
Propagate(ܿ, ࢞), called whenever some variable ࢞,
We implemented the system in C# and tested it on two
constrained by some constraint ܿ, is narrowed, narrows the
different graphs and four different constraint
other variables involved in ܿ, to rule out combinations that
configurations. The “mansion” topology is the west wing
violate the constraint. It dispatches to different methods,
of the first floor of the mansion from the original Resident
depending on the type of constraint. For example,
Evil. Like all RE levels, it is designed as a single, linear
cardinality constraints count the number of variables that
path, with the remaining nodes forming 4 culs-de-sac
could have some specified value ݇, and the number that
along the way. The “quad” topology consists of four
definitely have that value, then compare them to the
copies of the mansion, arranged in a diamond pattern,
minimum and maximum allowed occurrences:
allowing 2 different possible routes. Culs des sacs were
PropagateCardinality(ܿ, ࢞ǡ ݇) { handled using the support method (summation).
ܺ ൌset of variables constrained by ܿ Rooms were assigned contents, either empty, a large or
possible ൌ ሼ࢞ ‫ܺ א‬ȁ݇ ‫࢞ א‬ሽ small health pack or large or small ammo supply, a

23
zombie, two zombies, a zombie dog, a boss, a trap, or a grounded input (based on Windows performance counters),
locked door. Tests varied depending on the bounds of and 1.5GB for doing the grounding itself.
different item types: That said, Clingo is a much more powerful solver; given
sufficient time, it can find solutions to very hard problem
H.Pack Ammo instances (instances that are almost but not quite
Config Zomb 2 Zomb Dog Trap
(S/L) (S/L)
unsolvable) where the interval solver will just thrash. So
Easy 0/1-7 n/a 1-5 1-3 n/a n/a
Med 0/1-40 0/1-40 1-40 1-40 1-2 1 the extra space is worthwhile for hard problems, although
Hard 0/1-40 3 2 2 1-2 1 they would have to be solved off-line.
Big 3-10/3-10 3-10/3-10 5 5 5 2

The “easy” configuration used a reduced version of the Related work


problem involving only health survivability and 6 room Procedural level generation is an active area of research.
contents types. All other configurations involved solving Early efforts date back at least to Rogue (Toy et al. 1980).
simultaneously for health and ammo survivability, as well A number of researchers have examined the problem of
as placing the locked door and boss (who drops the key for populating levels with objects. Ashmore (2007) describes
the door) such that they cannot be bypassed and they are a system for placement of key and lock puzzles
encountered in the right order (boss/key before door). implemented as a set of rules, although it does not provide
Problems become harder as they require more enemies to explicit solvability guarantees. Dormans (2011) presents a
be included, since they requires more ammo and health system for combined topology generation and item
packs, and the solver runs out of rooms to put them in. population using graph rewriting. However, rewrite rules
Execution times for our system, and for Clingo (Gebser must be written to ensure invariants, such as puzzle
et al. 2010), a popular answer-set solver, are shown below.1 solvability. Left 4 Dead’s “Director” (Booth 2009) places
Clingo works by first “grounding” the problem into SAT enemies and items dynamically based on candidate
problem, then optimizing the problem, and finally solving locations specified by designers. It uses a notion of
it. Clingcon (Gebser et al. 2009), which combines ASP “directionality” similar to standard path DAGs to reason
with a FD constraint solver may have performed better, but about which areas are behind or in front of the player.
has not been released as of this writing. The “total” A number of authors have used finite-domain constraint
columns include the time for grounding and optimization, satisfaction for PCG. Tanagra (G. Smith et al. 2011) uses
while the “solve” columns include only the time to solve the CHOCO solver (Jussien et al. 2008) to help generate
the SAT problem. The last line shows the time for Clingo level designs for 2D platformer games. There is also
on pre-grounded input. The total column is then the considerable work by Smith, Mateas, and colleagues on
solving time plus the time needed to read and unpack the using answer-set solvers. DIORAMA (2011) populates
ground form. levels with bases and oil wells subject to distance
constraints. Refraction (2012) automatically generates
Time Clingo (sec) Speedup
Config Map puzzles while guaranteeing solvability and other desired
(sec) Total Solve Total Solve
Easy Mansion 94μs 1.6 0.011 17K 117 properties. Variations Forever (2010) generates entire
Medium Mansion 900μs 7.0 0.016 7818 18 game rule sets using ASP. Nelson (2011) has used logical
Medium Quad 0.019 34.5 0.062 1816 3.26 representations and constraint reasoning for determining
Hard Mansion 0.0079 6.58 0.016 834 2.03
Hard Quad 0.0161 33.8 0.047 2105 2.92 properties of game rule sets such as solvability.
34.7 0.109 632 1.99
Big Quad 0.0549
1.03 0.078 19 1.42
Conclusion
The interval method is quite fast on these problems, Procedural content generation is an interesting domain for
even compared to Clingo on pre-grounded input. It also constraint satisfaction because it is motivated by variety
requires very little storage; we estimate less than 5KW of rather than intrinsic difficulty. CSP systems can perform
data for the big/quad case, small enough to easily fit in very well on these problems, even fast enough for real-time
cache.2 Clingo requires 37MB is data working set for pre- operation, for such problems that have dense solution
spaces. This paper can be seen both as additional support
for the viability of constraint satisfaction, and as the
1
Execution times are averages per solution for the 10,000 randomly introduction of a new, useful class of constraints.
generated solutions. Tests were run on a 2009 laptop, a Sony VGN-
Z691Y/B (2.66GHz Core 2 Duo P9600, 4GB of RAM), running under the
.NET runtime on Windows 7 (64 bit) and using AC power.
2
521 variables (4 words each), 340 constraints (average of 12 words of 2038 (3 words per entry), for a total of 1534KW, plus stack, and GC
each), 1538 constraint arcs (2 words), and a maximum undo stack depth overhead.

24
The choice of representation and solver do have a potential, but non-zero current flow. The cul-de-sac can
profound impact on performance, however. While not then be handled using either of the methods discussed
appropriate for all applications, interval methods offer an above.
easy to implement technology for Rogue-like games that
require fast, in-game solution of simple path constraints.
References
Ashmore, Calvin. 2007. “The quest in a generated world.” Proc.
Appendix: Computing a standard path DAG 2007 Digital Games Research Assoc. 503-509.
We can compute a standard path DAG by treating the Benhamou, Frédéric, and Laurent Granvilliers. 2006. Continuous
and interval constraints. In Handbook of Constraint
graph as a resistor network, connect the entrance and exit
Programming, ed. Francesca Rossi et al. Elsevier.
to a power source, and solving for the directions of the
Booth, Michael. 2009. The AI Systems of Left 4 Dead. In
resulting current flows using Kirchhoff’s and Ohm’s laws. Artificial Intelligence and Interactive Digital Entertainment 2009.
Due to space constraints, we will only sketch the Stanford, CA: AAAI Press.
algorithm, but the approach is conceptually Dormans, Joris. 2011. “Proceedings of the 2nd International
straightforward. Workshop on Procedural Content Generation in Games.”
We construct a linear system with one variable ܸ௝ for Workshop on Procedural Content Generation in.
each node ݆, representing its potential (voltage), and one Gebser, Martin et al. 2009. Constraint Answer Set Solving. In
variable ‫ܫ‬௝ǡ௞ for each edge ሼ݆ǡ ݇ሽ representing the current ICLP ’09 Proceedings of the 25th International Conference on
flow through the edge. From Ohm’s law, we have that Logic Programming, 235 - 249. Pasadena, CA: Springer.
Gebser, Martin et al. 2010. A User ’ s Guide to gringo , clasp ,
ܴ௝ǡ௞ ‫ܫ‬௝ǡ௞ ൌ ሺܸ௞ െ ܸ௝ ሻ clingo , and iclingo ‫כ‬. Potsdam.
where ܴ௝ǡ௞ ൐ Ͳ is an arbitrary constant. The simplest Hunicke, Robin, and Vernell Chapman. 2003. “AI for Dynamic
Difficulty Adjustment in Games.” Proceedings of the Challenges
choice is to set all ܴ௝ǡ௞ to 1, but they can be chosen in Game AI Workshop, Nineteenth National Conference on
randomly or through any policy desired. Now, from Artificial Intelligence: 91–96.
Kirchhoff’s current law, we have that for each node ݆ other Jussien, Narendra et al. 2008. The CHOCO constraint
than the entrance and exit: programming solver. In CPAIOR08 workshop on OpenSource
Software for Integer and Contraint Programming OSSICP08.
෍ ‫ܫ‬௝ǡ௞ ൌ Ͳ Mackworth, Alan K. 1977. “Consistency in networks of
ሼ௝ǡ௞ሽ‫א‬ா relations.” Artificial Intelligence 8: 99-118.
Nelson, Mark J. 2011. Game Metrics Without Players : Strategies
Since all current entering a node must also leave it.
for Understanding Game Artifacts. In Workshop for AI in the
Finally, we set: Game Design Process at AIIDE 2011, 14-18. Stanford, CA:
AAAI Press.
ܸ‡–”ƒ ‡ ൌ ͳ
ܸ‡š‹– ൌ Ͳ Rossi, F et al. 2006. Handbook of Constraint Programming. Ed. F
Rossi et al. Change. Vol. 35. Elsevier.
This gives us a system of ȁܸȁ ൅ ȁ‫ܧ‬ȁ equations and an equal Smith, Adam M, and Michael Mateas. 2010. Variations Forever :
number of unknowns. Solving linear systems generally Flexibly Generating Rulesets from a Sculptable Design Space of
takes cubic time; however very sparse systems such as this Mini-Games. In IEEE Conference on Computational Intelligence
and Games, 273-280. Copenhagen: IEEE Press.
can typically be solved by sparse solvers in linear time.
Having solved for the currentsǡ ‫ܫ‬௝ǡ௞ , we now simply set Smith, Adam M, and Michael Mateas. 2011. “Answer Set
Programming for Procedural Content Generation : A Design
the directions of the edges to the directions of the currents: Space Approach.” IEEE Transactions on Computational
the edge ሼ݆ǡ ݇ሽ goes from ݆ to ݇ if ‫ܫ‬௝ǡ௞ ൐ Ͳ, and ݇ to ݆, if Intelligence and AI in Games 3 (3): 187-200.
‫ܫ‬௝ǡ௞ ൏ Ͳ. Smith, Adam M. et al. 2012. A Case Study of Expressively
The interesting case comes when ‫ܫ‬௝ǡ௞ ൌ Ͳ, i.e. where no Constrainable Level Design Automation Tools for a Puzzle
current flows between nodes ݆ and ݇. There are two cases. Game. In International Conference on the Foundations of Digital
If current flows through both nodes, just not between them, Games. Raleigh: ACM Press.
then we have a situation where the two nodes just happen Smith, Gillian et al. 2011. “Tanagra : Reactive Planning and
to have the same potential, and we can arbitrarily direct the Constraint Solving for Mixed-Initiative Level Design.” IEEE
Transactions on Computational Intelligence, AI and Computer
edge either way, or omit it entirely from the DAG. If one Games 3 (3): 201-215.
of the nodes has no current flowing through it at all, then it
Stout, Michael. 2012. “Learning From The Masters: Level Design
is part of a cul-de-sac. The cul-de-sac to which it belongs In The Legend Of Zelda.” Gamasutra.
will be precisely the connected set of nodes with equal Toy, Michael et al. 1980. Rogue. Computer Science Research
potential and zero current flow, and they will be connected Group, UC Berkeley.
to the main graph by exactly one node with the same

25

You might also like