uranus0516 commited on
Commit
ca4e543
1 Parent(s): 86e10b0

Create poke.py

Browse files
Files changed (1) hide show
  1. poke.py +49 -0
poke.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import gradio as gr
3
+ def poke(player1,player2):
4
+ poke=['A','2','3','4','5','6','7','8','9','10','J','Q','K']
5
+ #print("请玩家1按回车键抽牌")
6
+ if player1!=" ":
7
+ a1=random.randint(0, 12)
8
+ #return poke[a1]
9
+ b1=random.randint(0, 12)
10
+ #return poke[b1]
11
+ c1=random.randint(0, 12)
12
+ #return poke[c1]
13
+ list1 = [a1,b1,c1]
14
+ #print("请玩家2按回车键抽牌")
15
+ if player2!=" ":
16
+ a2=random.randint(0, 12)
17
+ #return poke[a2]
18
+ b2=random.randint(0, 12)
19
+ #return poke[b2]
20
+ c2=random.randint(0, 12)
21
+ #return poke[c2]
22
+ list2 = [a2,b2,c2]
23
+ if a1==b1==c1 :
24
+ return poke[a1],poke[b1],poke[c1],"\n",poke[a2],poke[b2],poke[c2],"\n",f"玩家1赢了"
25
+ elif a2==b2==c2 :
26
+ return poke[a1],poke[b1],poke[c1],"\n",poke[a2],poke[b2],poke[c2],"\n",f"玩家2赢了"
27
+ elif (a1==b1!=c1) or (a1==c1!=b1) or (b1==c1!=a1) and (a2!=b2!=c2) :
28
+ return poke[a1],poke[b1],poke[c1],"\n",poke[a2],poke[b2],poke[c2],"\n",f"玩家1赢了"
29
+ elif (a2==b2!=c2) or (a2==c2!=b2) or (b2==c2!=a2) and (a1!=b1!=c1) :
30
+ return poke[a1],poke[b1],poke[c1],"\n",poke[a2],poke[b2],poke[c2],"\n",f"玩家2赢了"
31
+ elif max(list1) >max(list2) :
32
+ return poke[a1],poke[b1],poke[c1],"\n",poke[a2],poke[b2],poke[c2],"\n",f"玩家1赢了"
33
+ elif max(list2) >max(list1) :
34
+ return poke[a1],poke[b1],poke[c1],"\n",poke[a2],poke[b2],poke[c2],"\n",f"玩家2赢了"
35
+ demo=gr.Interface(
36
+ fn=poke,
37
+ inputs=[
38
+ gr.Textbox(
39
+ label="玩家一",
40
+ lines=1,),
41
+ gr.Textbox(
42
+ label="玩家二",
43
+ lines=1,),
44
+ ],
45
+ outputs=[gr.Textbox(
46
+ label="结果",
47
+ lines=7,)
48
+ ])
49
+ demo.launch()