Runes and i ching robot, v0.2 , still building interpretation code for blog.
Output should include rune & i Ching, possibly a one line summary.
May merge in the tarot too?
import tkinter as tk
import random
from datetime import datetime
# Elder Futhark Runes with meanings
runes = [
(“Fehu”, “Wealth, prosperity”),
(“Uruz”, “Strength, health”),
(“Thurisaz”, “Conflict, protection”),
(“Ansuz”, “Communication, insight”),
(“Raidho”, “Journey, travel”),
(“Kenaz”, “Knowledge, creativity”),
(“Gebo”, “Gift, generosity”),
(“Wunjo”, “Joy, harmony”),
(“Hagalaz”, “Disruption, hail”),
(“Nauthiz”, “Need, resistance”),
(“Isa”, “Stillness, ice”),
(“Jera”, “Harvest, reward”),
(“Eihwaz”, “Endurance, transformation”),
(“Perthro”, “Mystery, fate”),
(“Algiz”, “Protection, higher self”),
(“Sowilo”, “Success, vitality”),
(“Tiwaz”, “Justice, leadership”),
(“Berkano”, “Birth, growth”),
(“Ehwaz”, “Movement, change”),
(“Mannaz”, “Humanity, cooperation”),
(“Laguz”, “Flow, intuition”),
(“Ingwaz”, “Fertility, potential”),
(“Dagaz”, “Breakthrough, awakening”),
(“Othala”, “Heritage, inheritance”)
]
# I Ching full 64 hexagrams
hexagrams = {
“111111”: (1, “Creative Force”),
“000000”: (2, “Receptive Earth”),
“100010”: (3, “Difficulty at the Beginning”),
“010001”: (4, “Youthful Folly”),
“111010”: (5, “Waiting”),
“010111”: (6, “Conflict”),
“010000”: (7, “The Army”),
“000010”: (8, “Holding Together”),
“111011”: (9, “Taming the Power of the Small”),
“110111”: (10, “Treading”),
“111000”: (11, “Peace”),
“000111”: (12, “Standstill”),
“101111”: (13, “Fellowship with Men”),
“111101”: (14, “Great Possession”),
“001000”: (15, “Modesty”),
“000100”: (16, “Enthusiasm”),
“100110”: (17, “Following”),
“011001”: (18, “Work on the Decayed”),
“110000”: (19, “Approach”),
“000011”: (20, “Contemplation”),
“100101”: (21, “Biting Through”),
“101001”: (22, “Grace”),
“000001”: (23, “Splitting Apart”),
“100000”: (24, “Return”),
“100111”: (25, “Innocence”),
“111001”: (26, “Great Taming”),
“100001”: (27, “Nourishment”),
“011110”: (28, “Great Exceeding”),
“010010”: (29, “Danger”),
“101101”: (30, “Clinging Fire”),
“001110”: (31, “Influence”),
“011100”: (32, “Endurance”),
“001111”: (33, “Retreat”),
“111100”: (34, “Great Power”),
“000101”: (35, “Progress”),
“101000”: (36, “Darkening of the Light”),
“101011”: (37, “Family”),
“110101”: (38, “Opposition”),
“001010”: (39, “Obstruction”),
“010100”: (40, “Deliverance”),
“110001”: (41, “Decrease”),
“100011”: (42, “Increase”),
“111110”: (43, “Breakthrough”),
“011111”: (44, “Coming to Meet”),
“000110”: (45, “Gathering Together”),
“011000”: (46, “Pushing Upward”),
“010110”: (47, “Oppression”),
“011010”: (48, “The Well”),
“101110”: (49, “Revolution”),
“011101”: (50, “The Cauldron”),
“100100”: (51, “The Arousing”),
“001001”: (52, “Keeping Still”),
“001011”: (53, “Gradual Progress”),
“110100”: (54, “Marrying Maiden”),
“101100”: (55, “Abundance”),
“001101”: (56, “The Wanderer”),
“011011”: (57, “Gentle Wind”),
“110110”: (58, “Joyous Lake”),
“010011”: (59, “Dispersion”),
“110010”: (60, “Limitation”),
“110011”: (61, “Inner Truth”),
“001100”: (62, “Small Exceeding”),
“101010”: (63, “After Completion”),
“010101”: (64, “Before Completion”)
}
def cast_runes():
non_reversing = {“Gebo”, “Hagalaz”, “Isa”, “Jera”, “Sowilo”, “Dagaz”, “Ingwaz”}
chosen = random.sample(runes, 3)
result = []
for name, meaning in chosen:
if name in non_reversing:
result.append((name, meaning))
else:
reversed_flag = random.choice([True, False])
if reversed_flag:
result.append((f”{name} (reversed)”, f”Blocked or inverted: {meaning}”))
else:
result.append((name, meaning))
return result
def cast_i_ching():
lines = []
binary = “”
for _ in range(6):
tosses = [random.choice([2, 3]) for _ in range(3)]
total = sum(tosses)
if total == 6:
lines.append(“Old Yin (6) – changing to Yang”)
binary = “0” + binary
elif total == 7:
lines.append(“Young Yang (7)”)
binary = “1” + binary
elif total == 8:
lines.append(“Young Yin (8)”)
binary = “0” + binary
elif total == 9:
lines.append(“Old Yang (9) – changing to Yin”)
binary = “1” + binary
hex_info = hexagrams.get(binary, (“?”, “Unknown Hexagram”))
return lines[::-1], hex_info
def days_since_birth():
return (datetime.today() – datetime(1969, 2, 2)).days
def cast_all():
rune_results = cast_runes()
i_ching_lines, (hex_num, hex_name) = cast_i_ching()
days = days_since_birth()
output_text = “Runes Drawn:\n”
for i, (name, meaning) in enumerate(rune_results, 1):
output_text += f” {i}. {name} – {meaning}\n”
output_text += “\nI Ching Hexagram (bottom to top):\n”
for line in i_ching_lines:
output_text += f” – {line}\n”
output_text += f”\nHexagram #{hex_num}: {hex_name}\n”
output_text += f”\nDays since Feb 2, 1969: {days} days”
output.delete(“1.0”, tk.END)
output.insert(tk.END, output_text)
cast_all.result_text = output_text
def share_result():
try:
root.clipboard_clear()
root.clipboard_append(cast_all.result_text)
root.update()
status_label.config(text=”Copied to clipboard!”)
except:
status_label.config(text=”Copy failed”)
# GUI setup (night mode)
root = tk.Tk()
root.title(“Runes & I Ching”)
root.configure(bg=”#1a1a1a”)
root.geometry(“380×640”)
title = tk.Label(root, text=”Rune & I Ching Caster”, font=(“Helvetica”, 16, “bold”), bg=”#1a1a1a”, fg=”white”)
title.pack(pady=10)
cast_button = tk.Button(root, text=”Cast Runes + I Ching”, command=cast_all, font=(“Helvetica”, 13),
bg=”#333″, fg=”white”)
cast_button.pack(pady=5)
share_button = tk.Button(root, text=”Share Results”, command=share_result, font=(“Helvetica”, 13),
bg=”#555″, fg=”white”)
share_button.pack(pady=5)
output = tk.Text(root, height=26, width=44, font=(“Courier”, 10), wrap=”word”,
bg=”#121212″, fg=”#dddddd”, insertbackground=”white”)
output.pack(padx=10, pady=10)
status_label = tk.Label(root, text=””, font=(“Helvetica”, 10), bg=”#1a1a1a”, fg=”#00cc99″)
status_label.pack()
cast_all.result_text = “”
root.mainloop()