Python_if条件_判断游戏里的大中小R_AB/奇偶测试选择玩家

这篇博客介绍了如何使用Python进行游戏中的条件判断,包括区分氪佬和非氪玩家、根据氪金量划分大中小R、结合玩家肝度的条件嵌套,以及AB/奇偶测试来选择玩家的策略。通过`if...else`和`random`函数实现各种逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主要语法

  1. if …… else
  2. if……elif……elif……else
  3. 条件嵌套,同等缩进为同一条件结构
  4. random函数

Case1 :氪佬和非氪

实现1 : if……else……判断
在这里插入图片描述
实现2 : 选择结构
在这里插入图片描述

Case2 :根据玩家氪金数量划分大中小R

在这里插入图片描述

Case3 :加入条件嵌套,在判断玩家氪度的同时判断玩家肝度

'''制定划分大中小R的标准,逐级判断是否符合条件,最后没有满足任何一个付费档位的就是免费玩家。 并且返回该玩家的充值金额
氪度分档标准:
大R:(647,+∞)
中R:(100,647]
小R:(6,100]
微氪:(0,6]
免费

肝度分档标准:日平均游戏时长
肝佬:3h+
休闲玩家:小于3h
'''
pay_amount = int(input('please input how much dolla have the user pay:'))
day_duration = int(input('please input how much hour have the user spend in our game:'))
if pay_amount >647:
    print(f'大R!The user have pay {pay_amount}$')
    if day_duration >=3 :
        print(f'And the user is a 肝佬, who daily use {day_duration} in our game')
    else :
        print(f'But the user is a 休闲佬, who daily use {day_duration} in our game')
elif pay_amount > 100 and pay_amount<= 647:
    print(f'中R!The user have pay {pay_amount}$') 
    if day_duration >=3 :
        print(f'And the user is a 肝佬, who daily use {day_duration} in our game')
    else :
        print(f'But the user is a 休闲佬, who daily use {day_duration} in our game')
elif pay_amount > 6 and pay_amount<= 100:
    print(f'小R!The user have pay {pay_amount}$') 
    if day_duration >=3 :
        print(f'And the user is a 肝佬, who daily use {day_duration} in our game')
    else :
        print(f'But the user is a 休闲佬, who daily use {day_duration} in our game')
elif pay_amount > 0 and pay_amount<= 6:
    print(f'微氪!The user have pay {pay_amount}$') 
    if day_duration >=3 :
        print(f'And the user is a 肝佬, who daily use {day_duration} in our game')
    else :
        print(f'But the user is a 休闲佬, who daily use {day_duration} in our game')
else:
    print('there is no pay in our game')
    if day_duration >=3 :
        print(f'But the user is a 肝佬, who daily use {day_duration} in our game')
    else :
        print(f'And the user is a 休闲佬, who daily use {day_duration} in our game')

在这里插入图片描述

Case4: AB/奇偶测试选择玩家

在这里插入图片描述
通过help函数查看randint函数,可以看到a,b范围是两个闭区间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值