Python数字炸弹游戏

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
_icon=""" _______
|4855544|
|8545212|---~~/ numberbool
|_______|
"""
from random import randint
#print(_lzhicon)
print(_icon)
DEBUG=False
def prin(a):
    if DEBUG:
        print("[DEBUG]",a)
player=int(input("请输入玩家数量>"))
max=100
min=0
# randnumber=randint(min,max)
randnumber=19
prin("randnumber:"+str(randnumber))
def caishu(i,min,max):
    print("最大上限",max,",最小下限",min)
    try:
        temp=int(input("玩家"+str(i)+"猜1个数字>"))
    except ValueError as e:
        prin(str(e))
        print("输入的不是数字")
        c,min,max=caishu(i,min,max)
        return [c,min,max]
    if temp>=min and temp<=max:
        if temp==randnumber:
            print("玩家",i,"出局")
            return [-1,min,max]
        else:
            if temp<randnumber:
                print("小了")
                min=temp
            else:
                print("大了")
                max=temp
    else:
        print("数不在范围内,重新输入")
        c,min,max=caishu(i,min,max)
        return [c,min,max]
    print()
    return [0,min,max]
c=0
while True:
    for i in range(1,player+1):
        c,min,max=caishu(i,min,max)
        if c!=0:
            break
    if c!=0:
        break
while True:pass