Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 1 consist of three exercises. This is the third of three exercises in Lab 1 , which focuses on basic loops and conditionals, functions

Lab 1 consist of three exercises. This is the third of three exercises in Lab 1, which focuses on basic loops and conditionals, functions and passing objects as parameters, dictionaries, and bar chart visualization.
This exercise is to simulate 200000 rounds of a dice version of the children's card game War. The purpose of this simulation is to determine which player has an advantage of based on these rules below.
Rules
There are two players: PLAYER and BANKER. These are just names for the players. Each player has a regular six-sided die. In one round, each player will roll their die and attempt to get the highest value. The rules are:
If either player rolls a six, the game stops. The player with the higher die value wins. If both dice values are the same, then it is a tie.
If neither player has a six in the initial roll, then a player may re-roll under these conditions:
If the BANKER initially rolled a 3 or below, the BANKER will re-roll their die.
If the PLAYER initially rolled a 2 or below, the PLAYER will re-roll their die.
After this reroll, the game stops. The player with the higher die value wins. If both dice values are the same, then it is a tie.
Tasks
The starter code has been created for you. You must use it with the two functions you will write, especially the outcomes dictionary variable declared for you.
Complete the simulateGames function. Simulate the total number of rounds with the rules. Determine the outcome and increase the count on the outcomes dictionary. Use the rollDie function included for you for this task.
Complete the visualizeResults function. Use the seaborn barplot() to visualize the outcomes.
Function comments have been added for you.
Answer the questions below.

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

Step: 3

blur-text-image

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

How are taxes accounted for when we calculate the cost of debt?

Answered: 1 week ago

Question

Part A . What three essential items are missing from this plot?

Answered: 1 week ago