Team Dont Block Me, National Taiwan University

Slides:



Advertisements
Similar presentations
ICAMP: Game Simulation and Analysis Analysis of the Game “Poison” Sarah Eichhorn University of California Irvine iCAMP Overview Meeting, 5/5/10.
Advertisements

Game Theory An Overview of Game Theory by Kian Mirjalali.
AE1APS Algorithmic Problem Solving John Drake.  Invariants – Chapter 2  River Crossing – Chapter 3  Logic Puzzles – Chapter 5  Matchstick Games -
Two-Player Zero-Sum Games
Progressively Finite Games
For the ultimate in entertainment, play with 2 or more people, individually or as a team Players alternate turns Each player picks an “answer” and must.
CompSci Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything,
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:
Brian Duddy.  Two players, X and Y, are playing a card game- goal is to find optimal strategy for X  X has red ace (A), black ace (A), and red two (2)
An Introduction to Game Theory Math 480: Mathematics Seminar Dr. Sylvester.
Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010.
Example 31: Solve the following game by equal gains method: Y I II I II I X II II
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.
Benjamin Casey C S 329 E Spring  Variants played since ancient times; resemblance to Chinese “Jianshizi” or “picking stones”  Current name and.
Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (1) d091: Urban Transport System Po-Lung Chen Team Dont Block Me, National Taiwan.
CompSci Recursion & Minimax Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything, ace your computer science.
Game Theory [geym theer-ee] : a mathematical theory that deals with the general features of competitive situations in a formal abstract way.
Backtracking, Search, Heuristics
Tools for Decision Analysis: Analysis of Risky Decisions
Sequential Flexibility
Today we are going to play…..
Great Theoretical Ideas in Computer Science
Analyzing Games of Chance Investigation 5 – How Likely Is It?
How to play football By Emanuel Ellis.
Designing: A Game of Chance
Pre-Calculus – Chapter 2
Task: It is necessary to choose the most suitable variant from some set of objects by those or other criteria.
Learn Satta Matka Strategies that can help you win a lottery game.
CONTACT AT: xBox Helpline Number. Issues we solved How to login account How to play the downloaded game Not able to update the gaming console.
Lecture 12.
C nnect 4 Group 9-18 See Zhuo Rui Jorelle 3S3 (Leader)
Artificial Intelligence
Game Theory.
CS330 Discussion 4 Spring 2017.
The Game: Attack and Defend
Main Game Set-Up Fill in your questions and answers.
Welcome to Experts! While you’re waiting, check your audio. EXPERTS.
Probability And Expected Value ————————————
Alpha-Beta Search.
Today we are going to play…..
Game Theory II.
NIM - a two person game n objects are in one pile
Artificial Intelligence
Support vector machines
Alpha-Beta Search.
Topic 1: Problem Solving
Alpha-Beta Search.
Pruned Search Strategies
Probability And Expected Value ————————————
Blockbusters!!! Graphing Lines.
Strike it out.
Support vector machines
Lecture 20 Linear Program Duality
Systems of Inequalities. Linear Programming
X y y = x2 - 3x Solutions of y = x2 - 3x y x –1 5 –2 –3 6 y = x2-3x.
Alpha-Beta Search.
Try starting with fewer objects to investigate.
Game Theory Day 2: More Simple Games.
Factor Game Sample Game.
GAMES AND STRATEGIES.
GAMES AND STRATEGIES.
Assignment #3: Kalah.
Do not use a calculator for the following!!.
Alpha-Beta Search.
Backtracking, Search, Heuristics
Minimax strategies, alpha beta pruning
CS51A David Kauchak Spring 2019
Backtracking, Search, Heuristics
Jeopardy.
Game Design Principles
Presentation transcript:

Team Dont Block Me, National Taiwan University d038: Nim Game (Again) Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Nim Game The Nim Game consists of some piles of stones, and the players take turn to grab stones from some pile(s). The player who grabs the last stone loses the game. pile1 pile2 pile3

Problem Description (1/3) A Nim Game variant: 2 piles of stones, each pile consists of zero or more stones. 2 players, alternately grab stones from the pile(s). The one who grabs the last stone loses the game. Grabbing rule: Grab at least one stone from one of the two piles. Grab from each of the two piles the same number of stones.

Problem Description (2/3) The player who does NOT grab first will have one chance of launching a “counterattack” during the game play. Counterattack:

Problem Description (3/3) Two experts playing this new Nim game. Their strategies are always the best possible. If the current situation would lead to a win: choose the way minimizing #steps. If the current situation would lead to a loss: choose the way maximizing #steps. Given the number of the stones and , Determine: (1) First player will win or lose. (2) The total number of steps in this game.

Solution (1/4) This problem can be solved by dynamic programming. A “state” of the game consists of: # of stones in first pile # of stones in second pile the current player has the chance to use counterattack? the other player has the chance to use counterattack? A win/lose function can be determined by the “state”. can be “WIN” or “LOSS”

Solution (2/4) The recurrence relation: The initial condition: “WIN”, if Otherwise “LOSS” The initial condition: , , and are all “WIN” states.

Solution (3/4) Similarly, we can define the function for the number of steps in game according to players’ strategies. Case 1 (the state is going to win): Find minimum (if possible)

Solution (4/4) Case 2 (the state is going to lose): For initial conditions, set them all to zero. Find maximum (if possible)

Time Complexity Let be the maximum number of stones +1 in a pile. The number of possible states is no more than . Calculation time for a state is . Therefore the time complexity is . We can use pre-calculation to find out the answer to all the possible states.

Implementation Details Be careful! The maximum number of stones in a pile can be 110, not 100. This might cause runtime error if the array is too small.

Finally… Thanks for your attention!