arxiv:cs/ v2 [cs.cc] 27 Jul 2001

Similar documents
Lecture 19 November 6, 2014

arxiv: v1 [cs.cc] 12 Dec 2017

Amazons, Konane, and Cross Purposes are PSPACE-complete

GEOGRAPHY PLAYED ON AN N-CYCLE TIMES A 4-CYCLE

arxiv: v1 [cs.cc] 14 Jun 2018

Generalized Amazons is PSPACE Complete

Scrabble is PSPACE-Complete

STRATEGY AND COMPLEXITY OF THE GAME OF SQUARES

Alessandro Cincotti School of Information Science, Japan Advanced Institute of Science and Technology, Japan

Pennies vs Paperclips

Lecture 20 November 13, 2014

Which Rectangular Chessboards Have a Bishop s Tour?

arxiv: v2 [cs.cc] 29 Dec 2017

More NP Complete Games Richard Carini and Connor Lemp February 17, 2015

Legend. The Red Goal. The. Blue. Goal

PRIMES STEP Plays Games

Easy Games and Hard Games

Senior Math Circles February 10, 2010 Game Theory II

One-Dimensional Peg Solitaire, and Duotaire

2048 IS (PSPACE) HARD, BUT SOMETIMES EASY

Problem Set 4 Due: Wednesday, November 12th, 2014

arxiv: v1 [math.co] 30 Jul 2015

On the fairness and complexity of generalized k-in-a-row games

Game Values and Computational Complexity: An Analysis via Black-White Combinatorial Games

arxiv: v1 [cs.cc] 21 Jun 2017

1 In the Beginning the Numbers

Narrow misère Dots-and-Boxes

Pearl Puzzles are NP-complete

Fraser Stewart Department of Mathematics and Statistics, Xi An Jiaotong University, Xi An, Shaanxi, China

arxiv:cs/ v1 [cs.cc] 11 Jun 2001

The first player to construct his or her obelisk is the winner, and if a player has no legal moves, he or she immediately loses the game.

How hard are computer games? Graham Cormode, DIMACS

Odd king tours on even chessboards

arxiv: v2 [cs.cc] 18 Mar 2013

Grade 6 Math Circles Combinatorial Games - Solutions November 3/4, 2015

Movement of the pieces

Circular Nim Games. S. Heubach 1 M. Dufour 2. May 7, 2010 Math Colloquium, Cal Poly San Luis Obispo

arxiv: v2 [cs.cc] 20 Nov 2018

The Complexity of Generalized Pipe Link Puzzles

DELUXE 3 IN 1 GAME SET

SOLITAIRE CLOBBER AS AN OPTIMIZATION PROBLEM ON WORDS

Open Problems at the 2002 Dagstuhl Seminar on Algorithmic Combinatorial Game Theory

Super Mario. Martin Ivanov ETH Zürich 5/27/2015 1

Grade 6 Math Circles Combinatorial Games November 3/4, 2015

New Toads and Frogs Results

Grade 7/8 Math Circles Game Theory October 27/28, 2015

arxiv: v1 [cs.cc] 7 Mar 2012

On Variations of Nim and Chomp

Three Pile Nim with Move Blocking. Arthur Holshouser. Harold Reiter.

The Complexity of Escaping Labyrinths and Enchanted Forests

Playing games with algorithms: Algorithmic Combinatorial Game Theory

Analysis of Don't Break the Ice

VARIATIONS ON NARROW DOTS-AND-BOXES AND DOTS-AND-TRIANGLES

Solitaire Games. MATH 171 Freshman Seminar for Mathematics Majors. J. Robert Buchanan. Department of Mathematics. Fall 2010

Light Up is NP-complete

Computational complexity of two-dimensional platform games

depth parallel time width hardware number of gates computational work sequential time Theorem: For all, CRAM AC AC ThC NC L NL sac AC ThC NC sac

Variations on Instant Insanity

Jamie Mulholland, Simon Fraser University

Surreal Numbers and Games. February 2010

OCTAGON 5 IN 1 GAME SET

Graphs of Tilings. Patrick Callahan, University of California Office of the President, Oakland, CA

Faithful Representations of Graphs by Islands in the Extended Grid

The game of Paco Ŝako

Gradual Abstract Proof Search

A GRAPH THEORETICAL APPROACH TO SOLVING SCRAMBLE SQUARES PUZZLES. 1. Introduction

Crossing Game Strategies

Game Theory and an Exploration of 3 x n Chomp! Boards. Senior Mathematics Project. Emily Bergman

Ian Stewart. 8 Whitefield Close Westwood Heath Coventry CV4 8GY UK

Easy to Win, Hard to Master:

Week 1. 1 What Is Combinatorics?

EXPLORING TIC-TAC-TOE VARIANTS

Mind Ninja The Game of Boundless Forms

Combined Games. Block, Alexander Huang, Boao. icamp Summer Research Program University of California, Irvine Irvine, CA

Introduction to Computing 2014 Assignment 4 (Preliminary Version) Simple Checkers Game

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

arxiv:cs/ v2 [cs.cc] 22 Apr 2008

Obliged Sums of Games

arxiv: v1 [cs.cc] 16 May 2016

Figure 1: The Game of Fifteen

arxiv:math/ v1 [math.co] 22 Aug 2000

MULTINATIONAL WAR IS HARD

On Variants of Nim and Chomp

1, 2,, 10. Example game. Pieces and Board: This game is played on a 1 by 10 board. The initial position is an empty board.

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH1301 DISCRETE MATHEMATICS. Time Allowed: 2 hours

Solving the Rubik s Cube Optimally is NP-complete

Nim is Easy, Chess is Hard But Why??

5.4 Imperfect, Real-Time Decisions

Nontraditional Positional Games: New methods and boards for playing Tic-Tac-Toe

GO is Polynominal-Space Hard

Boulder Chess. [0] Object of Game A. The Object of the Game is to fill the opposing Royal Chambers with Boulders. [1] The Board and the Pieces

Kaboozle Is NP-complete, even in a Strip

Two Parity Puzzles Related to Generalized Space-Filling Peano Curve Constructions and Some Beautiful Silk Scarves

Conway s Soldiers. Jasper Taylor

Tic-Tac-Toe on graphs

I.M.O. Winter Training Camp 2008: Invariants and Monovariants

Mathematics of Magic Squares and Sudoku

The patterns considered here are black and white and represented by a rectangular grid of cells. Here is a typical pattern: [Redundant]

In Response to Peg Jumping for Fun and Profit

The Computational Complexity of Games and Puzzles. Valia Mitsou

Transcription:

Phutball Endgames are Hard Erik D. Demaine Martin L. Demaine David Eppstein arxiv:cs/0008025v2 [cs.cc] 27 Jul 2001 Abstract We show that, in John Conway s board game Phutball (or Philosopher s Football), it is NPcomplete to determine whether the current player has a move that immediately wins the game. In contrast, the similar problems of determining whether there is an immediately winning move in checkers, or a move that kings a man, are both solvable in polynomial time. 1 Introduction John Conway s game Phutball [1 3, 13], also known as Philosopher s Football, starts with a single black stone (the ball) placed at the center intersection of a rectangular grid such as a Go board. Two players sit on opposite sides of the board and take turns. On each turn, a player may either place a single white stone (a man) on any vacant intersection, or perform a sequence of jumps. To jump, the ball must be adjacent to one or more men. It is moved in a straight line (orthogonal or diagonal) to the first vacant intersection beyond the men, and the men so jumped are immediately removed (Figure 1). If a jump is performed, the same player may continue jumping as long as the ball continues to be adjacent to at least one man, or may end the turn at any point. Jumps are not obligatory: one can choose to place a man instead of jumping. The game is over when a jump sequence ends on or over the edge of the board closest to the opponent (the opponent s goal line) at which point the player who performed the jumps wins. It is legal for a jump sequence to step onto but not over one s own goal line. One of the interesting properties of Phutball is that any move could be played by either player, the only partiality in the game being the rule for determining the winner. It is theoretically possible for a Phutball game to return to a previous position, so it may be necessary to add a loop-avoidance rule such as the one in Chess (three repetitions allow a player to claim a draw) or Go (certain repeated positions are disallowed). However, repetitions do not seem to come up much in actual practice. It is common in other board games 1 that the problems of determining the outcome of the game (with optimal play), or testing whether a given move preserves the correct outcome, are PSPACEcomplete [5], or even EXPTIME-complete for loopy games such as Chess [8] and Go [11]. However, no such result is known for Phutball. Here we prove a different kind of complexity result: University of Waterloo, Department of Computer Science, Waterloo, Ontario N2L 3G1, Canada, {eddemaine,mldemaine}@uwaterloo.ca University of California, Irvine, Department of Information and Computer Science, Irvine, CA 92697-3425, USA, eppstein@ics.uci.edu 1 More precisely, since most games have a finite prescribed board size, these complexity results apply to generalizations in which arbitrarily large boards are allowed, and in which the complexity is measured in terms of the board size. 1

Figure 1: A jump in Phutball. Left: The situation prior to the jump. Right: The situation after jumping two men. The same player may then jump the remaining man. the problem of determining whether a player has a move that immediately wins the game (a mate in one, in chess terminology) is NP-complete. Such a result seems quite unusual, since in most games there are only a small number of legal moves, which could all be tested in polynomial time. The only similar result we are aware of is that, in Twixt, it is NP-complete to determine whether a player s points can be connected to form a winning chain [10]. However, the Twixt result seems to be less applicable to actual game play, since it depends on a player making a confusing tangle of his own points, which does not tend to occur in practice. The competition between both players in Phutball to form a favorable arrangement of men seems to lead much more naturally to complicated situations not unlike the ones occurring in our NP-completeness proof. 2 The NP-Completeness Proof Testing for a winning jump sequence is clearly in NP, since a jump sequence can only be as long as the number of men on the board. As is standard for NP-completeness proofs, we prove that the problem is hard for NP by reducing a known NP-complete problem to it. For our known problem we choose 3-SAT: satisfiability of Boolean formulae in conjunctive normal form, with at most three variables per clause. We must show how to translate a 3-SAT instance into a Phutball position, in polynomial time, in such a way that the given formula is solvable precisely if there exists a winning path in the Phutball position. The overall structure of our translation is depicted in Figure 2, and a small complete example is shown in Figure 6. We form a Phutball position in which the possible jump sequences zigzag horizontally along pairs of lines, where each pair represents one of the variables in the given 3-SAT instance. The path then zigzags vertically up and down along triples of lines, where each triple represents one of the clauses in the 3-SAT instance. Thus, the potential winning paths are formed by choosing one of the two horizontal lines in each pair (corresponding to selecting a truth value for each variable) together with one of the three vertical lines in each triple (corresponding to selecting which of the three variables has a truth value that satisfies the clause). By convention, we associate paths through the upper of a pair of horizontal lines with assignments that set the corresponding variable to true, and paths through the lower of the pair with assignments that set the variable to false. The horizontal and vertical lines interact at certain marked crossings in a way that forces any path to correspond to a satisfying truth assignment. We now detail each of the components of this structure. Fan-in and fan-out. At the ends of each pair or triple of lines, we need a configuration of men that allows paths along any member of the set of lines to converge, and then to diverge again at 2

Figure 2: Overall plan of the NP-completeness reduction: a path zigzags through horizontal pairs of lines (representing variables) and vertical triples of lines (representing clauses). Certain variableclause crossings are marked, representing an interaction between that variable and clause. the next pair or triple. Figure 3 depicts such a configuration for the triples of vertical lines; the configuration for the horizontal lines is similar. Note that, if a jump sequence enters the configuration from the left, it can only exit through one of the three lines at the bottom. If a jump sequence enters via one of the three vertical lines, it can exit horizontally or on one of the other vertical lines. However, the possibility of using more than one line from a group does not cause a problem: a jump sequence that uses the second of two horizontal lines must get stuck at the other end of the line, and a jump sequence that uses two of three vertical lines must use all three lines and can be simplified to a sequence using only one of the three lines. Non-interacting line crossing. Figure 4 depicts a configuration of men that allows two lines to cross without interacting. A jump sequence entering along the horizontal or vertical line can and must exit along the same line, whether or not the other line has already been jumped. Interaction. Figure 5 depicts a configuration of men forming an interaction between two lines. In the initial configuration, a jump sequence may follow either the horizontal or the vertical line. However, once the horizontal line has been jumped, it will no longer be possible to jump the vertical line. Theorem 1 Testing whether a Phutball position allows a winning jump sequence is NP-complete. Proof: As described above, we reduce 3-SAT to the given problem by forming a configuration of men with two horizontal lines of men for each variable, and three vertical lines for each clause. We connect these lines by the fan-in and fan-out gadget depicted in Figure 3. If variable i occurs 3

Figure 3: Configuration of men to allow a choice between three vertical lines. Similar configurations are used at the other end of each triple of lines, and at each end of pairs of horizontal lines. Figure 4: Left: configuration of men to allow horizontal and vertical lines to cross without interacting. Right: after the horizontal jump has been taken, the short gap in the vertical line still allows it to be traversed via a pair of jumps. Figure 5: Left: configuration of men to allow horizontal and vertical lines to interact. Right: after the horizontal jump has been taken, the long gap in the vertical line prevents passage. 4

as the jth term of clause k, we place an interaction gadget (Figure 5) at the point where the bottom horizontal line in the ith pair of horizontal lines crosses the jth vertical line in the kth triple of vertical lines. If instead the negation of variable i occurs in clause k, we place an interaction gadget similarly, but on the top horizontal line in the pair. At all other crossings of horizontal and vertical lines we place the crossing gadget depicted in Figure 4. Finally, we form a path of men from the final fan-in gadget (the arrow in Figure 2) to the goal line of the Phutball board. The lines from any two adjacent interaction gadgets must be separated by four or more units, but other crossing types allow a three-unit separation. By choosing the order of the variables in each clause, we can make sure that the first variable differs from the last variable of the previous clause, avoiding any adjacencies between interaction gadgets. Thus, we can space all lines three units apart. If the 3-SAT instance has n variables and m clauses, the resulting Phutball board requires 6n + O(1) rows and 9m + O(1) columns, polynomial in the input size. Finally, we must verify that the 3-SAT instance is solvable precisely if the Phutball instance has a winning jump sequence. Suppose first that the 3-SAT instance has a satisfying truth assignment; then we can form a jump sequence that uses the top horizontal line for every true variable, and the bottom line for every false variable. If a clause is satisfied by the jth of its three variables, we choose the jth of the three vertical lines for that clause. This forms a valid jump sequence: by the assumption that the given truth assignment satisfies the formula, the jump sequence uses at most one of every two lines in every interaction gadget. Conversely, suppose we have a winning jump sequence in the Phutball instance; then as discussed above it must use one of every two horizontal lines and one or three of every triple of vertical lines. We form a truth assignment by setting a variable to true if its upper line is used and false if its lower line is used. This must be a satisfying truth assignment: the vertical line used in each clause gadget must not have had its interaction gadget crossed horizontally, and so must correspond to a satisfying variable for the clause. Figure 6 shows the complete reduction for a simple 3-SAT instance. We note that the Phutball instances created by this reduction only allow orthogonal jumps, so the rule in Phutball allowing diagonal jumps is not essential for our result. 3 Phutball and Checkers Phutball is similar in many ways to Checkers. As in Phutball, Checkers players sit at opposite ends of a rectangular board, move pieces by sequences of jumps, remove jumped pieces, and attempt to move a piece onto the side of the board nearest the opponent. As in Phutball, the possibility of multiple jumps allows a Checkers player to have an exponential number of available moves. Checkers is PSPACE-complete [7] or EXPTIME-complete [12], depending on the termination rules, but these results rely on the difficulty of game tree search rather than the large number of moves available at any position. Does Checkers have the same sort of single-move NP-completeness as Phutball? It is convenient to view Checkers as being played on a nonstandard diamond-shaped grid of square cells, with pieces that move horizontally and vertically, rather than the usual pattern of diagonal moves on a checkerboard (Figure 7). This view does not involve changing the rules of checkers nor even the geometric positions of the pieces, only the markings of the board on which they rest. Then, any jump preserves the parity of both the x- and y-coordinates of the jumping piece, so at most one fourth of the board s cells can be reached by jumps of a given piece (Figure 8, left). For any given piece p, form a bipartite graph G p by connecting the vacant positions that p can 5

Figure 6: Complete translation of 3-SAT instance (a b c) ( a b c). 6

Figure 7: The checkerboard can equivalently be viewed as a diamond-shaped grid of orthogonally adjacent square cells. Figure 8: Left: only cells of the same parity can be reached by jumps. Right: graph G p formed by connecting jumpable pieces with cells that can be reached by jumps from the upper black king. reach by jumping with the adjacent pieces of the opposite color that p can jump. If p is a king, this graph should be undirected, but otherwise it should be directed according to the requirement that the piece not move backwards. Note that each jumpable piece has degree two in this graph, so the possible sequences of jumps are simply the graph paths that begin at the given piece and end at a vacant square. Figure 8, right, depicts an example; note that opposing pieces that can not be jumped (because they are on cells of the wrong parity, or because an adjacent cell is occupied) are not included in G p. Using this structure, it is not hard to show that Checkers moves are not complex: Theorem 2 For any Checkers position (on an arbitrary-size board), one can test in polynomial time whether a checker can become a king, or whether there is a move which wins the game by jumping all the opponent s pieces. Proof: Piece p can king precisely if there is a directed path in G p from p to one of the squares along the opponent s side of the board. A winning move exists precisely if there exists a piece p for which G p includes all opposing pieces and contains an Euler path starting at p; that is, precisely if G p is connected and has at most one odd-degree vertex other than the initial location of p. The second claim in this theorem, testing for a one-move win, is also proved in [7]. That paper also show that the analogous problem for a generalization of checkers to arbitrary graphs is NPcomplete. 7

4 Discussion We have shown that, in Phutball, the exponential number of jump sequences possible in a single move, together with the ways in which parts of a jump sequence can interfere with each other, leads to the high computational complexity of finding a winning move. In Checkers, there may be exponentially many jump sequences, but jumps can be performed independently of each other, so finding winning moves is easy. What about other games? In particular, Fanorona [4, 6] seems a natural candidate for study. In this game, capturing is performed in a different way, by moving a piece in one step towards or away from a contiguous line of the opponent s pieces. Board squares alternate between strong (allowing diagonal moves) and weak (allowing only orthogonal moves), and a piece making a sequence of captures must change direction at each step. Like Checkers (and unlike Phutball) the game is won by capturing all the opponent s pieces rather than by reaching some designated goal. Is finding a winning move in Fanorona hard? If so, a natural candidate for a reduction is the problem of finding Hamiltonian paths in grid graphs [9]. The complexity of determining the outcome of a general Phutball position remains open. We have not even proven that this problem is NP-hard, since even if no winning move exists in the positions we construct, the player to move may win in more than one move. Acknowledgment This work was inspired by various people, including John Conway and Richard Nowakowski, playing phutball at the MSRI Combinatorial Game Theory Research Workshop in July 2000. References [1] E. R. Berlekamp, J. H. Conway, and R. H. Guy. Winning Ways for your Mathematical Plays, vol. II, Games in Particular. Academic Press, 1982, pp. 688 691. [2] M. Burke. Zillions of Games: Phutball. Web page, 1999, http://www.zillions-of-games.com/ games/phutball.html. [3] T. Cazenave. Resultats du Tournoi Berder99. Web page, September 1999, http://www.ai. univ-paris8.fr/ cazenave/phutball/phutball.html. [4] D. Eppstein. Fanorona. Java program, 1997, http://www.ics.uci.edu/ eppstein/180a/projects/ fanorona/. [5] D. Eppstein. Computational Complexity of Games and Puzzles. Web page, 2000, http://www. ics.uci.edu/ eppstein/hard.html. [6] L. Fox. Fanorona: History, Rules and Strategy. Northwest Corner, Inc., 1987. [7] A. S. Fraenkel, M. R. Garey, D. S. Johnson, T. Schaefer, and Y. Yesha. The complexity of checkers on an N N board preliminary report. Proc. 19th Symp. Foundations of Computer Science, pp. 55 64. IEEE, 1978. 8

[8] A. S. Fraenkel and D. Lichtenstein. Computing a perfect strategy for n n Chess requires time exponential in n. J. Combinatorial Theory, Ser. A 31:199 214, 1981. [9] A. Itai, C. H. Papadimitriou, and J. L. Szwarcfiter. Hamilton paths in grid graphs. SIAM J. Comput. 11(4):676 686, November 1982. [10] D. Mazzoni and K. Watkins. Uncrossed knight paths is NP-complete. Manuscript, October 1997, http://www.mathematik.uni-bielefeld.de/ sillke/problems/twixt Proof Dra\%ft. [11] J. M. Robson. The complexity of Go. Proc. IFIP, pp. 413 417, 1983. [12] J. M. Robson. N by N checkers is EXPTIME complete. SIAM J. Comput. 13(2):252 267, May 1984. [13] J. Williams. Philosopher s Football. Abstract Games no. 3, pp. 10 14, Autumn 2000. 9