: == x ==" = 1/8 # (young/stable/static) yang "7 : =======" = 3/8 # (young/stable/static) yin "8 : == ==" = 3/8 # old/changing/moving yang "9 : == o ==" = 1/8 # # 3-coins Probabilities: # old/changing/moving yin "6 : === x ===" = 1/8 # (young/stable/static) yang "7 : =========" = 3/8 # (young/stable/static) yin "8 : === ===" = 3/8 # old/changing/moving yang "9 : ====o====" = 1/8 # # Modified 3-coins Probabilities: # old/changing/moving yin "6 : === x ===" = 1/8 * 1/2 = 1/16 # (young/stable/static) yang "7 : =========" = 3/8 - 1/8*1/2 = 5/16 # (young/stable/static) yin "8 : === ===" = 3/8 - P[6] = 7/16 # old/changing/moving yang "9 : ====o====" = 1/8 - p[7] = 3/16 # see # https://aleadeum.com/2013/07/12/the-i-ching-random-numbers-and-why-you-are-doing-it-wrong/ # especially see the remark why 1st round are 1/4-3/4 whilst 2nd and 3rd round are 1/2-1/2 import random def toss(method: str = "yarrow") -> int: """Toss.""" rng = random.SystemRandom() # Auto-seeded, with os.urandom() special_coin = 0 val = 0 for flip in range(3): # Three simulated coin flips i.e. coin 0, 1, 2 val += rng.randint(2, 3) # tail=2, head=3 for each coin if flip == 0: special_coin = val # Coin 0 as the special coin if method == "coin": # Coin method note tth or 223 is 7 or young yang return val # Probability of 6/7/8/9 is 1/8 3/8 3/8 1/8 elif method == "modified 3 coins": # method similar to "yarrow-stick" need to have prob. # for 6/7/8/9 as 1/16 5/16 7/16 3/16 # now coin method is # for 6/7/8/9 as 2/16 6/16 6/16 2/16 # modified to change # -1/16 -1/16 +1/16 + 1/16 # 6 7 8 9 if (val == 6) and (special_coin == 2): special_coin = rng.randint(2, 3) if special_coin == 2: val = 6 else: val = 8 elif (val == 7) and (special_coin == 3): special_coin = rng.randint(2, 3) if (special_coin == 3): val = 7 else: val = 9 return val # probability of 6/7/8/9 is 1/16 5/16 7/16 3/16 else: # yarrow-stick method as effectively default # start_sticks, sky-left, sky-reminder, human, earth-right, earth-reminder, bin # value-> 49 0 0 0 0 0 0 # index-> 0 1 2 3 4 5 6 # on table: # heaven # heaven-left human earth-right # earth # # sometimes use finger to hold above def printys(ys, remark):