Answered! In Python code can you please code the following in regards to the dice game '"crapps". "Make the point" means you…

No Come Out Continuous Rolls Roll Play? Yes (Make Bet) Yes Yes (Natural) (Point Win) Point 7 or WIN Value? 11? No No Yes Yes (7-out) (Craps) 2, 3, LOSE or 12? Point Value Roll 4, 5, 6, 8, 9, 10

In Python code can you please code the following in regards to the dice game ‘”crapps”. “Make the point” means you roll a 7 on the first time you roll the dice. Write a function called make_point(point, num_loaded) that simulates whether or not you “make the point”. This function should take two inputs: point (the “point” rolled on the first roll assuming you don’t crapp out or win) and the num_loaded parameter that indicates the number of loaded dice that should be used in lower level functions. This function should return True if the point is made and False if the point is not made for the simulated scenario. This function should have the function parameter defaults set so that num_loaded defaults to 0.

Expert Answer

 

from random import randint

from sys import exit

import os

def handle_roll(total_counts):

die1, die2 = randint(1, 6), randint(1, 6)

total = die1 + die2

total_counts[total – 2] += 1

print ‘Die 1: %d nDie 2: %d nTotal: %d.’ % (die1, die2, total)

print ‘nnRoll again?’

response = raw_input(‘Press enter to roll again, type “stats” to view scores, or “quit” to exit.n> ‘).lower()

if response == ”:

return handle_roll

elif response == ‘stats’:

return handle_stats

elif response == ‘quit’:

return None

return handle_unknown

def handle_stats(total_counts):

for i in xrange(0, 11):

print ‘%ds: %d’ % (i + 2, total_counts[i])

raw_input(”)

return handle_roll

def handle_unknown(total_counts):

print ‘I don’t know what that means so you get to roll again.’

raw_input(”)

return handle_roll

def main():

os.system(‘clear’)

print ‘Welcome to the dice rolling simulator!’

raw_input(‘Press enter to begin.’)

total_counts = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

state = handle_roll

while state != None:

os.system(‘clear’)

state = state(total_counts)

if __name__ == “__main__”:

main()

Still stressed from student homework?
Get quality assistance from academic writers!