Given: The information provided is given as follows:
Aim: To design an algorithm such that the first player should choose his moves in such a way that no matter what moves the second player chooses, the first player will always win.
Note: It is given that each piles have n number of pebbles and there are 3 piles.
Therefore, total number of pebbles, N = 3n
Algorithm: The algorithm is given as follows:
Procedure defining which move will force a win:
Complexity:
Problem 4. (20 points) Pebbles Game. Two players play a game, starting with three piles of...
1. NIM game is a game with multiple piles of match sticks with the two players taking turns to remove 1 pile or part of 1 pile. The person getting the last stick wins. In the class I had shown how (1, 1) and (2, 2) are losing configurations (i.e. the person facing two piles of 2 and 2 sticks will lose). a) Prove that (3, 4) is a winning configuration. Show how the 1s player can win if she...
1. NIM game. This is a different version or easier version of NIM game Consider a pile of 5 matchsticks. Two people take turns removing 1 or 2 sticks each time from this pile. Suppose both players play smartly (nobody plays a fool move trying to let the opponent wins. But there is only one winner anyway) a)If the person getting the last stick wins, will the first player win? Why? Show the steps the first and second player will...
A subtraction game Subtraction games are two-player games in which there is a pile of objects, say coins. There are two players, Alice and Bob, who alternate turns subtracting 4.9. A SUBTRACTION GAME 19 from the pile some number of coins belonging to a set S (the subtraction set). Alice goes first. The first player who is unable to make a legal move loses. For example, suppose the initial pile contains 5 coins, and each player can, on his turn,...
Your task in to design a game of Nim in Python. In this game “Two players take turns removing objects from distinct heaps or piles. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap/pile. The goal of the game is to avoid taking the last object.” (Wikipedia) In your implementation of the game, there will be 3 piles of objects. At the start...
Answer the following Nim game style questions. (Robert's Game) In this game, two players take turns removing stones from a pile that begins with n stones. The player who takes the last stone wins. A player removes either one stone or p stones, where p is a prime dividing the number of stones in the pile at the start of the turn For which n does the First Player have a winning strategy? A winning strategy for the First Player...
(Game: play a tic-tac-toe game) In a game of tic-tac-toe, two players take turns marking an available cell in a grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the cells in the grid have been filled with tokens and neither player has achieved a win. Create...
Program 4: C++ The Game of War The game of war is a card game played by children and budding computer scientists. From Wikipedia: The objective of the game is to win all cards [Source: Wikipedia]. There are different interpretations on how to play The Game of War, so we will specify our SMU rules below: 1) 52 cards are shuffled and split evenly amongst two players (26 each) a. The 26 cards are placed into a “to play” pile...
Consider a game in which two players, Fred and Barney, take turns removing matchsticks from a pile. They start with 21 matchsticks, and Fred goes first. On each turn, each player may remove either one, two, or three matchsticks. The player to remove the last matchstick wins the game. (a) Suppose there are only 5 matchsticks left, and it is Fred’s turn. What move should Fred make to guarantee himself victory? Explain your reasoning. (b) Suppose there are 10 matchsticks...
1 22. (10 marks) In a game, three players A, B and C take turns to shoot at a target. Player A shoots first. If A misses the target, B shoots. If B misses the target, C shoots. If missed the target, A shoots; and so on. When a player hits the target, this player wins the game and the game is over. The probability that A hits the target is the probability that B hits the target is; and...
18. Tic-Tac-Toe Game rite a program that allows two players to play a game of tic-tac-toe. Use dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following: Write . Displays the contents of the board array. . Allows player 1 to select a location on the board for an X. The program should ask the...