1 / 31

The Game of Nim on Graphs: NimG

The Game of Nim on Graphs: NimG. Gwendolyn Stockman Alan Frieze and Juan Vera. The Game of Nim. 2 players n piles of disks, with a 1 , a 2 , … a n disks on each pile Players take turns removing disks from each pile A player loses when there are no disks left. Impartial Games.

mallika
Télécharger la présentation

The Game of Nim on Graphs: NimG

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Game of Nim on Graphs: NimG Gwendolyn Stockman Alan Frieze and Juan Vera

  2. The Game of Nim • 2 players • n piles of disks, with a1, a2, … an disks on each pile • Players take turns removing disks from each pile • A player loses when there are no disks left

  3. Impartial Games • Geography, Nim, and NimG are impartial games • A game in which the only difference between the two players is which one goes first • Every position of an impartial game has a Grundy Number or Nim-Value

  4. x y w z Sprague-Grundy Numbers (Nim-Sums) • Used to represent wining and losing positions • Given a game tree T = (V,E) • Recursively define: with • A player is in a winning position if at the end of his/her turn the playing piece is on such that

  5. Grundy Numbers (cont.) • Let a1, a2, … an be the binary representations of the number of disks on each of the n piles • In the game of Nim the Grundy number for a setup is the bit-wise sum (mod 2) of the ai‘s • Example: 1 1 1 1 0 0 1 1 1 1 0 0 0 0 The Grundy number is 0 so this is a winning position!

  6. Proposed Versions of NimG • 2 players • 1 piece is moved along an undirected graph with no self-loops, and discs are removed • If discs on vertices: • Could move first and then remove discs • Could remove discs and then move • Possibly allow moves to empty verticies • If discs on edges: • Remove discs as you go along an edge • Players take turns removing disks from piles • How to win: • The other player can’t complete their turn

  7. Example of Vertex NimG 7 15 9 6 5 6 5 4 21 21 10 10 8 8 5 13 2

  8. Geography • Two players alternately move a piece on a graph until one loses by being unable to make an legal moves • Directed or Undirected • Edge Geography • No edge repeated • Vertex Geography • No vertex repeated • Undirected Vertex Geography • Contained in a version of Vertex NimG with: • 1 chip on each vertex • Not allowed to move to empty vertices • Solvable in polynomial Time • Second player has a winning strategy IFF the graph has a perfect matching (Fraenkel 1993) • Undirected Edge Geography • PSPACE-complete (Fraenkel 1993)

  9. Previous Work: Nim on Graphs • In A Nim game played on Graphs I and II (Fukuyama 2003) Edge NimG was examined • Proved that the Grundy Numbers can be found completely on: • Bipartite Graphs • Trees • Cycles • Main Method: matchings on graphs • Contains normal Nim • 2 vertices with n edges with a1, a2, … an disks on each edge • Contains Undirected Edge Geography • 1 disk on each edge

  10. andisks a0disks an-1disks a1disks … v0 v1 vn-1 vn The Game: Vertex NimG • The game from now on: • Vertex NimG • Moves to empty vertices allowed • Notation for Vertex NimG on a path of length N • (a0,a1,…,an-1,an):0 represents: • Where is the piece being moved

  11. Theorem 1: Vertex NimG on path of length 2

  12. 0 0 x 0 x x 0 0 0 x 0 NimG on a Path of Length 3 • Not so simple on longer paths • Grundy Numbers bounded by a function of d, the number of disks on the graph • First note that x  • Easy to see that • is a child for and • Easy to see that • is a child and • Rest omitted for brevity

  13. (0,a,b,0):1 (0,0,b,0):2 (0,1,b,0):2 (0,2,b,0):2 (0,b-1,b,0):2 (0,b,b,0):2 0 a b 0 NimG on a Path of Length 3 (cont.) • Will prove that given a,bsuch that a>b then • Because with

  14. NimG on a Path of Length 3 (cont.) • Take a and we want to know the value of • Examine the children of that position in the game tree and find a+1 a 1 1

  15. NimG on a Path of Length 3 (cont.) • Take a and we want to know the value of • Examine the children of that position in the game tree and find a+1 a+2 2 1 2

  16. (0,a,b,0):1 (0,0,b,0):2 (0,1,b,0):2 (0,2,b,0):2 (0,b-1,b,0):2 (0,b,b,0):2 (0,1,b,0):0 NimG on a Path of Length 3 (cont.) • So given a,bsuch that a>b then • And • Further suppose we have a,b,c,e{0}such that then 1 2 3 4 b+1 0

  17. u v x y (G, A):v (G, A’):u Vertex NimG on Any Graph • Represent positions of NimG as (G, A):v where G is the graph, A is the amount function for G, and marker is at vertex vV(G) • A reduced game tree is used to find if a winning strategy exists from a given position, and if one does, what it is • Create the reduced game tree, T, where each node is a position, by • making (G,A):v the root • For each uN(v) such that A(u)< A(v) add node (G,A’): u as a child to (G,A):v where • Repeat once for each node added to T

  18. v h c b a d v c e a b f v b c a v b a c h Example: Create T • Player P1 starts with setup (G,A):v 12 4 9 3 2 1 6 5

  19. v h b b c a d v c d e a b f a d b v b d Example: Create T • Start with setup (G,A’):a 12 4 8 3 2 1 6 5

  20. v h c b b a d v c d e a b f d a Example: Create T • Start with setup (G,A’’):b 12 4 8 3 2 1 5 5

  21. v h b b c a d v e f c d e a b f b f e v f e a Example: Create T • Start with setup (G,A’’):b 12 4 8 3 2 1 5 5

  22. v h c b b a d v e f c d e f a b f e f c b f Example: Create T • Start with setup (G,A’’’):e 12 4 8 3 2 1 5 4

  23. v h c b b a d v e f c d e f a b f f c b e Example: Create T • Start with setup (G,A’’’):e 12 4 8 3 1 1 5 4

  24. v h c b b a d v e e e f f f c d e f f f a b f e f f f e f Example: Create T 12 4 9 3 1 1 5 4

  25. Labeling T • If it is player P1’s turn then label all even levels, including 0, of T, P1, and all odd levels P2 • Label each node either P1 or P2 • Player P1 has a winning strategy from nodes labeled P1 • Player P2 has a winning strategy from nodes labeled P2 • Label all nV(T), with labeling function L:V(T){P1,P2}, using a depth first labeling starting with the n=root of V(T) • Apply the depth first labeling to all children of n in T • Label n with L(n) • The root of T is labeled P1 IFF there is a winning strategy for player P1

  26. v b c b a e e e f f f d b w f e f f f d v b b f e a c w a f f f c f e e f b w v d e f f f w a e c b v e Example: Labeling T • Depth First Labeling of T : P1 does NOT have a winning strategy from (G,A):v! n a leaf and on a P2-level n a leaf and on a P2-level or n on a P1-level and at least one child of n labeled P1 or n on a P1-level and at least one child of n labeled P1 P1 or n on a P2-level and all children of n labeled P1 L(n):= n a leaf and on a P1-level n a leaf and on a P1-level P1 or n on a P2-level and at least one child of n labeled P2 or n on a P2-level and at least one child of n labeled P2 P2 or n on a P1-level and all children of n labeled P2 or n on a P1-level and all children of n labeled P2 P2 = A node labeled P2 = A node labeled P1 P1 = A node whose subtree is being labeled P2 = The node currently being examined P1

  27. v h d v c f b v e b f f e f c d e f v a f e a b f v v Why P1 can’t win • Assume that players will always follow a winning strategy if one exists • If P1 moves to a, b, or c then P2 will win • What if P1 moves to h? P1 still loses! P1 11 12 10 8 P2 4 9 2 5 8 6 3 P1 2 1 6 5 P2 P1

  28. (G, A):v (G, A’):u The Winning Strategy: Case 1 • If player P2 just moved from vertex u to vertex v, creating setup (G, A):v, and (G, A’):u is a child of (G, A): v labeled P1 • Remove r[1, A(v)- A(u)] disks from vertex v and move to vertex u, creating setup with • Replace the sub-tree with root (G, A’):u with the tree of root created as described before (G, A):v

  29. (G, A):w (G, A’):x The Winning Strategy: Case 2 • Otherwise, given setup (G, A):v pick any child (G, A’):u of node (G, A):v in T that is labeled P1 • remove r[1, A(v)- A(u)] disks from vertex v and move to vertex u, creating setup with • Replace the sub-tree with root (G, A’):u with the tree of root created as described before • The alterations to T insure that T maintains the property that for any node y=(G, A):w V(T)

  30. 1 node root of T  n-1 nodes  n-2 nodes  n-d nodes NimG on any Graph: Analysis • Tree T is exponential in size • What if there is a maximum number of disks allowed on each vertex? • Polynomial – at most nd number of nodes, where d is the maximum number of disks allowed on a vertex and n=V(G) • There does not exist any path starting from the root with a node (G,A):v and a node for any amount functions A and

  31. Questions???

More Related