Computational Complexity of Game and Puzzles
Total Page:16
File Type:pdf, Size:1020Kb
Computational Complexity of Games and Puzzles Diogo Manuel dos Santos Costa Thesis to obtain the Master of Science Degree in Information Systems and Computer Engineering Supervisors: Prof. Lu´ıs Manuel Silveira Russo Prof. Alexandre Paulo Lourenc¸o Francisco arXiv:1807.04724v1 [cs.CC] 12 Jul 2018 July 2018 Abstract In this thesis, we survey techniques and results from the study of Complexity Theory and Games. We then apply these techniques to obtain new results for previously unstudied games. Our contributions in the games Hexiom, Cut the Rope, and Back to Bed may be helpful in further studies by exploiting structure common to several games. We also highlight some interesting paths for further study, related to uncertainty, that have yet to receive thorough study given their prevalence in today’s games. Keywords games, puzzles, complexity, reductions i Resumo Nesta tese, estudamos varias´ tecnicas´ e resultados da relac¸ao˜ entre a Teoria da Complexidade e Jogos. Usamos as tecnicas´ estudadas para obter novos resultados. As nossas contribuic¸oes˜ para com os jogos Hexiom, Cut the Rope e Back to Bed poderao˜ ser uteis´ para obter futuros resultados noutros jogos, porque tiram partido de estrutura comum a varios´ jogos que ainda nao˜ foram estudados. Tambem´ salientamos poss´ıveis direcc¸oes˜ para estudo adicional, especialmente em relac¸ao˜ a` incerteza, algo prevalente nos jogos modernos mas ainda pouco estudado. Palavras Chave jogos, puzzles, complexidade, reduc¸oes˜ iii Contents 1 Introduction 2 1.1 Motivation . .3 1.1.1 “Serious” Games . .4 1.1.2 Game Design . .4 1.2 Objectives . .5 1.3 Structure . .5 2 Background 7 2.1 Introduction to Complexity Theory and Important Results and Problems . .9 2.1.1 Basic Notions & Definitions . .9 2.1.2 Complexity Classes . 10 2.1.3 Membership, Hardness & Completeness . 11 2.1.4 Reductions . 13 2.1.5 Original Problems . 14 2.2 Related Work . 15 2.2.1 Partition & Packing Problems . 16 2.2.2 Hamiltonicity . 16 2.2.3 CircuitSAT & Nikoli games . 16 2.2.4 Video Games . 17 2.2.5 Non-Deterministic Constraint Logic . 18 2.2.6 Two Player Games of Perfect Information . 19 2.3 Frameworks . 19 2.3.1 Gadgets . 19 2.3.2 Circuit SAT . 20 2.3.3 3-CNFSAT . 20 2.3.4 Hamiltonian Cycle . 22 2.3.5 TQBF . 23 2.4 Example Proofs . 27 v 2.4.1 Akari . 27 2.4.2 Super Mario Bros. 31 2.4.3 The Legend of Zelda: A Link to the Past . 34 3 Results 39 3.1 Approach . 41 3.1.1 Circuit SAT . 41 3.1.2 3-CNFSAT . 43 3.1.3 TQBF . 43 3.1.4 NP and PSPACE ..................................... 44 3.2 Cut the Rope (3-CNFSAT) . 44 3.3 Hexagonal Akari (CircuitSAT) . 49 3.4 Offspring Fling (TQBF) . 52 3.5 Super Meat Boy . 55 3.6 Triangular Akari (CircuitSAT) . 58 3.7 HexCells (CircuitSAT) . 61 3.8 Hexiom (CircuitSAT) . 65 3.9 Back To Bed (TQBF) . 71 4 Final Remarks 79 4.1 Bloxorz - a Puzzle Game based on an “Easy” Mechanic . 81 4.1.1 Movement Complexity . 81 4.1.2 General Complexity . 83 4.1.3 Conclusion . 83 4.2 Guessing . 83 4.2.1 Guessing and Propagation . 84 4.2.2 Guessing and Co-NP . 84 4.2.3 Conclusion . 85 4.3 Puzzle games with Hidden Information - PSPACE and co-NP . 85 4.3.1 Games Against Nature . 85 4.3.2 Revealing Hidden Information. 85 4.3.3 PSPACE or Co-NP? . 85 4.3.4 Conclusion . 86 4.4 MaxSAT & Optimization . 86 4.4.1 MaxSAT . 86 4.4.2 Application to Games . 86 4.4.3 Conclusion . 87 vi 4.5 Conclusion . 88 A Instance Examples 95 A.1 Cut the Rope . 95 A.2 Hexagonal Akari . 96 A.3 Triangular Akari . 97 A.4 Offspring Fling . 98 A.5 Super Meat Boy . 103 A.6 HexCells . 104 A.7 Hexiom . 105 A.8 Back to Bed . 108 vii viii List of Figures 2.1 NP-Hardness framework from [1]................................. 21 2.2 PSPACE-Hard framework from [1]................................ 24 2.3 TQBF gadgets from [1]. ..................................... 25 2.4 Puzzle example. 28 2.5 Akari’s gadgets NP-Hard. 29 2.6 Super Mario Bros.’s gadgets from [1]............................... 33 2.7 Zelda’s crossover gadget from [1]. ............................... 35 2.8 Zelda’s door gadget from [1]. .................................. 36 3.1 Individual gate conversion to NAND gates only. 42 3.2 (x ⊕ y) _ (:x ^ z) before and after NAND conversion. 42 3.3 Crossover gadget using XOR gates. 42 3.4 Cut the Rope elements required for the proof . 45 3.5 Cut the Rope gadgets. 46 3.6 Lamp (center) propagating light. 49 3.7 Hexagonal Akari’s gadgets. 50 3.8 Offspring Fling’s movement and carrying constraints. 53 3.9 Offspring Fling’s toggle switch. 53 3.10 Offspring Fling’s gadgets. 54 3.11 Super Meat Boy mechanics. 56 3.12 Super Meat Boy gadgets. 57 3.13 Light propagation for triangular grids. ..