猫史档案馆


【Python作品分享】A智猪博弈系统【作品秀】

用户:S_XS_X查看:0 回复:0 评论:0 创建时间:2020-03-22T12:23:27


【作品展示】

center_image

 

【作品介绍】

sx

 

【作品源代码】

# Object_Oriented_Programming_4
# 智猪博弈系统
import random

# 规则解读
print("你进行投骰子,选择投骰子或跳过本局,最后结算",
    "投得除1点以外的任何点数,本人点数加该点数,否则点数清零,你现在的点数是0")
print("Have a good time!")

# 基本信息
money_bits = 0  # 现有点数

# 主体部分
# 摇骰子函数
def Dice():
    Dice = [1, 2, 3, 4, 5, 6]
    x2 = Dice[random.randint(0, 5)]
    return x2

# 选择操作函数
def operation():
    print('''
    ''')
    print("选择你要进行的操作:")
    print("=" * 10)
    opt_list = ["A.继续本轮", "B.转到下轮", "C.结算"]
    for op in opt_list:
        print(op)
    print("=" * 10)
    opt = input("输入-->")
    return opt

while True:
    x1 = Dice()
    user_opt = operation()
    if user_opt == "A":
        print("你投得{}点".format(x1))
        if x1 == 1:
            print("你失去所有点数")
            money_bits = 0
            continue
        else:
            money_bits += x1
            print("你现在共有{}点数".format(money_bits))
    elif user_opt == "B":
        continue
    elif user_opt == "C":
        print('''
        ''')
        print("=======结算=======")
        print("你现在的点数是{}.".format(money_bits))
        break
    else:
        print("出错了,请再试一次")

print("Game over!")

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页