Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python. please help me out asap Playing time: About 5 minutes. Goal: Win the opponent's Army Equipment Needed: Ten coins Setup: Each player takes five

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
python. please help me out asap
Playing time: About 5 minutes. Goal: Win the opponent's Army Equipment Needed: Ten coins Setup: Each player takes five coins, arranges their coins in a sequence called their "Army", and then flips each coin in turn so that it randomly shows heads (H) or tails (T) The starting board layout should look something like this: Player 1: THTIT Player 2: TTHTH Coins can be captured as prisoners by an army. These coins go after the army coins, leaving space between them. The order of coins in the army and prisoners is important they must not be rearranged during play unless specified in the rules below Round of play: The players compare the first coins in their armies If the first coins don't match H beats T, so the player with H captures the coin of the player with T. and puts the T and Hat the end of their Army in that order. In addition, the player with H then captures any Prisoners of the player with T see below and places the opposing Prisoners and then their own Prisoners in order at the end of their Army . If the first coins do match (both players have H or both have 1), each player puts their first coin at the end of their Prisoners Players with coins still in their Army then put the first remaining coin in their Army at the end of their Prisoners. Victory conditions: At any point, if either player has no Army, the game is immediately over If only one player has an Army, that player wins. Otherwise, both players must have no Army -- all coins must be prisoners. . If one player has more coins than the other in their Prisoners, that player wins. o Otherwise, the game is a tie: . Let's Play A Game Coin War is a two-player game inspired by the card game War. The rules are given here. Even though Coin War is much shorter and more interesting than the card game, it still gets boring to play through a game. Would be great if we could just get a computer to take a starting position, play out the game for us, and tell us who wins. What we want to do is. h For this assignment, you will create a program that allows the user to input a starting position of Coin War. You may choose to take input either from standard input or from a file named on the command line (your choice: be sure to document which you chose in your README). Then the program will play the game to completion and report whether Player 1 or Player 2 wins. The first line of the input should be either "random" or "position". If the first line is "position". the next two lines should each be five letters. Each letter should be either Hor T. Sample input requesting a random game: random Sample input requesting a game from a given position: an German English X Artide Talk Google Translate War (card game) From Wikipedia, the free encyclopedia War (also known as Battle in the United Kingdom) is a simple War card game, typically played by two players using a standard Alternative names Battle playing card deck21 and often played by children. There are Type many variations, including the German 32-card variant Tod und Catching type Players 2 Leben ("Life and Death") Skills required Counting and card Contents [hide] values 1 Gameplay Age range 5-120 Cards 52 2 Variations 3 See also Deck French 4 References Play Clockwise 5 Literature Card rank (highest AKQJ 10 9 8 7 65 first) 32 6 External links Playing time 10-40 min Random chance High Gameplay [edit] Related games The objective of the game is to win all of the cards. Beggar-My-Neighbour The deck is divided evenly among the players, giving each a down stack. In unison, each player reveals the top card of their deck--this is a battle--and the player with the higher card takes both of the cards played and moves them to their stack. Aces are high, and suits are ignored.121 if the two cards played are of equal value, then there is a war 21 Both players place the next three cards face down and then another card face-up. The owner of the higher face-up card wins the war and adds all the cards on the table to the bottom of their deck. If the face-up cards are again equal then the battle repeats with another set of face-down up cards. This repeats until one player's face-up card is higher than their opponent's Most descriptions of War are unclear about what happens if a player runs out of cards during a war in some variants that player immediately loses in others, the player may play the last card in their deck as their face up card for the remainder of the war or replay the game from the beginning Game designer Greg Castikyan has observed that since there are no choices in the game and all outcomes are random cannot be considered game.by some definitions. However the rules often donat Recity in Strategy 1. Functions a. Define a function to read the input. One possibility is to have the function return a list of two lists. The first list would contain the five coin position characters for Player 1. The second list would contain the five coin position characters for player 2 as The function will either read the position from the input, or randomly generate a position. b. Define a function to play out the game. It should take the position as an argument and return either 1, 2 or 0 described in the assignment. 1 The function will have to manipulate the players lists. Each player has both an army list and a prisoners list. The prisoners list starts empty 11 A while loop can be used to run rounds of the game until it is over 111 Inside the while loop. there will be an if with two or three cases. It might be worth defining a separate function for a round that is not a tie, to avoid duplicating code 2. Call the functions, print the result. Sample game: Here is the starting setup: each player has flipped their five coins and is ready to begin play Player 11 THHTT Player 2: TTHTH We start round 1 Player 1: THITT Player 2: ITHTH Both players have T at the front of their army, so this is a tie Player 11 THHTT Player 2: TTHTH As a result of the tie, cach player moves the first coin, the T, to the end of their prisoners. This gives cach side its first prisoner Player 1: MATT I Player 2: THTHT Each player then moves their new first coin to the end of their prisoners as well Player 1: HIT TH Player 2: HTH TT That ends round 1 Now we start round 2 Player 1: HIT TH Player 21 MTH TI Both sides start with heads, so it is a tie again. We move each player's H to the back of their prisoners Player It IT THE Player 21 TH TTH followed by their next coin - both have T Player 1 T THAT FiAyer 21 TTHT Thus ends found 2 We now start round 3 PENYET THAT Psy 21 TTIT followed by their next coin-both have T. Player 1: I THET Player 2: H TTHT Thus ends round 2 We now start round 3. Player 1: T THAT Player 2: H TTHT Player 2 wins this round, because H beats T. So Player 2 captures Player I's first coin and places it at the tail of Player 2's army, Player 11 THAT Player 21 HT TTHT Player 2 then places their own head coin at the tail of their army Player 1: THAT Player 21 TH TTHT then Player l's prisoners Player 11 Player 2: THTHAT TTT then their own prisoners Player 11 Player 2: THTHTITIT That ends round 3. At the start of round 4 Player 1: Player 1 THTHTTTT only Player 2 has coins, o Player 2 wins de over layer wina Strategy Coin War is a frame of pure luck The player who starts with the most heads almost always wins View at Page Playing time: About 5 minutes. Goal: Win the opponent's Army Equipment Needed: Ten coins Setup: Each player takes five coins, arranges their coins in a sequence called their "Army", and then flips each coin in turn so that it randomly shows heads (H) or tails (T) The starting board layout should look something like this: Player 1: THTIT Player 2: TTHTH Coins can be captured as prisoners by an army. These coins go after the army coins, leaving space between them. The order of coins in the army and prisoners is important they must not be rearranged during play unless specified in the rules below Round of play: The players compare the first coins in their armies If the first coins don't match H beats T, so the player with H captures the coin of the player with T. and puts the T and Hat the end of their Army in that order. In addition, the player with H then captures any Prisoners of the player with T see below and places the opposing Prisoners and then their own Prisoners in order at the end of their Army . If the first coins do match (both players have H or both have 1), each player puts their first coin at the end of their Prisoners Players with coins still in their Army then put the first remaining coin in their Army at the end of their Prisoners. Victory conditions: At any point, if either player has no Army, the game is immediately over If only one player has an Army, that player wins. Otherwise, both players must have no Army -- all coins must be prisoners. . If one player has more coins than the other in their Prisoners, that player wins. o Otherwise, the game is a tie: . Let's Play A Game Coin War is a two-player game inspired by the card game War. The rules are given here. Even though Coin War is much shorter and more interesting than the card game, it still gets boring to play through a game. Would be great if we could just get a computer to take a starting position, play out the game for us, and tell us who wins. What we want to do is. h For this assignment, you will create a program that allows the user to input a starting position of Coin War. You may choose to take input either from standard input or from a file named on the command line (your choice: be sure to document which you chose in your README). Then the program will play the game to completion and report whether Player 1 or Player 2 wins. The first line of the input should be either "random" or "position". If the first line is "position". the next two lines should each be five letters. Each letter should be either Hor T. Sample input requesting a random game: random Sample input requesting a game from a given position: an German English X Artide Talk Google Translate War (card game) From Wikipedia, the free encyclopedia War (also known as Battle in the United Kingdom) is a simple War card game, typically played by two players using a standard Alternative names Battle playing card deck21 and often played by children. There are Type many variations, including the German 32-card variant Tod und Catching type Players 2 Leben ("Life and Death") Skills required Counting and card Contents [hide] values 1 Gameplay Age range 5-120 Cards 52 2 Variations 3 See also Deck French 4 References Play Clockwise 5 Literature Card rank (highest AKQJ 10 9 8 7 65 first) 32 6 External links Playing time 10-40 min Random chance High Gameplay [edit] Related games The objective of the game is to win all of the cards. Beggar-My-Neighbour The deck is divided evenly among the players, giving each a down stack. In unison, each player reveals the top card of their deck--this is a battle--and the player with the higher card takes both of the cards played and moves them to their stack. Aces are high, and suits are ignored.121 if the two cards played are of equal value, then there is a war 21 Both players place the next three cards face down and then another card face-up. The owner of the higher face-up card wins the war and adds all the cards on the table to the bottom of their deck. If the face-up cards are again equal then the battle repeats with another set of face-down up cards. This repeats until one player's face-up card is higher than their opponent's Most descriptions of War are unclear about what happens if a player runs out of cards during a war in some variants that player immediately loses in others, the player may play the last card in their deck as their face up card for the remainder of the war or replay the game from the beginning Game designer Greg Castikyan has observed that since there are no choices in the game and all outcomes are random cannot be considered game.by some definitions. However the rules often donat Recity in Strategy 1. Functions a. Define a function to read the input. One possibility is to have the function return a list of two lists. The first list would contain the five coin position characters for Player 1. The second list would contain the five coin position characters for player 2 as The function will either read the position from the input, or randomly generate a position. b. Define a function to play out the game. It should take the position as an argument and return either 1, 2 or 0 described in the assignment. 1 The function will have to manipulate the players lists. Each player has both an army list and a prisoners list. The prisoners list starts empty 11 A while loop can be used to run rounds of the game until it is over 111 Inside the while loop. there will be an if with two or three cases. It might be worth defining a separate function for a round that is not a tie, to avoid duplicating code 2. Call the functions, print the result. Sample game: Here is the starting setup: each player has flipped their five coins and is ready to begin play Player 11 THHTT Player 2: TTHTH We start round 1 Player 1: THITT Player 2: ITHTH Both players have T at the front of their army, so this is a tie Player 11 THHTT Player 2: TTHTH As a result of the tie, cach player moves the first coin, the T, to the end of their prisoners. This gives cach side its first prisoner Player 1: MATT I Player 2: THTHT Each player then moves their new first coin to the end of their prisoners as well Player 1: HIT TH Player 2: HTH TT That ends round 1 Now we start round 2 Player 1: HIT TH Player 21 MTH TI Both sides start with heads, so it is a tie again. We move each player's H to the back of their prisoners Player It IT THE Player 21 TH TTH followed by their next coin - both have T Player 1 T THAT FiAyer 21 TTHT Thus ends found 2 We now start round 3 PENYET THAT Psy 21 TTIT followed by their next coin-both have T. Player 1: I THET Player 2: H TTHT Thus ends round 2 We now start round 3. Player 1: T THAT Player 2: H TTHT Player 2 wins this round, because H beats T. So Player 2 captures Player I's first coin and places it at the tail of Player 2's army, Player 11 THAT Player 21 HT TTHT Player 2 then places their own head coin at the tail of their army Player 1: THAT Player 21 TH TTHT then Player l's prisoners Player 11 Player 2: THTHAT TTT then their own prisoners Player 11 Player 2: THTHTITIT That ends round 3. At the start of round 4 Player 1: Player 1 THTHTTTT only Player 2 has coins, o Player 2 wins de over layer wina Strategy Coin War is a frame of pure luck The player who starts with the most heads almost always wins View at Page

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions