OK, so i have worked on it a bit and have developed some code but am having problems with defining when the game should stop because the winning player needs to wins by 2 points and the highest score needs to be atleast 15. here is my code so far
def main ():
print Intro ()
probA, probB, n = getInputs ()
winsA, winsB = simNGames (n, probA, probB)
printSummary (winsA, winsB)
def Intro ():
print "This program simulates a gsme of volleyball between"
print "two players called A and B."
print "player A always has the first serve"
def getInputs ():
a = input ("Player A wins a serve")
b = input ("Player B wins a serve")
n = input ("How many games do you want to simulate?")
return a, b, n
def simNGames(n, probA, probB) :
winsA= winsB = 0
for i in range(n):
scoreA, scoreB = simOneGame (probA, probB)
if scoreA > scoreB:
winsA =winsA + 1
winsB = winB + 1
return winsA, winsB
def simOneGame (probA, probB):
scoreA = 0
scoreB = 0
while not gameOver (scoreA, scoreB):
if serving == "A":
if random () < probA:
scoreA = scoreA + 1
serving = "B"
if random() < probB:
scoreB = scoreB + 1
serving = "A"
return scoreA, scoreB
def gameOver(a, b):
if (a - b) > 2 or < -2
def printSummary(winsA, winsB):
n= winsA + winsB
print "\nGames simulated", n
print "Wins for A: %d (%0.1f%%)" % (winsA, float(winsA)/n*100)
print "Wins for B: %d (%0.1f%%)" % (winsB, float(winsA)/n*100)
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...