我真的很感激python程序的一些帮助。这是一个板球程序;询问用户要玩的轮数,然后跟踪跑动、检票口和轮盘。那部分没问题,但我不知道如何跟踪每个击球手和跑动。一次只有一名击球手可以出去,他们在每次结束后交换前锋端,显然是为了奇怪的跑动。如果可以的话请帮忙。到目前为止,这是程序的一部分,我只需要添加击球手。
for overs in range(1, numOvers + 1):
if endGame: #.........set to true from inner loop when breaking
break
print()
print("---------------------------")
print("Enter runs for over ", overs)
print("---------------------------")
#inner loop for number of balls in the over
for _runs in range(1, BALLS_IN_OVER + 1):
#calculate the number of overs and remainding balls
totalBallsFaced += 1
totalOversFaced = (totalBallsFaced // BALLS_IN_OVER)
partOverFaced = (totalBallsFaced % BALLS_IN_OVER)
#print()
runs = int(input("> ")) #...........prompt user for runs
if runs < 0:#.......................if negative number, add to 1 to wicket
wicket += 1
print("Batter out...")
if wicket >= 10:#...............if batter out and if all batters out then team out
print("Batters all out")
endGame = 1 #..............set to true
break #.......................break to outer loop
else:
total += runs #..................if input >= 0 , add to total
感谢快速反馈的家伙,我考虑了这两个想法并最终完成了。只有指数 1 得分和击球手指数 2 的击球手是另一个击球手,他们只是交换奇数跑。