1. A Case Study ofExpressively ConstrainableLevel Design
Automation Toolsfor a Puzzle GameAdam M. Smith (presenter), Erik
Andersen, Michael Mateas, ZoranPopovidexpressiveintelligencestudio
centerforgamescience UC Santa Cruz University of
[email protected] 2012 Raleigh, USA
2. Refraction (deployed game) Over 495,000 plays on
Kongregate.expressiveintelligencestudio UC Santa Cruz
3. Towards Infinite Refraction Automatically designed levels
& progressions Customization for individual players Educational
soundnessexpressiveintelligencestudio UC Santa Cruz
4. Requirements for Design Automation Solves hard combinatorial
search problems in reasonable amounts of time Small amount of code
Trustable output Hard constraints Global
optimizationexpressiveintelligencestudio UC Santa Cruz
5. Refraction gameplayexpressiveintelligencestudio UC Santa
Cruz
6. Roadmap Design automation problems Original solutions
Introduction to answer set programming (ASP) New solutions
Comparisons: size, speed, style Lessons
learnedexpressiveintelligencestudio UC Santa Cruz
7. Three Design Automation Problems Synthesis Mission
Generation Grid Embedding Analysis Puzzle
Solvingexpressiveintelligencestudio UC Santa Cruz
9. Problem: Grid Embedding Mission
Spaceexpressiveintelligencestudio UC Santa Cruz
10. Example: Puzzle Solving S2 B x S2 S2 x x x x x x x S2 Tgt B
x x x x x 3/4 B B x x E2 B x C2 Tgt Src S2 1/2 1/4 C2 S2 x S2 Src B
x x x x 1/1 B B x x x Puzzle Solutionexpressiveintelligencestudio
UC Santa Cruz
11. Six Design Automation Tools Problem Original Approach New
Approach Mission Generation Custom, feed-forward ASP (AnsProlog +
Lua) algorithm (Java) Grid Embedding Depth-first search (Java) ASP
(AnsProlog) Puzzle Solving Depth-first search (Java) ASP (AnsProlog
+ Lua) S2 B x S2 S2 x x x x x x x S2 Tgt B x x x x x 3/4 B B x x E2
B x C2 Tgt Src S2 1/2 1/4 C2 S2 x S2 Src B x x x x 1/1 B B x x
xexpressiveintelligencestudio UC Santa Cruz
12. Original Mission Generator Custom feed-forward algorithm:
Several stages that iteratively expand graph Expression translation
Opportunistic connection Target completion Note: Common PCG
strategy Output meets requirements by
constructionexpressiveintelligencestudio UC Santa Cruz
13. Original Grid Embedder Depth-first search: Transfer pieces
from mission to spots on grid one- by-one Notes: This is a tough
combinatorial search problem! DFS is complete on finite problems.
A* would be faster, but more complex. We want to maintain less
code!expressiveintelligencestudio UC Santa Cruz
14. Original Puzzle Solver Depth-first search: Place pieces
from tray one-by-one Note: Harder: math not resolved, no solution
template A* ... we really want more control over
solutions!expressiveintelligencestudio UC Santa Cruz
15. Brief intro to ASP (not Prolog!) ASP (answer set
programming) is a declarative logic programming paradigm focused on
complex (NP and NPNP) combinatorial search an optimization
problems. Overview: Designer defines problem (in AnsProlog syntax).
Grounder transforms problem into SAT-like. High-performance solver
enumerates solutions.expressiveintelligencestudio UC Santa
Cruz
16. Answer Set Program Design Guess a solution so that none of
its deduced properties are forbidden, optionally optimizing a
metric.expressiveintelligencestudio UC Santa Cruz
17. Answer Set Program Design Which two numbers that multiply
to 42 have the smallest sum? % guess two numbers 2 { picked(1..42)
} 2. % deduce if they multiply to 42 product_ok :- picked(A),
picked(B), 42==A*B. % forbid lack of proper product :- not
product_ok. % optimize (weighted) sum #minimize [ picked(A)=A
].expressiveintelligencestudio UC Santa Cruz
18. New Grid Embedder Answer Set Program: Guess: Absolute
positions for pieces (x;y) Directions for laser ports (n;e;w;s)
Deduce: Relative positions from absolute positions Free paths from
relative positions Beam production from free paths Expression
instantiation from beams Forbid: Overlapping pieces Lack of
embedding for mission edges Illegal port configurations Notes: How
do I place and configure the pieces so that the apparent mission
subsumes the required mission? This tool involves 75 lines of
code.expressiveintelligencestudio UC Santa Cruz
19. New Mission Generator Answer Set Program: Guess node and
edge descriptions so that required expressions and piece counts are
satisfied. Notes: What vs. How clarifies problem Now easy to drop
in additional constraints without redesign. Concatenate this with
embedder to make monolithic generator!expressiveintelligencestudio
UC Santa Cruz
20. New Puzzle Solver Answer Set Program: Guess placement of
player pieces so that all targets are powered correctly. Notes:
100% faithful model of game How many pieces are used in the
simplest solution that does not cross any beams or use an
expander?expressiveintelligencestudio UC Santa Cruz
21. Code Size Comparison Problem Original Solution New Solution
Mission Generation 1,145 Java 194 AnsProlog + 38 Lua Grid Embedding
987 Java 75 AnsProlog + 0 Lua Puzzle Solving 988 Java 83 AnsProlog
+ 61 Lua Improvements: - Much smaller than even simple custom
algorithms - No procedural commitments - Freely include extra
constraints in inputexpressiveintelligencestudio UC Santa Cruz
22. Search Time Comparison Problem Java Search ASP Search
Mission Generation < 1 ms. < 1 ms. Grid Embedding 650 ms.*
110 ms. Puzzle Solving No solutions within 350 ms. one hour* *
Including an advanced feature borrowed from the answer set solver.
Problems derived from running example: (representative of
late-stage gameplay)expressiveintelligencestudio UC Santa Cruz
23. Embedding Style Examplesexpressiveintelligencestudio UC
Santa Cruz
24. Lessons Learned We rebuilt our design automation tools for
a real, deployed game on a substrate that natively understood hard
constraints and global optimization and they were smaller and went
a bit faster. and they transformed the way were designing our new
game.expressiveintelligencestudio UC Santa Cruz
25. Design Process Impact Got out of the search algorithm
design business Got into the expressive authoring business We
clarified our design automation problems Found new uses for tools:
Mission Gen. + Grid Embed. = Unified Puzzle Synthesizer Solver =
Puzzle Analysis Power Tool Discovered new constraints: Stylistic
Educational Gained rapid prototyping
toolsexpressiveintelligencestudio UC Santa Cruz