그래서, 나는이 포럼의 사용자들로부터 도움을 받아 웹을 둘러 보는 것으로부터 프로그램 시뮬레이터를 연구하고있다. 나는 대부분 그것을 끝낼 수있었습니다. 적어도 나는 게임의 논리를 가지고 있다고 생각한다.While loop 영원히 반복하다. Python
지난 번 실행했을 때 실행 중이었지만 지금은 while 루프가 영원히 실행되기 때문에 뭔가를 인식하지 못하고 변경해야합니다. 프로그램에서 주사위는 사용자의 개입없이 영원히 계속 굴러 가고 있습니다.
누군가 코드를 볼 수 있고 코드에 문제가 있는지 확인할 수 있습니까? 나는 몇 시간 동안이 일을하고 있었고, 어디를 가는지 알지 못했다.
나는 결코 다시는 도박을하지 않을 것이다! :/
from Dice import PairOfDice
print("Now Let's play with two dice!")
#
def MainDouble():
bdice = PairOfDice()
doubleDiceRoll = ''
global myPoint #declare global variable
input("Press Enter to Roll the Dice once")
while doubleDiceRoll == '': #Roll the dice (both die objects)
bdice.toss()
print ('The first die reads.. ' + str(bdice.getValue1()) + '\n')
print ('The second die reads.. ' + str(bdice.getValue2()) + '\n')
Val = bdice.getTotal()
##Beginning of conditional blocks##
if Val == 7 or Val == 11:
gamestatus = "WON"
elif Val == 2 or Val == 3 or Val == 12:
gamestatus = "LOST"
if Val != 7 and bdice.getTotal() != 11 and Val != 2 and Val != 3 and Val != 12:
gamestatus = "CONTINUE"
#
myPoint = Val
print("The Point is now " + myPoint + "/n") #display the user's point value
global pSum
pSum = 0
#The point
while gamestatus == "CONTINUE": #Checking the point
global point
point = myPoint
pSum = MainDouble()
if pSum == myPoint:
gamestatus == "WON"
elif pSum == 7:
gamestatus = "LOST"
if gamestatus == "WON":
print("Winner!")
else:
print("Sorry, Seven out!")
print ("Roll Again?")
doubleDiceRoll = input("Roll Again?")
MainDouble()
스크립트의 마지막에'doubleDiceRoll = input ("Roll Again?")'이 있지만'while doubleDiceRoll == '''안에 있지 않습니다. 아무것도 변경하지 않고 항상 참입니다. – mhlester