I am working on an assignment that involves simulating a volley ball game and I have NO idea. Can anyone help.
Here is the question
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 else: winsB = winB + 1 return winsA, winsB def simOneGame (probA, probB): serving= "A" scoreA = 0 scoreB = 0 while not gameOver (scoreA, scoreB): if serving == "A": if random () < probA: scoreA = scoreA + 1 else: serving = "B" else: if random() < probB: scoreB = scoreB + 1 else: 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) if __name__=='__main__':main()
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Private Sub btn_addline_Click(ByVal ...