Show HN: I Ching simulator with accurate Yarrow Stalk probabilities (castiching.com)
Technical detail for the curious:
The simulation follows the traditional Yarrow Stalk algorithm (Da Yan). The core of this algorithm relies on modulo-4 arithmetic on the stalks remaining after a random split.
To make it physically realistic, I used a Box-Muller transform to simulate the user splitting the stalks with a Gaussian distribution (since humans naturally tend to split near the middle), rather than a uniform random split.
I was worried this 'human bias' might skew the modulo probabilities, so I ran a 1-million-run Monte Carlo simulation to verify.
The Result: The remainders [0,1,2,3] still emerged with a near-perfect 25% distribution (deviation < 0.05%).
So, the app simulates the physics of human imperfection while preserving the mathematical perfection of the probability distribution (where Old Yin is 1/16).
Stack: Next.js + Tailwind css
Happy to answer any questions about the math or the hexagrams!
29 comments
[ 4.1 ms ] story [ 49.7 ms ] threadTo be honest, I haven't added it because I'm hesitating. I planned to use AI to generate the interpretations, but I'm not sure if that's a good idea.
I feel like letting AI explain the I Ching might kill the 'traditional vibe'.
I'm still deciding: should I use AI, or just use the classic book text? What do you think?
https://www.urbandictionary.com/define.php?term=A+Suffusion+...
I probably stared at it for too long on my own monitor and got used to it. I will bump up the contrast in the next update to ensure it's readable for everyone.
I guess it's a question of philosophy, either split into groups based off of your intuition, or aim for a truly random split in the pile.
Anyway, I wasn't sure if this is something that's a settled matter or what.
You are right that humans don't split perfectly randomly (Uniform Distribution). We tend to aim for the middle but miss slightly.
In my code, I modeled this 'human splitting action' using a Gaussian (Normal) distribution centered at 50% of the pile, with a standard deviation. This simulates the user trying to split the stalks roughly in half, rather than just picking a random number from 0 to 49.
Interestingly, my Monte Carlo simulations showed that even with this human bias (splitting near the middle), the final modulo-4 probabilities remain stable. So the algorithm is robust even against our 'imperfect' hands.
Have you built a web app or a mobile app? I'd love to check out your work if you have a link!
https://neoching.com
It got tiring and boring to click and click and click with the mouse with no explanation for how it works
Original Hexagram 45. GATHERING TOGETHER (MASSING) (Ts'ui)
Transformed Hexagram 17. FOLLOWING (Sui)
Ok.
My interpretation for your power supply:
Gathering (45): You need to gather some capacitors? (or maybe a heat sink for the 'massing'?)
Following (17): Clearly it's telling you to use a Voltage Follower. :D
To be honest, my reason for picking this method was simple: I was reading a book about the I Ching that described the different ways to cast hexagrams.
The Yarrow Stalk method stood out to me because it felt more mysterious—in the past, it seemed like a secret method known only by a few experts.
Also, from a coding perspective, this algorithm was just much more interesting to build than a simple coin toss!
A fundamental part of I Ching reading is the implication that each present state is in the process of transforming to another.
I spent the last 24 hours implementing the feedback from this thread. Thank you all for the harsh (but fair) critique.
1. Ditched AI for the Classics Many of you pointed out that AI interpretations felt "soulless" or risky. I agreed.
Now: The app directly displays the canonical Richard Wilhelm / Cary Baynes translation (Foreword by Carl Jung) for the Primary Hexagram, Moving Lines, and the Relating Hexagram. It's mathematically precise and respects the source material.
2. No More Lost Readings (Persistence) @jmkd mentioned losing a reading on refresh.
Fix: The latest reading is now auto-saved to Local Storage.
Privacy: Still no login required. Your data stays in your browser.
3. Shareable "Result Cards" Since the hexagrams look so cool, I added a feature to generate a downloadable image card. It captures the visual pattern and the key judgment text.
Give it another spin and let me know if the "Moving Lines" logic feels right to you now!
_____ (black bar, 7)
_____ (black bar, 7)
__.__ (grey bar, marked by green dot in the middle, 9)
__ __ (two short black bars with gap in the middle, 8)
__.__ (grey bar, marked by green dot in the middle, 9)
__ __ (two short black bars with gap in the middle, 8)
Primary Hexagram 6. CONFLICT (Sung)
Relating Hexagram 20. CONTEMPLATION (Kuan)
Reverse engineer the question :->