|
|
发表于 2018-7-5 23:17:07
|
显示全部楼层
替你改了,不用递归。只是简单的试了,不知有没有bug
- import random
- def funDice():
- return [random.randint(1,6) for i in range(3)]
- def funBigOrSmall(ndice,boolnum):
-
- if (ndice <= 9 and boolnum == 'S') or (9 < ndice <= 18 and boolnum == 'B'):
- return True
- else:
- return False
-
- def funGameStarts(money):
- while True:
- print("<<<<<< Game Starts >>>>>>")
- while True:
- Guess = input("B(Big) or S(Bmall):") #简化一下,只输入一个字母
- Guess = Guess.upper()
- if Guess in ['B', 'S']:
- break
- print("输入有误噢!")
- Bet = int(input("How much you wanna bet ? -"))
- if Bet > money:
- print("赌注不够噢")
- break
- print("<<<<<< Roll The Dice >>>>>>")
- Dicetemp = funDice()
- print("The points is ",Dicetemp,end=' ')
- if funBigOrSmall(sum(Dicetemp),Guess):
- money = money + Bet
- print("You gained ", Bet,",you have ", money,"now")
-
- else:
- money = money-Bet
- print("You lose ",Bet,",you have ",money,"now")
- if money == 0:
- print('Game over')
- break
- funGameStarts(10000)
复制代码 |
|