大家都知道,王者荣耀里的刺客赵云有被动免伤机制,但是玩的时候感受不明显,下面给大家看一个直观的数据
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
# 在我的 notebook 里,要设置下面两行才能显示中文
plt.rcParams['font.family'] = ['sans-serif']
blood = 1 # 初始满血量
blood_no_protect = 1 # 初始满血量
damage = 0.1 # 每次伤害量
total = 0
# 用于绘制图表
index = 0
has_protect = []
no_protect = []
while True:
protect = ((1 - blood) / 3) # 免伤率: 赵云受到3%伤害时,1%免伤,当前90%的血量,免伤为
real_damage = damage * (1 - protect) # 加入免伤率后的伤害
blood = blood - real_damage # 生命值递减
blood_no_protect = blood_no_protect - damage
has_protect.append(blood) # 统计免伤
if(blood_no_protect >0): # 统计未免伤
no_protect.append(blood_no_protect)
else:
no_protect.append(0)
total = total + damage # 统计等价生命值
index = index + 1
if blood < 0:
break
print("第%s次,遭受伤害 %.3f,当前生命值 %.3f" % (index ,real_damage,blood))
print("总的被动等价生命值 %s" % total)
t = np.linspace(0, 1, index)
plt.title('赵云被动生命值')
plt.ylabel('生命值')
plt.xlabel('时间')
plt.plot(t, has_protect, 'r', label='有被动免伤')
plt.plot(t, no_protect, 'b', label='没有被动免伤')
plt.legend()
plt.grid()
plt.show()
输出结果:
第1次,遭受伤害 0.100,当前生命值 0.900
第2次,遭受伤害 0.097,当前生命值 0.803
第3次,遭受伤害 0.093,当前生命值 0.710
第4次,遭受伤害 0.090,当前生命值 0.620
第5次,遭受伤害 0.087,当前生命值 0.532
第6次,遭受伤害 0.084,当前生命值 0.448
第7次,遭受伤害 0.082,当前生命值 0.366
第8次,遭受伤害 0.079,当前生命值 0.287
第9次,遭受伤害 0.076,当前生命值 0.211
第10次,遭受伤害 0.074,当前生命值 0.137
第11次,遭受伤害 0.071,当前生命值 0.066
总的被动等价生命值 1.2
这里可以看出随时时间推移,赵云的被动免伤会逐渐提高,没有免伤的情况下,到了0.8 的时间就已经嗝屁了,有免伤还可以再支撑一下,相当于原血量的 120%