# String format example: f"Result: {value:{width}.{precision}}" width = 3 print(f'[{ys[0]}, \t{ys[1]}, \t{ys[2]}, \t{ys[3]}, \t{ys[4]}, \t{ys[5]}, \t{ys[6]}] \t{remark}') return def ys_round(ys, round, debug="no"): if debug == "yes": print("Round is", round) if debug == "yes": print("===============") if debug == "yes": print(f'[{"src"}, \t{"sky"}, \t{"left"}, \t{"human"}, \t{"earth"}, \t{"right"}, \t{"bin"}] \t{"remark"}') # Generate a number somewhere in between 1/3 to 2/3 as human do not trick if debug == "yes": printys(ys, "Starting") ys[1] = rng.randint(ys[0] // 3, ys[0] * 2 // 3) ys[4] = ys[0] - ys[1] ys[0] = ys[0] - ys[1] - ys[4] if debug == "yes": printys(ys, "Separate into two") ys[3] = 1 ys[1] = ys[1] - ys[3] if debug == "yes": printys(ys, "and with one as human") ys[2] = ys[1] % 4 if ys[2] == 0: ys[2] = 4 ys[1] = ys[1] - ys[2] if debug == "yes": printys(ys, "then 4 by 4 and sky behind ...") ys[5] = ys[4] % 4 if ys[5] == 0: ys[5] = 4 ys[4] = ys[4] - ys[5] if debug == "yes": printys(ys, "then 4 by 4 and earth behind ...") ys[6] += ys[2] + ys[3] + ys[5] ys[2] = 0 ys[3] = 0 ys[5] = 0 ys[0] = ys[1] + ys[4] ys[1] = 0 ys[4] = 0 if debug == "yes": printys(ys, "complete the cycle ...") return ys ys = [0, 0, 0, 0, 0, 0, 0] # May be better use dictionary ys[0] = 55 # printys(ys, "The number of heaven and earth is 55") ys[0] = 49 # printys(ys, "only 49 is used") # Round 1 need to ensure mod 4 cannot return 0 and cannot have 0 # wiki said cannot have 1 as well not sure about that ys = ys_round(ys, 1, "no") # "yes") ys = ys_round(ys, 2, "no") # "yes") ys = ys_round(ys, 3, "no") # "yes") return ys[0] // 4 # We build in bottom to top print("Method is yarrow by default\n") toss_array = [0, 0, 0, 0, 0, 0] for line in range(0, 6, 1): toss_array[line] = toss() print("Line is ", line + 1, "; toss is ", toss_array[line], "\n") # Hence we print in reverse def print_lines_in_reverse(toss_array): for line in range(5, -1, -1): val = toss_array[line] # The changing line/hexagram need another program if val == 6: print('6 : == x ==')# || == == > -------') elif val == 7: print('7 : -------')# || ------- > -------') elif val == 8: print('8 : == ==')#