Anygua CAST FROM ANYTHING
Anygua/The Math
Reproducible · auditable

The Math of Casting

How a three-thousand-year-old number-drawing tradition becomes a procedure you can read, reproduce, and inspect.

CHAPTER 00

Every hexagram is the same data structure.

Whether the input is coins, yarrow stalks, time, or a digest, Anygua reduces the result to six line positions. Each position can only be one of four states: 6, 7, 8, or 9.

line in { 6 old-yin, 7 young-yang, 8 young-yin, 9 old-yang }
7 / 8 are static lines
6 / 9 are moving lines that flip into their opposite

-> six lines bottom-to-top determine the primary hexagram
-> moving positions determine the changed hexagram
CHAPTER 01

Three coins: a simple binomial distribution.

Three coins, heads and tails counted as 3 or 2. The sum is exactly one of 6, 7, 8, or 9. Each line is independent; toss six times.

Classic

Procedure

heads = 3, tails = 2
sum of three coins in { 6, 7, 8, 9 }
-> P(6)=1/8, P(7)=3/8, P(8)=3/8, P(9)=1/8

Distribution

6 old-yin1/80.125
7 young-yang3/80.375
8 young-yin3/80.375
9 old-yang1/80.125
CHAPTER 02

Yarrow stalk: the asymmetric classical distribution.

Fifty stalks, one set aside, leaving forty-nine. Divide, hang one, count by fours, gather the remainder. Three variations make one line; eighteen make a hexagram. The distribution is not the same as the coin method.

Classic

Procedure

49 -> divide -> hang one -> count by fours -> gather
three variations make one line; eighteen make a hexagram
-> P(6)=1/16, P(7)=5/16, P(8)=7/16, P(9)=3/16

Distribution

6 old-yin1/160.0625
7 young-yang5/160.3125
8 young-yin7/160.4375
9 old-yang3/160.1875
CHAPTER 03

Plum blossom: number drawing as modular arithmetic.

Shao Yong's move was to rewrite casting as deterministic arithmetic. Any integer can enter the system. Time is just integers too.

From time

upper = (year_branch + month + day) mod 8
lower = (upper_sum + hour) mod 8
moving = (year_branch + month + day + hour) mod 6

From two numbers

upper = A mod 8
lower = B mod 8
moving = (A + B) mod 6
CHAPTER 04

From anything: inputs become stable bytes first.

Text, verse, audio, and images all work if they can be turned into stable bytes. Anygua then runs one SHA-256 digest pipeline.

01

Input

text / verse / audio / image

02

Bytes

UTF-8 text / raw file bytes

03

Digest

SHA-256 -> 32 bytes

04

Draw

digest bytes -> six bands

05

Lookup

binary -> 64 hexagrams

The same modern input always returns the same hexagram. Text and verse use the parity of the first 6 digest bytes plus the 7th byte for the moving line; audio and image files use six digest-band means against their median, with the largest deviation marking the moving line.

CHAPTER 05

Where does randomness come from?

Traditional: cryptographic randomness

Coin tosses and yarrow divisions call Ruby SecureRandom, backed by the operating system.

coin = SecureRandom.random_number(2)

Modern: fully deterministic

Modern methods add no randomness. Same bytes means same digest, and the same digest means the same hexagram.

same bytes -> same SHA-256 -> same hexagram
CHAPTER 06

What can it calculate, and what can it not calculate?

It can calculate that two identical modern inputs return the same hexagram. It can calculate that young-yin appears with probability 7/16 in the yarrow method.

It cannot calculate whether you will get a raise next year, because there is no causal chain between a probability distribution and your paycheck. Anygua makes the math reproducible; the cultural reading remains yours.

Add Anygua to your home screen for instant casting anywhere.