Card Game Simulation(in Python 3.8.1)
The purpose of this assignment is to help you gain experience using while loops to solve problems.
For this assignment, you will simulate a simplified card game that has some similarity to the game of 21. At the start of the program, the user will be asked to supply both the winning score (an integer from 1 thru 21) and the number of times to run the simulation (an integer from 100 to 100,000). To determine if a game results is a win or a loss, a random card is repeatedly drawn from an infinite deck of cards until either the sum of the drawn cards equals the winning score (in which case the game is won) or exceeds the winning score (in which case the game is lost). There are 13 types of cards in the deck: aces, 2s, 3s, 4s, 5s, 6s, 7s, 8s, 9s, 10s, jacks, queens, and kings. Because the deck is infinite, the probability of drawing any card at any point in the simulation is always the same. Assume that an ace counts as 1 point, a jack as 10, a queen as 10, a king as 10, and all other cards as face value.
Example: Suppose the desired winning score is 19 and random cards are generated as follows:
Sample Output Transcript
This transcript shows two runs of the program. In the first simulation, the program simulates the card game 11,111 times looking for a sequence of cards that adds up to 21. Because random numbers are used, each time the program is run, slightly different answers might appear. In the second simulation, the program simulates the card game 100,000 times looking for a sequence of cards that adds up to 1.
Notice that the program requires the user to enter integers until one in the proper range is supplied. Note: the program does not need to handle the case where something other than an integer is entered.
Requirements
The required code is given below in case of any douts you can ask me in comments
main.py


CODE TO COPY
import random
def generate_card():
cards =
["ace","2","3","4","5","6","7","8","9","Jack","Queen","King"]
return random.choice(cards)
def getCardValue(val):
if val == "ace":
return 1
elif val == "2":
return 2
elif val == "3":
return 3
elif val == "4":
return 4
elif val == "5":
return 5
elif val == "6":
return 6
elif val == "7":
return 7
elif val == "8":
return 8
elif val == "9":
return 9
elif val == "Jack" or val == "Queen" or val == "King":
return 10
def simulate_one_game(winScore):
game = True
score = 0
print()
while game:
card = generate_card()
val = getCardValue(card)
score += val
if score<winScore:
print(card ," - cummulative score is, ",score,", Keep Going")
elif score==winScore:
print(card ," - cummulative score is, ",score,"\nCongratualtion!
You win")
game = False
return True
elif score>winScore:
print(card ," - cummulative score is, ",score,"\nSorry! You
Lost")
game = False
return False
print()
def user_Input(minVal,maxVal,msg):
winScore = 0
while winScore<minVal or winScore>maxVal:
winScore = int(input(msg))
return winScore
def main():
wins=0
msg = "Enter winning Score (between 1 - 23): "
winScore = user_Input(1,23,msg)
noOfGames = int(input("Enter number of times to run simulation :
"))
for i in range(noOfGames):
if(simulate_one_game(winScore)):
wins+=1
print("Total wins : ",wins)
main()
OUTPUT
Card Game Simulation(in Python 3.8.1) The purpose of this assignment is to help you gain experience...
Suppose, we have 3 players and they are playing a card game. In the card game, the deck contains 10 cards where there are 3 kings, 3 aces, and 4 jacks. Each player gets a card from the deck randomly. The winner of the game is determined based on the strength of the card where a king has 10 strength, an ace has 15 strength and a jack has 20 strength. Your task is to write a function called playgame()...
Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....
For this assignment you will create a one-player variation of the game BlackJack. The game will be divided into five rounds. The goal of each round is to accumulate a hand of cards that gets as close to 21 without going over. At the beginng of the game you will start with a score of 100 points. After each round, the difference between your hand and 21 will be subtracted from your total score. The object of the entire game...
Using C++: 1. Array and Struct in Card applications: In card game design, card suit and face values can be defined with enumeration values. Declare suit values - – hearts, clubs, diamonds, spades using enum, declare face values of 2 – 10, Jack, Queen, King, Ace using enum Declare a structure called Card, and it includes two data members, whose data types are the above two defined enumerations suit and face typedef an array called Deck, and it includes all...
I need to build the card game of War in C++. It will be a 2 player game. Each player will have their own deck of 52 cards. 2-10, Jack=11, Queen=12, King=13, Ace=14. Each player will draw one card from their deck. The player with the higher card wins both cards. If the card drawn is the same, then each player will draw 3 cards and on the 4th card drawn will show it. The player that shows the higher...
Python 3.7 Card Game: In this assignment you will be creating ‘card game’ with specific rules. Rules of the game are fairly simple. The game will be played with 3 players, two AI players and 1 Human player. Rules of the game: 1- Will have 3 players (2 AI, and 1 Human player). 2- The cards we have for this game is three ones (1), three twos (2), and three three’s (3). 3- Need to shuffle the cards randomly so...
2. You are playing a game where you chose a card at random from a standard deck of 52 cards. If the card chosen is a face card then you win $3. If the card is not a face card then you pay $1. There are 12 face cards in the deck. (a) How much money would you expect to win or lose each time you play the game? (b) If you wanted to make the answer to part a)...
In C++ program Fishing Game Simulation For this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught. Each possible item is worth a certain number of fishing points. The points will not be displayed until the user has finished fishing, and then a message is displayed congratulating the user depending on the number of fishing points gained. Here are some suggestions for the...
Please to indent and follow structure!!!!!
Assignment 3 - The card game: War Due Date: June 9th, 2018 @
23:55
Percentage overall grade: 5% Penalties: No late assignments
allowed
Maximum Marks: 10
Pedagogical Goal: Refresher of Python and hands-on experience
with algorithm coding, input validation, exceptions, file reading,
Queues, and data structures with encapsulation.
The card game War is a card game that is played with a deck of
52 cards. The goal is to be the first player to...
You play a game in which you are dealt one card at random from a standard deck of 52 cards. The payoffs are: $10 if you get a face card (a jack, a queen, or a king) Twice the number showing on a number card: $2 for an ace, $4 for a 2, and so on up to $20 for a 10 What is the expected value of the game? Choose the best answer. A) 10+2+4+⋯+20 B) 35/2×10+1/52×2+1/52×4+⋯+1/52×20 C) 3/13×10+1/13×2+1/13×4+⋯+1/13×20...