def show_array(argv, p): tmp = 0 res = 0 i = 1 last = 0 Ox = [] Tx = [] print(f"{'x':>4}\t|", end = " ") while i < 9: if (i == 1): print(" %d" %(i - 1), end = "") elif (tmp == 0 and (int(argv[i - 1]) != 0)): print("%d" %(i - 1), end = "") last = i - 1 tmp += int(argv[i]) res += 100 * op.combination(i - 1, 100) * np.power(p, i - 1) * np.power((1 - p), 100 - (i - 1)) if (tmp >= 10 and (int(argv[i + 1]) >= 10)): if (tmp != int(argv[i]) or int(argv[i - 1] == 0)): print("-%d" %(i - 1), end = "") last = i - 1 print("\t|", end = " ") Ox.append(tmp) Tx.append(res) res = 0 tmp = 0 i += 1 if (tmp != 0): print("\t|", end = " ") Ox.append(tmp - int(argv[i - 1])) res -= 100 * op.combination(i - 2, 100) * np.power(p, i - 2) * np.power((1 - p), 100 - (i - 2)) Tx.append(res) print("%d+\t| Total" %(last + 1)) tmp = 0 print(f"{'Ox':>4}\t|", end = " ") for O in Ox: print(" %d\t|" %O, end = "") for i in range(last + 1, 9): tmp += int(argv[i + 1]) print(" %d\t| 100" %tmp) Ox.append(tmp) tmp = 0 print(f"{'Tx':>4}\t|", end = " ") for T in Tx: print(" %.1f\t|" %T, end = "") tmp += T print(" %.1f\t| 100" %(100 - tmp)) Tx.append(100 - tmp) return (Ox, Tx)
def yams(dice, A): die = 5 need = 5 for elem in dice: if (elem == A): die -= 1 need -= 1 if (need <= 0): return 1 return ((op.combination(need, die) * (op.prob**die)))
def full(dice, A, B): reroll = 5 cptA = 0 cptB = 0 for elem in dice: if (elem == A and cptA < 3): reroll -= 1 cptA += 1 if (elem == B and cptB < 2): reroll -= 1 cptB += 1 return (op.combination((2 - cptB), reroll) / (op.val**reroll))
def pair(dice, A): die = 5 need = 2 for elem in dice: if (elem == A): die -= 1 need -= 1 if (need <= 0): return 1 return ((op.combination(need, die) * (op.prob**need) * ((1 - op.prob)**(die - need))) + three(dice, A))
def four(dice, A): die = 5 need = 4 for elem in dice: if (elem == A): die -= 1 need -= 1 if (need <= 0): return 1 return ((op.combination(need, die) * (op.prob**need) * ((1 - op.prob)**(die - need))) + yams(dice, A))