Question: I need help creating these three functions: The simulate function should simulate playing a given number of hands of blackjack and track the winnings (

I need help creating these three functions:
The simulate function should simulate playing a given number of hands of blackjack and track the winnings (and high- and low-water marks).The simulate method should handle player actions, including betting, hitting, staying, doubling, and payoff. Let's ignore insurance and splitting to make things easier. It should reshuffle on the next hand after the penetration percentage has been achieved in the shoe (and notify the player).
Code Snippet:
def simulate(player,
dealer=Soft17(),
hands=100,
ndecks=6,
penetration=0.7,
nplayers=7):
"""simulate playing an evening's worth of blackjack
:param player: Blackjack object representing the player
:param dealer: Blackjack object representing the dealer
:param hands: Number of hands to simulate
:param ndecks: Number of decks in each shoe
:param penetration: Depth of shoe before reshuffling
:param nplayers: Number of other players present (not simulated, but cards seen)
:return: (final, lo, hi) player's accumulated winnings
"""
The visualize function must call simulate and then plot the results in a histogram with the other visualization features noted above on the plot.
Code Snippet:
def visualize(trials, player=Basic()):
"""simulate and plot results of a blackjack strategy
:param trials: number of trials to simulate
:param player: player Blackjack object to simulate
"""
The helper function, overlay_bell_curve, must also be called by visualize and have the following spec for itself and also its nested function f.
Code Snippet:
def overlay_bell_curve(mu, sigma, n, bins):
"""Overlay a normal curve atop an histogram on current pylab figure.
:param mu: mean
:param sigma: standard deviation
:param n: number of events tracked in histogram
:param bins: number of bins in histogram
"""
def f(x):
"""probability density function of normal distribution"""

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!