Synthesizing Interpretable Strategies for Solving Puzzle Games
Total Page:16
File Type:pdf, Size:1020Kb
Synthesizing Interpretable Strategies for Solving Puzzle Games Eric Butler Emina Torlak Zoran Popovic´ [email protected] [email protected] [email protected] Paul G. Allen School of Computer Paul G. Allen School of Computer Paul G. Allen School of Computer Science and Engineering Science and Engineering Science and Engineering University of Washington University of Washington University of Washington ABSTRACT Understanding how players interact with games is an important challenge for designers. When playing games centered around problem solving, such as logic puzzles like Sudoku or Nonograms, people employ a rich structure of domain-specic knowledge and strategies that are not obvious from the description of a game’s rules. is paper explores automatic discovery of player-oriented knowl- edge and strategies, with the goal of enabling applications ranging from diculty estimation to puzzle generation to game progression analysis. Using the popular puzzle game Nonograms as our target Figure 1: An example of a Nonograms puzzle, with the start domain, we present a new system for learning human-interpretable state on the le and completed puzzle on the right. e num- rules for solving these puzzles. e system uses program synthesis, bered hints describe how many contiguous blocks of cells powered by an SMT solver, as the primary learning mechanism. are lled with true. We mark cells lled with true as a black e learned rules are represented as programs in a domain-specic square and cells lled with false as a red X. We use the X to language for condition-action rules. Given game mechanics and a distinguish from unknown cells, which are blank. training set of small Nonograms puzzles, our system is able to learn sound, concise rules that generalize to a test set of large real-world puzzles. We show that the learned rules outperform documented eectiveness [38]. One potential use is automatically understand- strategies for Nonograms drawn from tutorials and guides, both in ing game strategies: if we can analyze the rules of the game and terms of coverage and quality. automatically deduce what the eective player strategies are, we can support a range of intelligent tools for design feedback, con- CCS CONCEPTS tent generation, or diculty estimation. For humans to use these •Computing methodologies →Articial intelligence; computer-generated strategies, they need the strategies to be both eective in the domain of interest and concisely expressed so a KEYWORDS designer can understand the whole strategy in their mind. Automated Game Analysis, Program Synthesis, Articial Intelli- Modeling player interaction is challenging because the game gence mechanics do not fully capture how human players might approach the game. is is true for all games, but especially for logic puzzle ACM Reference format: Eric Butler, Emina Torlak, and Zoran Popovic.´ 2017. Synthesizing Inter- games such as Sudoku or Nonograms. ese puzzles are straight- pretable Strategies for Solving Puzzle Games. In Proceedings of FDG’17, forward for a computer to solve mechanically by reduction to SAT Hyannis, MA, USA, August 14-17, 2017, 12 pages. or brute-force search, but humans solve them in very dierent DOI: 10.1145/3102071.3102084 ways. Rather than search, human players use a collection of in- terconnected strategies that allow them to make progress without 1 INTRODUCTION guessing. For example, there are dozens of documented strategies for Sudoku1 [33], and puzzle designers construct puzzles and rank Automated game analysis is a growing research area that aims to their diculty based on which of these strategies are used [34]. e uncover designer-relevant information about games without hu- strategies take the form of interpretable condition-action rules that man testing [21, 24, 31, 35], which can be particularly advantageous specify (1) where a move can be made, (2) what (easy-to-check) in situations where human testing is too expensive or of limited conditions must hold to make it, and (3) how to make the move. Permission to make digital or hard copies of all or part of this work for personal or Human players solve puzzles by looking for opportunities to apply classroom use is granted without fee provided that copies are not made or distributed these strategies rather than by manual deduction or search in the for prot or commercial advantage and that copies bear this notice and the full citation problem space. on the rst page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permied. To copy otherwise, or Learning and applying these strategies is the core of human republish, to post on servers or to redistribute to lists, requires prior specic permission expertise in the game. Understanding these strategies as a designer and/or a fee. Request permissions from [email protected]. allows one to eectively build and analyze puzzles and progressions. FDG’17, Hyannis, MA, USA © 2017 Copyright held by the owner/author(s). Publication rights licensed to ACM. While many such strategies can be uncovered through user testing 978-1-4503-5319-9/17/08...$15.00 DOI: 10.1145/3102071.3102084 1hp://www.sudokuwiki.org/Strategy Families contains a rather extensive list. FDG’17, August 14-17, 2017, Hyannis, MA, USA Eric Butler, Emina Torlak, and Zoran Popovic´ and designer introspection, they may not eectively cover the the resulting large set of rules to an optimal subset that strikes a puzzle design space or be the most useful or simple strategies. balance between game-state coverage and conciseness according Designers can benet from tools that, given a game’s rules, can to the given cost function. We evaluate the system by comparing help understand its strategy space. While we would prefer nding its output to documented strategies for Nonograms drawn from strategies people use, as a necessary step, we must nd strategies tutorials and guides, nding that it fully recovers many of these we can easily understand and can demonstrate are eective for the control rules and covers nearly all of game states covered by the problem-solving task. remaining rules. In this paper, we investigate automatically learning human- Our approach to learning interpretable strategies by representing friendly game playing strategies expressed as condition-action rules. them as condition-action rules dened over domain-specic con- We focus on the popular puzzle game Nonograms, also known as cepts is motivated by cognitive psychology and education research. Picross, Hanjie, O’Ekaki, or Paint-by-Numbers. A nonogram (see In this approach, a set of rules represents (a part of) domain-specic Figure 1) is a puzzle in which the player must ll in a grid of cells procedural knowledge of the puzzle game—the strategies a person with either true (black square) or false. Integer hints are given for takes when solving problems. Such domain-specic knowledge is each row and column that specify how many contiguous segments crucial for expert problem solving in a variety of domains [3, 8], of lled cells exist in each row or column. Solutions oen form from math to chess to professional activities. e DSL denes the interpretable pictures, though this is not necessary. By convention, (domain-specic) concepts and objects to which the player can refer nonograms have unique solutions and, like other logic puzzles such when solving puzzles, thus constraining the space of strategies that as Sudoku, can be solved by deducing parts of the answer in any can be learned to human-friendly ones. Our system takes this space order. Also like many logic puzzles, Nonograms is, for arbitrarily as input provided by a designer, and produces the procedural knowl- sized puzzles, NP-complete [37], but typical puzzles used in com- edge to be used by players. us, the designer can dene (and iterate mercial books and games can oen be solved with a xed set of on) the concepts over which rules are dened. e designer also greedy strategies. Even for puzzles that require some tricky moves, provides a cost function (dened over the syntax of the DSL) that greedy strategies can suce to nd a large portion of the solution. measures interpretability in terms of rule complexity, which allows A key challenge in learning these strategies is interpretability: the our system to bias the learning process toward concise, interpretable learned strategies need to be expressed in terms of game-specic rules. e eventual goal of this line of research is automatically concepts meaningful to human players, such as, in the case of discovering strategies that players are likely to use. In this work, we Nonograms, the numerical hints or state of the board. To address focus on the immediate task of nding human-interpretable rules this challenge, we developed a new domain-specic programming in a structure compatible with evidence of how players behave. language (DSL) for modeling interpretable condition-action rules. While our implementation and evaluation focuses on Nono- In contrast to previous DSLs designed for modeling games [5, 18, 23, grams, the system makes relatively weak assumptions (discussed in 24, 27], which focus on encoding the rules and representations of the detail) about the DSL used as input. Variations could be used, and game, our DSL focuses on capturing the strategies that a player can we expect DSLs representing other logic puzzles could be used in the use when puzzle solving. us, the constructs of the language are system. And while many parts of the learning mechanism are spe- game-specic notions, such as hint values and the current state of cic to logic puzzles, we expect the approach of using program syn- the board. In this way, we frame the problem of discovering player thesis for learning of human-interpretable strategies to apply more strategies for Nonograms as the problem of nding programs in our broadly, especially to domains with well-structured problem solving DSL that represent (logically) sound, interpretable condition-action (even beyond games, such as solving algebraic equations [7]).