用户:
12345lcy查看:0 回复:0 评论:0 创建时间:2021-07-21T10:56:17
【作品展示】

【作品介绍】
各位大佬,你好!如有报错或bug,请马上告诉我!
祝大家暑假快乐!
【作品源代码】
import turtle
import random
print('你好,训练师!欢迎来到斗兽牌')
t = turtle.Pen()
r = turtle.Screen()
t.hideturtle()
#进度
t.penup()
t.goto(-100, 0)
t.pendown()
t.pencolor('blue')
t.pensize(40)
t.forward(300)
t.pencolor('yellow')
t.pensize(40 - 10)
t.backward(300)
# 规则说明
print('规则说明')
print('老鼠克大象,猫克老鼠,狗克猫:狼克狗,虎克狼,狮子克虎,大象克狮子', '')
print('除开老鼠,大象都可以克,除开大象,狮子都可以克。。。。一直推下去')
print('和上上面一样,动物编号:1,2,3,4,5,6,7 克的不算')
print('一共30回合')
print('比赛开始')
for i in range(30):#回合
#玩家输入
print("-----------------------------------------")
shu_ru = int(turtle.textinput('请输入动物号:', '只能输入已有的动物编号'))
if shu_ru ==1:
print('玩家输入的是:老鼠')
elif shu_ru ==2:
print('玩家输入的是:猫')
elif shu_ru ==3:
print('玩家输入的是:狗')
elif shu_ru ==4:
print('玩家输入的是:狼')
elif shu_ru ==5:
print('玩家输入的是:虎')
elif shu_ru ==6:
print('玩家输入的是:狮子')
elif shu_ru ==7:
print('玩家输入的是:大象')
else:
print("你输入有误,不能重新")
#电脑输入
cop_num = random.randint(1,7)
if cop_num == 1:
print('电脑输入的是:老鼠')
elif cop_num == 2:
print('电脑输入的是:猫')
elif cop_num == 3:
print('电脑输入的是:狗')
elif cop_num == 4:
print('电脑输入的是:狼')
elif cop_num == 5:
print('电脑输入的是:虎')
elif cop_num == 6:
print('电脑输入的是:狮子')
else:
print('电脑输入的是:大象')
#判断功能
if shu_ru == 1 and cop_num == 7 or shu_ru == 2 and cop_num == 1 or shu_ru == 3 and cop_num == 2 or shu_ru == 4 and cop_num == 3 or shu_ru == 5 and cop_num == 4 or shu_ru == 6 and cop_num == 5 or shu_ru == 7 and cop_num == 6 or shu_ru == 3 and cop_num = 2 or shu_ru == 3 and cop_num == 1 or shu_ru == 4 and cop_num == 1 or shu_ru == 4 and cop_num == 2 or shu_ru == 4 and cop_num == 3 or shu_ru == 5 and cop_num == 1 or shu_ru == 5 and cop_num == 2 or shu_ru == 5 and cop_num == 3 or shu_ru == 5 and cop_num == 4 or shu_ru == 6 and cop_num == 1 or shu_ru == 6 and cop_num == 2 or shu_ru == 6 and cop_num == 3 or shu_ru == 6 and cop_num = 4 or shu_ru == 6 and cop_num == 5 or shu_ru == 7 and cop_com == 2 or shu_ru == 7 and cop_com == 3 or shu_ru == 7 and cop_com == 4 or shu_ru == 7 and cop_com == 5 or shu_ru == 7 and cop_com == 6:
print("这局玩家胜")
t.pencolor("tan1")
t.forward(300/10)
elif shu_ru == 7 and cop_num == 1 or shu_ru == 1 and cop_num == 2 or shu_ru == 2 and cop_num == 3 or shu_ru == 3 and cop_num == 4 or shu_ru == 4 and cop_num == 5 or shu_ru == 5 and cop_num == 6 or shu_ru == 6 and cop_num == 7 or shu_ru == 2 and cop_num = 3 or shu_ru == 1 and cop_num == 3 or shu_ru == 1 and cop_num == 4 or shu_ru == 2 and cop_num == 4 or shu_ru == 3 and cop_num == 4 or shu_ru == 1 and cop_num == 5 or shu_ru == 2 and cop_num == 5 or shu_ru == 3 and cop_num == 5 or shu_ru == 4 and cop_num == 5 or shu_ru == 1 and cop_num == 6 or shu_ru == 2 and cop_num == 6 or shu_ru == 3 and cop_num == 6 or shu_ru == 4 and cop_num = 6 or shu_ru == 5 and cop_num == 6 or shu_ru == 2 and cop_com == 7 or shu_ru == 3 and cop_com == 7 or shu_ru == 4 and cop_com == 7 or shu_ru == 5 and cop_com == 7 or shu_ru == 6 and cop_com == 7:
print("这局电脑胜")
t.pencolor("red")
t.forward(300/10)
print("-------------------------")
else:
print("这局平局")
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn