欢迎光临散文网 会员登陆 & 注册

【Baldur's Gate 3】DND基础知识【走进博德之门3】

2023-07-24 10:18 作者:银白色_奇迹  | 我要投稿

import time

import random


"""

Y: Expected value

X: Dice count

DMAX: max value of Dice

"""

MAX_LOOP = 1000000

MODE = 1 # 0 use simple aglorithms


def calculate(X, DMAX):

Y = (DMAX - X ) / 2 + X

return Y


if MODE == 0:

dice_count = int(eval(input("请输入骰子数量: ")))

max_value = int(eval(input("请输入骰子面数: "))) * dice_count

expected_value = calculate(dice_count, max_value)


print("数学期望是:  ", expected_value)

time.sleep(5)

exit(0)


if MODE == 1:

aglo = input("print enter calculation aglorithms, such '2d6'\t")

aglo_list = aglo.split('d')

dice_count = int(aglo_list[0])

dice_max = int(aglo_list[-1])

print("你输入的骰子是{0}D{1}".format(dice_count, dice_max))

output = 0

for _ in range(MAX_LOOP):

once_roll = 0

for count in range(dice_count):

roll = random.randint(1,dice_max)

once_roll += roll

output += once_roll / MAX_LOOP

print("{0}次掷骰结果: {1}".format(MAX_LOOP, output))

time.sleep(5)

exit(0)

【Baldur's Gate 3】DND基础知识【走进博德之门3】的评论 (共 条)

分享到微博请遵守国家法律