A PSPACE-complete Graph Nim

We build off the game, NimG to create a version named Neighboring Nim. By reducing from Geography, we show that this game is PSPACE-hard. The games created by the reduction share strong similarities with Undirected (Vertex) Geography and regular Nim,…

Authors: Kyle Burke, Olivia George

A PSPACE-complete Graph Nim
A PSP A CE-complete Graph Nim Kyle G. Burk e Colb y College paithanq@gmail.com Olivia C. George No vem ber 1, 2018 Abstract W e build off the game NimG [9] to create a v ersion named Neigh- boring Nim . By reducing from Geography , w e show that this game is PSP A CE-hard. The games created b y the reduction share strong similarities with Undirected (Ver tex) Geography and regular Nim , though these are b oth solv able in p olynomial-time. This appli- cation of graphs can b e used as a form of game sum with an y rulesets, not only Nim . 1 Bac kground 1.1 Algorithmic Combinatorial Game Theory Most of the results here revolv e around the computational complexit y of determining whic h pla yer has a winning strategy from a given game p osition. There exist faster algorithms to solve this problem for some rulesets than for others. F or each ruleset, we consider the computational problem that could b e solved by such an algorithm. W e will refer to b oth the ruleset and problem b y the same name. W e strongly encourage readers unfamiliar with these topics to refer to [1]. 1.2 T erminology There is a small amount of non-standard terminology used in this pap er. • W e use the word sticks to refer to the ob jects in nim heaps. Th us, a nim heap of size six contains six stic ks. 1 • An optimal se quenc e set is a set of sequences of pla ys for b oth pla yers suc h that any mo ve deviating from one of the sequences results in an N-p osition. No mo v e in that sequence should be non-optimal for either pla yer. Thus, if a play er do es not know whether they hav e a winning strategy , adhering to an optimal sequence is at least as go o d as any other mo ve. 1.3 Nim Nim is an impartial game pla yed on a collection of heaps, eac h with a non- negativ e num ber of sticks. On a play er’s turn, they choose a non-empty pile and remov e as many sticks as desired (at least one) from that pile. A play er loses when they cannot remov e sticks (all piles are empt y). Nim is a classic impartial game, b eing the basis of Nim b ers and Sprague- Grundy theory[8][5]. Nim has lots of nice prop erties, from easy ev aluation of games to obvious comp os ition of tw o Nim games (the sum is just a new Nim game). 1.4 NimG Nim has b een extended to incorporate graphs so that nim heaps are assigned to either edges or vertices. There are three differen t versions of the game named NimG . In all three v ersions, a turn consists of b oth trav ersing an edge of the graph and removing stic ks from a visited elemen t. 1.4.1 Edge-heap NimG F ukuy ama describ es NimG where nim heaps are em b edded into the edges of the graph[4]. On each turn, the curren t play er c ho oses an edge to tra verse (whic h has at least 1 stic k on it) and remo ves any num ber of sticks from that edge. The next play er then starts on the vertex on the other end of that edge and must c ho ose an adjacent edge for their mov e. When there are no more edges with sticks adjacent to the curren t vertex, the current play er loses. Man y results for this game are known on complete graphs[2]. 1.4.2 V ertex-heap NimG In Ver tex NimG , play ers similarly mo ve from one vertex to another, but heaps are connected to the v ertices instead of edges[9]. The t wo v arian ts can b e easily describ ed here as: “remov e sticks, then mo ve” and “mo ve, then 2 remo ve stic ks”. In b oth cases, a play er loses if they cannot complete their turn. The main topic of this pap er is a v arian t of “mov e, then remov e”. 1.5 Geograph y W e will use Geography to sho w the PSP A CE-hardness of Neighboring Nim . There are many fla vors of Geography ; w e use the term to refer to Directed Ver tex Geography . This impartial game is play ed on a directed graph; eac h turn b egins with a v ertex chosen. The curren t play er’s turn consists of choosing an outgoing arc that leads to a vertex that hasn’t b een visited y et. The next pla yer then starts their turn with the resulting v ertex selected. W e formally describ e the ruleset as follows: Definition 1.1 (Geography) (Dir e cte d V ertex) Ge o gr aphy p ositions ar e describ e d by: G = ( V , E ) and v ∈ V . Move options for ( G, v ) ar e al l ( G 0 , v 0 ) wher e: • ( v , v 0 ) ∈ E , • V 0 = V \ { v } , • E 0 is the subset of E induc e d by V 0 , and • G 0 = ( V 0 , E 0 ) . Geography is kno wn to b e PSP A CE-complete[7]. 2 Neigh b oring Nim W e define the ruleset Neighboring Nim to be similar to the “mov e then remo ve” version of NimG , but also allow play ers to choose to play on the same vertex as the last mo ve as though eac h vertex has a self-lo op. Note that standard Nim is equiv alen t to a game of Neighboring Nim on a complete graph with each heap on a separate vertex. A more formal definition follo ws. Definition 2.1 (Neighboring Nim) Neighboring Nim p ositions ar e de- scrib e d by G = ( V , E ) , w : V → N , and x ∈ V . The options for ( G, w, x ) ar e al l ( G, w 0 , x 0 ) wher e w 0 : V → N and • x 0 = x or { x, x 0 } ∈ E , • w 0 ( x 0 ) < w ( x 0 ) , and 3 • ∀ v ∈ V \ { x 0 } : w 0 ( v ) = w ( v ) . Our main result for this pap er is that Neighboring Nim is PSP A CE- hard. Since our analysis uses graphs with a small num b er of stic ks on each v ertex, we define a version of the game with a b ounded num b er of sticks per v ertex. Definition 2.2 ( k -Neigh b oring Nim) k -Neighboring Nim is the same ruleset as Neighboring Nim , exc ept that the weight function, w , has b ounde d r ange: [0 , k ] . W e are able to show that 2-Neighboring Nim is PSP A CE-complete, and thus c -Neighboring Nim is also PSP ACE-complete for any constant c ≥ 2. The case for 1-Neighboring Nim is solv able in p olynomial time, since this game is equiv alent to Undirected (Ver tex) Geography [3]. Th us, if P 6 = PSP A CE, allo wing a second stick on some vertex-heaps can greatly increase the computational hardness of determining the winning pla yer! 3 Computational Complexit y of Neigh b oring Nim 3.1 PSP A CE -hardness The follo wing is the main result of this pap er. Theorem 3.1 (Hardness) Neighboring Nim is PSP A CE -har d. W e will show the hardness of this problem b y reducing from the game Geography , whic h is PSP A CE-hard[6]. Pro of. Giv en an y Geography p osition, we will give an algorithm to con- struct an equiv alent Neighboring Nim state, meaning that there is a win in the Geography p osition exactly when there is a win in corresp onding Neighboring Nim p osition. First w e will describ e the metho d for gener- ating these p ositions, then prov e their equiv alence. Let GG b e a Geography p osition on the directed and un weigh ted graph G = ( V , E ). W e define a new undirected graph, G 0 = ( V 0 , E 0 ) with weigh ts on the vertices w : V 0 → N in the follo wing wa y . ∀ v ∈ V : let X v ∈ V 0 and set w ( X ) = 1. Also, ∀ ( y , z ) ∈ E : (edge directed from y to z ) let a y ,z , b y ,z , c y ,z , d y ,z , e y ,z , f y ,z , g y ,z ∈ V 0 where, ignoring the ( y , z )-subscripts, w ( a ) = w ( b ) = w ( c ) = w ( e ) = w ( f ) = w ( g ) = 1, w ( d ) = 2 and, ( X y , a ) , ( a, b ) , ( b, c ) , ( c, d ) , ( b, e ) , ( e, f ) , ( d, f ) , ( d, g ) , ( f , g ) , ( g , X z ) ∈ E 0 . 4 1 1 1 2 1 1 1 X y a b c d e f g X z Figure 1: Our main gadget: reduce eac h directed edge from y to z to the undirected w eighted graph sho wn here. See Figure 1 for a visual description. The resulting G 0 is the graph for our Neighboring Nim p osition equiv- alen t to GG . The only final step is to declare that if GG has a starting v ertex, v , then X v ∈ V 0 is the starting vertex (where the previous play had b een made) in our game and w ( X v ) is set to 0 instead of 1. T o complete the reduction, we must show that the structure in Figure 1 “acts” lik e a directed edge in Geography . Thus, we must pro ve: • Mo ving “bac kwards” is a losing play . If the previous play was at X z , then a backw ards play w ould b e to remov e the only stic k at g ( y ,z ) . A bac kwards play results in an N -p osition. • The same play er moving in to the gadget should also mov e out. If a pla yer mo ves from X y to a ( y ,z ) , then in an optimal sequence of plays, the same play er will mo ve from g ( y ,z ) to X z . W e prov e the former in Lemma 3.2 and the latter in Lemma 3.3. The result is that eac h of these gadgets (as in Figure 1) in the Neighboring Nim p osition works just lik e a (directed) edge in Geography . T rying to go backw ards will result in losing and, if play ers pla y optimally , they b oth migh t as well con tinue through each gadget. Lemma 3.2 (Don’t Go Bac kwards) Any play fr om ( X z ) to g ( y ,z ) (for al l y ) r esults in an N -p osition. 5 (See Appendix A for a proof of this claim.) This implies that our gadgets are directed: if a pla yer tries to go “bac kwards”: from an X -v ertex to an i -v ertex, the opp onen t will hav e a winning strategy . T o finish sho wing that our gadget acts like a directed edge, w e must pro ve that “nothing can go wrong” during a regular forward tra versal of the structure. T o this end, we find tw o sequences that constitute an optimal sequence set through the gadget, thus showing that neither play er b enefits from deviating from the sequence. In order to get from one end of the gadget (as in Figure 1) to the other, the follo wing sequence of mov es suffices (let Alice and Bob b e our tw o play ers; we will again ignore subscripts): Alice “tak es” a , Bob takes b , Alice tak es e , Bob takes f , Alice decrements d by 1, Bob takes g , Alice tak es X z . Note that the same play er (in this example, Alice) who chooses to take a also mov es to X z . The other sequence is where Bob takes c instead of g —here Alice will take the remaining ob ject at d and Bob will b e forced to tak e g , rejoining with the first sequence. See Figure 2 for a visual description of the safe sequences. W e must pro ve that neither pla yer b enefits from deviating from these sequences. T o do this, w e sho w that an y deviation is a losing mov e. 1 1 1 2 1 1 1 X y a b c d e f g X z Figure 2: This sequence of mov es is “safe” for b oth play ers to trav erse the gadget. The tw o gra y arrows indicate the p oten tial additional mov es in the second sequence. Eac h mov e assumes that exactly one ob ject is taken from a v ertex. Lemma 3.3 (Stick to the Script) L et the notation k ( p ) denote taking p 6 obje cts fr om vertex k in a turn. Then, after the plays ( . . . , X y (1) , a (1)) any play deviating fr om the fol lowing se quenc es is a losing move: ( b (1) , e (1) , f (1) , d (1) , g (1) , X z (1)) ( b (1) , e (1) , f (1) , d (1) , c (1) , d (1) , g (1) , X z (1)) . (See App endix B for the pro of of this claim.) This implies that once a pla yer makes an appropraite mov e on to the gadget (pla ying on an a -no de) an y “safe” sequence of mo ves in the gadget results in that same play er mak- ing the play at the opp osite X no de. The tw o ab o ve claims combined show that our gadget correctly mo dels a directed edge in a graph just b etw een the X no des. Th us, for any edge ( y , z ) in our Geography p osition, GG , the mov e to a ( y ,z ) will result in the same pla yer moving to X z as desired. Also, since w e pro ved play ers shouldn’t go backw ards, this game is equiv alen t to GG ; the first play er has a winning strategy in GG exactly when the first pla yer has a winning strategy in this Neighboring Nim p osition. Th us, Neighboring Nim is PSP ACE-hard.  The hardness of Ver tex NimG follo ws directly . Corollary 3.4 (V ertex NimG hardness) Ver tex NimG is PSP ACE - har d. Pro of. Neigh b oring Nim is a sp ecial case of Ver tex NimG where all v ertices hav e self-lo ops. Thus, Ver tex NimG is also PSP ACE-hard.  3.2 Sp eculation on Completeness Unfortunately , Neighboring Nim is not automatically PSP ACE-complete as games could take a n umber of mo ves exp onen tial in the size of the de- scription of the game. F or example, a vertex can hav e a num ber of sticks exp onen tial in the amount of bits needed to express that num b er and the rest of the graph. W e leav e this unsolv ed as Op en Problem 6.1. There are go o d arguments to conjecture either w ay . On one hand, it seems to not b e inside PSP ACE. Games can last an ex- p onen tial num b er of turns, so the game trees are extremely tall. A straight- forw ard brute-force trav ersal can’t b e p erformed in p olynomial space. On the other hand, it might b e inside PSP ACE. Although there are man y EXPTIME-hard rulesets, the authors know only of lo op y examples. This means they can ha ve positions that repeat during the course of a game, 7 whic h cannot o ccur in Neighboring Nim . Additionally , Nim heaps are w ell-understo o d, p erhaps increasing the size of the heaps do esn’t greatly increase the difficulty of finding strategies. 3.3 PSP ACE -complete v ersions W e can sidestep this problem a bit by using our b ounded-heap-size version of the game. Corollary 3.5 (2-Neighboring Nim Completeness) k -Neighboring Nim is PSP ACE -c omplete for any k ≥ 2 . Pro of. The result of the reduction from Theorem 3.1 is alwa ys a 2- Neighboring-Nim p osition. Th us, the PSP ACE-hardness holds for this subset of p ositions as w ell. The p ositions are in PSP A CE b ecause k b ounds the maxim um num b er of mov es p er vertex.  4 Generalization This graph-em b edding technique w orks with games other than Nim . Given a graph, assign different game states to the v ertices, and use similar rules: pla yers may mak e one mov e legal in the game in any vertex neigh b oring the last pla y . W e define this formally . Definition 4.1 (Neighboring- R ) Given any ruleset R , Neighboring- R has p ositions of the form G = ( V , E ) , w : V → positions ( R ) , and x ∈ V . The left options for ( G, w , x ) ar e ( G, w 0 , x 0 ) wher e w 0 : V → positions ( R ) and: • x 0 = x or { x, x 0 } ∈ E , • w 0 ( x 0 ) is a left option of w ( x 0 ) , and • ∀ v ∈ V \ { x 0 } : w 0 ( v ) = w ( v ) . The right options ar e define d analagously: w 0 ( x 0 ) must b e a right option of w ( x 0 ) . 8 4.1 Inequiv alen t P ositions This new definition allo ws a Neighboring Nim v ertex to con tain multiple heaps instead of only a single heap. Although each Nim position is equiv alent to a single heap, that equiv alence do esn’t carry o ver in the Neighboring situation. Consider the tw o Neighboring Nim games in figure 3. (The previous mov e w as made on the left-most vertex in b oth cases.) The v alues of the games embedded in the left vertices are b oth 0, the v alues on the middle vertices are b oth 0, and the v alues of the righ tmost games are b oth ∗ . Ho wev er, the o verall v alue of the p ositions are not equiv alen t. 0 I I I 0 0 I Figure 3: Tw o Neighboring Nim p ositions. In b oth, the last mo ve was made on the dashed v ertex. The v alue of the ab ov e game is zero, the v alue of the b ottom game is ∗ . In the top game, there are no mo ve options, so the v alue is 0. In the b ottom p osition, the next pla y er can mo ve to the middle vertex, ev en though the v alue of the Nim game there is also zero. After that mov e there are exactly tw o mov es remaining. Th us, the initial game has exactly three mo ves remaining and has a v alue of ∗ . 4.2 Generalized Hardness The next result allo ws us to sa y something ab out the hardness of graph- em b edded versions of man y impartial games. 9 Theorem 4.2 (Neighboring- R Hardness) F or any ruleset, R , which has p ositions identic al to 0 , ∗ , and ∗ 2 , Neighboring- R is PSP ACE -har d. Pro of. Tw o p ositions are identical if they ha ve isomorphic game trees. Replacing the nim heaps of size 1 and 2 with ∗ and ∗ 2, resp ectively , in the reduction of theorem 3.1 do esn’t change the winnability of the resulting games. Th us, the reduction applies to R .  5 Conclusions Building on algorithmic w ork analyzing different versions on NimG , we presen t Neighboring Nim , a new PSP ACE-hard game. An in teresting aspect of the hardness of Neighboring Nim is the juxta- p osition with Ver tex Geography . 1-Neighboring Nim is the same rule- set as Undirected Ver tex Geography , whic h is solv able efficiently[3]. Ho wev er, by adding an extra stic k to just a few vertices, w e can push the game in to PSP ACE-hardness! F urthermore, we can replace Nim and apply the graph-embedding con- cept to any other ruleset, R , to create Neighboring- R . 6 F uture W ork There are man y extensions to the work described here. The most prominent is certainly the unknown completeness of Neighboring Nim . Op en Problem 6.1 Neighboring Nim ∈ PSP ACE ? Additionally , there is still w ork to b e done on the computational hardness of other flav ors of NimG . Op en Problem 6.2 What is the c omputational c omplexity of Edge NimG ? Op en Problem 6.3 What is the c omputational c omplexity of Ver tex NimG on gr aphs without self-lo ops? Other explorable problems include the hardness of other versions of Neighboring- R . Op en Problem 6.4 Is Neighboring- R PSP ACE -har d if R includes any p ositions equiv alen t to ∗ and ∗ 2 ? 10 Note that op en problem 6.4 is a stronger statement than shown here b ecause equiv alen t do es not necessarily mean iden tical. Op en Problem 6.5 F or which other c omputational ly e asy rulesets, R , is Neighboring- R har d? Op en Problem 6.6 Ar e ther e strictly p artisan p ositions of a ruleset, R , that c an b e use d to show Neighboring- R is har d? How smal l c an the game tr e es b e to get a har d game? 7 Ac kno wledgmen ts The authors would like to thank those who play ed Neighboring Nim with them, including three excellent Wittenberg Universit y students: Deanna Fink, Dang Mai and Ernie Heyder, as well as Professor Doug Andrews who defeated the first author ov er and ov er again. W e would also lik e to thank Adam P ark er for listening to initial v ersions of the hardness pro of and pro of- reading this pap er. References [1] Erik D. Demaine and Rob ert A. Hearn. Pla ying games with algo- rithms: Algorithmic com binatorial game theory . In Mic hael H. Alb ert and Richard J. No wak o wski, editors, Games of No Chanc e 3 , volume 56 of Mathematic al Scienc es R ese ar ch Institute Public ations , pages 3–56. Cam bridge Universit y Press, 2009. [2] Lindsa y Eric kson. Nim on complete graphs. Ars Combinatoria , Accepted for publication in 2009. [3] Aviezri S. F raenk el, Edw ard R. Scheinerman, and Daniel Ullman. Undi- rected edge geography . The or. Comput. Sci. , 112(2):371–381, 1993. [4] Masahik o F ukuyama. A nim game pla yed on graphs. The or. Comput. Sci. , 1-3(304):387–399, 2003. [5] P . M. Grundy . Mathematics and games. Eur eka , 2:198—211, 1939. [6] Da vid Lich tenstein and Mic hael Sipser. Go is p olynomial-space hard. J. A CM , 27(2):393–401, 1980. 11 [7] C. H. Papadimitriou. Computational Complexity . Addison W esley , Read- ing, Massac hsetts, 1994. [8] R. P . Sprague. ¨ Ub er mathematische Kampfspiele. Tˆ ohoku Mathematic al Journal , 41:438—444, 1935-36. [9] Gw endolyn Sto ckman. Presen tation: The game of nim on graphs: NimG, 2004. Av ailable at http://www.aladdin.cs.cmu.edu/reu/ mini_probes/papers/final_stockman.ppt . A Pro of of Lemma 3.2 Lemma A.1 (Don’t Go Bac kwards) Any play fr om ( X z ) to g ( y ,z ) (for al l y ) is sub optimal. W e will refer to the pla yer who mo v es from X z to g (we will lea ve out the subscript for the internal v ertices) as the “fo e” while the other pla yer is the “hero”. W e will sho w that the hero has a winning strategy after a bac kwards mov e. W e can no w lo ok at tw o cases, each dep ending on the state of the game outside the gadget. The first is the case where the mov e from a to X y w ould be a winning pla y . In this case, the hero can next mo ve from g to d and take b oth of the ob jects there. The fo e has tw o options, b oth of whic h, w e show, allow the hero to win. 1. The fo e mo ves to c . In this case the hero m ust c ho ose to go to b . The fo e can now either c ho ose to mo ve to a —in whic h case the hero will gladly mo ve to X y and win as w e assumed—or to e . Then the hero simply takes the ob ject at f and, as there are no more mov es, the hero has won. 2. The fo e mov es to f . The hero must then take e and the fo e must tak e b . The hero can then mo ve to c and win the game. The second ma jor case assumes that the mov e from a to X y is a losing pla y . Here, the hero can still mov e to d (from g ) but will tak e only one of the ob jects. No w the fo e has three options: taking the other ob ject at d , mo ving to c or mo ving to f . W e show all to b e losses. 1. F o e mo ves to c . No w the hero should tak e the remaining ob ject at d . The follo wing sequence must o ccur: fo e must take f , hero at e , 12 fo e at b , hero at a , follow ed by the fo e at X y , a losing mov e by our assumption. 2. F o e takes the remaining ob ject at d . The hero will c ho ose to take c , so the fo e must take b . The hero can then take a , forcing the fo e to tak e X y , a losing mov e b y our assumption. 3. F o e tak es f . The hero should then take e so the fo e must take b . Again, the hero can take a , so the fo e must mo ve to X y , a losing mov e b y our assumption. Th us, it is a losing play to mov e from an X -vertex to a g -vertex. B Pro of of Lemma 3.3 Lemma B.1 (Stick to the Script) L et the notation k ( p ) denote taking p obje cts fr om vertex k in a turn. Then, after the plays ( . . . , X y (1) , a (1)) any play deviating fr om the fol lowing se quenc es is a losing move: ( b (1) , e (1) , f (1) , d (1) , g (1) , X z (1)) ( b (1) , e (1) , f (1) , d (1) , c (1) , d (1) , g (1) , X z (1)) . W e contin ue by analyzing all p ossible deviations from these sequences and sho w that they result in a loss. In this claim, we will refer to the deviating pla yer as the fo e and the other play er as the hero. W e will sho w that the fo e loses in each case. It may b e helpful to refer to Figure 2 during these case descriptions. 1. c (1) instead of e (1) . Here we hav e tw o sub cases: either moving from g to X z is a winning (result is a P -p osition) or losing (a N -p osition) mo ve. If it’s in N , then the hero can resp ond to c (1) with d (1). If the fo e then c ho oses g (1), the hero can take the remaining stick in d with d (1). f (1) and e (1) m ust follow with the hero winning. If the fo e instead c ho oses f (1), the hero can win instantly by choosing e (1). F or the fo e’s last c hance, they could select d (1), removing the other stic k from d . The hero should resp ond with g (1). The fo e will lose b y selecting f (1), b ecause the hero will win at e (1), but the fo e will also lose with X z (1), an N -p osition as assumed. If X z (1) is instead leav es the board in P , the hero should resp ond to c (1) with d (2). The fo e could choose f (1), but the hero can then win with e (1). Instead, the fo e can choose g (1) in which case the hero can c ho ose X z (1) and win, as assumed. 13 2. d (2) instead of (the first) d (1) . Here the hero has a simple mov e to win. By taking c (1) there are no further mo ves and the fo e has lost. 3. g (1) instead of (the first) d (1) . The hero can resp ond with d (1). This leav es tw o different adjacent v ertices with 1 ob ject apiece and no other adjacent non-empty vertices. Either mov e b y the foe results in one remaining mov e and a win for the hero. 4. d (1) instead of c (1) . The hero can resp ond with c (1) and win. 5. d (1) instead of X z (1) . This cannot happen in the second sequence, but if it happ ens in the first, the hero can resp ond with c (1) and win. Th us, any deviation from the tw o sequences sp ecified in the claim puts the game in an N -p osition. 14

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment