Content Game of Nim Impartial Games Sprague-Grundy theorem

Slides:



Advertisements
Similar presentations
AE1APS Algorithmic Problem Solving John Drake.  Coursework 3 due on Thursday at 1pm  (i.e. before the start of the tutorial).  Submit either hard-copy.
Advertisements

ICAMP: Game Simulation and Analysis Analysis of the Game “Poison” Sarah Eichhorn University of California Irvine iCAMP Overview Meeting, 5/5/10.
Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Introduction to Combinatorial Game Acm Honored Class Weitao.
15 Backward induction: chess, strategies, and credible threats Zermelo Theorem: Two players in game of perfect information. Finite nodes. Three outcomes:
Sam Chow. One Player Games Bored MUMSians Han writes the numbers 1, 2,..., 100 on the MUMS whiteboard. He picks two of these numbers, erases them, and.
AE1APS Algorithmic Problem Solving John Drake.  Invariants – Chapter 2  River Crossing – Chapter 3  Logic Puzzles – Chapter 5  Matchstick Games -
4 Games and Fuses U:\APPS\Ghostgum\gsview Shared folder U:\2nd Year Share\Computer Science Courses\Semester One\Algortithmic Problem Solving Book: Algorithmic.
Tic Tac Au-Toe-Mata Mark Schiebel. Outline I.Brief Cellular Automata Background II.Tic-Tac Au-Toe-Mata Rules III.Project Design IV.Computer Strategy V.Conclusion.
AE1APS Algorithmic Problem Solving John Drake..  Previously we introduced matchstick games, using one pile of matches  It is possible to have more than.
Place captured red pieces here Place captured yellow pieces here To use as Kings Rules New Game Exit Left mouse click on piece – drag to desired location.
Progressively Finite Games
Domineering Solving Large Combinatorial Search Spaces.
Everything You Always Wanted To Know about Game Theory* *but were afraid to ask Dan Garcia, UC Berkeley David Ginat, Tel-Aviv University Peter Henderson,
The Game of Nim on Graphs: NimG Gwendolyn Stockman Alan Frieze and Juan Vera.
CHECKMATE! A Brief Introduction to Game Theory Dan Garcia UC Berkeley The World Kasparov.
CHECKMATE! A Brief Introduction to Game Theory Dan Garcia UC Berkeley The World Kasparov.
Playing Konane Mathematically with Combinatorial Game Theory
Combinatorial Games Martin Müller. Contents Combinatorial game theory Thermographs Go and Amazons as combinatorial games.
Using Reduction for the Game of NIM. At each turn, a player chooses one pile and removes some sticks. The player who takes the last stick wins. Problem:
Graphs, relations and matrices
Games, Hats, and Codes Mira Bernstein Wellesley College SUMS 2005.
Great Theoretical Ideas in Computer Science.
Matthew Marcon Project 19 1/10/12
Nimbers! By: Alyssa Godesky. Nimbers come from a game called Nim, one of the oldest known strategy games.
Great Theoretical Ideas in Computer Science.
Salvador Badillo-Rios and Verenice Mojica. Goal The goal of this research project was to provide an extended analysis of 2-D Chomp using computational.
Kim Moore, Program Manager Dr. Tonya Jeffery, Co-PI.
Aayush Garg Pecha-Kucha Design Games 10. Games I like Strategy games Mathematical games Paper and Pencil games Street games.
Game Playing.
Part II - Sums of Games Consider a game called Boxing Match which was defined in a programming contest m.short.html.
Impartial Games, Nim, Composite Games, Optimal Play in Impartial games
Investigation #1 Factors and Products.
Set Theory Topic 1: Logical Reasoning. I can determine and explain a strategy to solve a puzzle. I can verify a strategy to win a game. I can analyze.
Game-playing AIs Part 1 CIS 391 Fall CSE Intro to AI 2 Games: Outline of Unit Part I (this set of slides)  Motivation  Game Trees  Evaluation.
Game theory Impartial Games.  Two-person games with perfect information  No chance moves  A win-or-lose outcome  Impartial games ◦ Set of moves available.
6 Sums of Games.. Lecture6 Admin Plagiarism forms Answer football cup final problem. //Daisy Problem hints e.g. try a smaller size. General problem solving.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Amazons Experiments in Computer Amazons, Martin Mueller and Theodore Tegos, 2002 Exhaustive Search in the Game Amazons Raymond Georg Snatzke, 2002 Presented.
Senior Project Poster Day 2007, CIS Dept. University of Pennsylvania Reversi Meng Tran Faculty Advisor: Dr. Barry Silverman Strategies: l Corners t Corners.
Crystal Bennett Joshua Chukwuka Advisor: Dr. K. Berg.
Lesson 10.6a AIM: Variations on Linear Nim. DO NOW.
A game based off of the esteemed classic By: Tadziu Kosiara.
An Introduction to Game Theory Math 480: Mathematics Seminar Dr. Sylvester.
Lecture Coursework 2 AGAIN. Rectangle Game Look at proof of matchsticks A rectangular board is divided into m columns by n rows. The area of the board.
Multiples and Factors. Multiples A multiple is a number that is in the times tables. A multiple is a number that is in the times tables. Multiples of.
Coin Turning Games By: Lauren Quattrocchi. What are Coin Turning Games? -Coin turning games are a class of combinatorial games in which there are a finite.
The Lovely Game of NIM. Version 1 - Classic NIM You will need seven objects, such as counters or blocks. It is a game for two players. Place the 7 counters.
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
Lecture Coursework 2. Rectangle Game Look at proof of matchsticks Read thru the question. A rectangular board is divided into m columns by n rows. The.
Benjamin Casey C S 329 E Spring  Variants played since ancient times; resemblance to Chinese “Jianshizi” or “picking stones”  Current name and.
Patrick Racy Project 19 1/9/12
Tic – Tac – Toe ! Choose a square by clicking on “box #” Choose a square by clicking on “box #” If the person choosing the square gets the problem correct,
Introductory Game Theory
Great Theoretical Ideas in Computer Science
PENGANTAR INTELIJENSIA BUATAN (64A614)
Tic – Tac – Toe ! Choose a square by clicking on “box #”
Adversarial Search.
SCIT1003 Chapter 2: Sequential games - perfect information extensive form Prof. Tsang.
Tic-Tac Toe.
Nim Game Lesson1 Compendium , page 173 Guidebook , page 127 THE LESSON Lesson Title: NIM lesson1 Date: Length of the Lesson: 45 minutes.
Nim Game Lesson1 Compendium , page 173 Guidebook , page 127 THE LESSON Lesson Title: NIM lesson1 Date: Length of the Lesson: 45 minutes.
NIM - a two person game n objects are in one pile
Duo By: Fernando & Vivian.
Strike it out.
Game Theory Day 2: More Simple Games.
FOUR PLAYER CHESS.
Tic – Tac – Toe ! Choose a square by clicking on “box #”
Tic – Tac – Toe ! Choose a square by clicking on “box #”
CS51A David Kauchak Spring 2019
Presentation transcript:

Honors Track: Competitive Programming & Problem Solving Impartial Game Theory Wouter Verlaek

Content Game of Nim Impartial Games Sprague-Grundy theorem Exercise problem

Game of Nim The Game of Nim Three piles (called nim-heaps) of stones Rules 2 players alternating turns, taking off any number of stones from a pile each turn Game ends when no stones are left End condition Player that takes the last stone(s) wins

Combinatorial Games Rules of a Combinatorial Game Played by two players There is a (usually finite) set of possible positions of the game Rules of the game specify for both players and each position which moves are allowed Players alternate moving Game ends when no more moves are possible for the players whose turn it is: Under normal play rule the last player to move wins Under misère play rule the last player to move loses  Has no strategy, very difficult to analyze The game always ends in a finite number of moves

Impartial Game Impartial Game A combinatorial game, where both players have the same set of moves. So the allowable moves in an impartial game only depends on position, not which of the two players is moving. All other combinatorial games are partisan  next talk

No draws in a finite number of moves are allowed Impartial Game? Are the following games impartial games? Tic Tac Toe No draws in a finite number of moves are allowed

Impartial Game? Are the following games impartial games? Jenga Yes!

Simultaneous moves are not allowed Impartial Game? Are the following games impartial games? Rock Paper Scissors Simultaneous moves are not allowed

Impartial Game Impartial Game A combinatorial game, where both players have the same set of moves. So the allowable moves in an impartial game only depends on position, not which of the two players is moving. Goal Come up with a winning strategy

Subtraction games Subtraction Game One pile of stones A set of positive numbers, e.g.: S = {1, 2} Rules Players alternately take n stones from the pile, where n should be a number in the set S. Same as Nim, the player that takes the last stone(s) from the pile wins. Graph Nodes are the states of the game, where in the subtraction game the state represents the amount of stones on the pile. Edges represent the available moves.

N, P positions P-position A game is in this position if it secures a win for the Previous player (the player that just moved). N-position A game is in this position if it secures a win for the Next player (the player that is about to make a move).

Subtraction games Label graph with N and P positions N N P N N P N, P positions: N N P N N P Pattern: P N N P N N P N N …

Sprague-Grundy Function Mex (minimum excludant) The mex of a set is the smallest value (≥ 0) not contained in the set Examples: mex(∅) = 0 mex({1, 2, 3}) = 0 mex({0, 2, 4, 6, …}) = 1 mex({0, 1, 2, 4, 5}) = 3 Sprague-Grundy Function G(v) = mex({G(w) if v  w})

Sprague-Grundy Function G(v) = mex({G(w) if v  w}) G(v): P-position  0 N-position  not 0 N N P N N P 2 1 2 1

Sum of games Two impartial games Q1, Q2 Moves You can either move in Q1 or in Q2 Game of Nim – single nim heap Q1 is one pile of stones. Move: take anything you like. N N N N N P Sum of games Q2 is exactly the same game as Q1 Now Q := Q1|Q2 Nim game with 2 heaps!

Sprague-Grundy Theorem Nimbers Values of the nim-heaps Nimber addition (⊕) a=5 b=3 Then a⊕b= Theorem The Sprague-Grundy function for a sum of games on a graph is just the Nim sum of the Sprague-Grundy functions of the sub-games. 101 011 + (mod 2) 110 = 6

Sprague-Grundy Theorem Nim game from the start Made of three single-heap Min games Heap 1: 101 Heap 2: 011 Heap 3: 100 + SG val: 010 101 001 100 000 001 100 001 000 001 000 000 Heap 2: -2 Heap 3: -4 Heap 1: -1 WIN! Heap 1: -4 Heap 2: -1

Black Out – BAPC 2012 B Black Out Table of 5 by 6 Each player in turn selects one or more squares that are adjacent and in the same row or column, and colors them all black. You may paint over black squares, but at least one square needs to be white. The winner is the player to color the last square(s) black. Your AI may always start the game. Strategy Get to a state where you can mirror your opponent’s moves (P-position), and the state of the table is symmetric. You will then always be able to make a move. How? Start by filling squares in the 3rd row such that your filled area is centered in the middle of the row.

Exercise Problems Impartial Games BAPC11G – Doubloon Game EAPC14E – Pawns EAPC11J – Shuriken Game Further reading Winning Ways for your Mathematical Plays by E. Berlekamp, J.H. Conway and R. Guy (1982)