// Package wuxing encodes the Wu Xing (五行) five-phase system. // // The five phases — Wood, Fire, Earth, Metal, Water — form two // directed cycles: // // Shēng (相生, generating): Wood → Fire → Earth → Metal → Water → Wood // Kè (相克, overcoming): Wood → Earth → Water → Fire → Metal → Wood // // Together these form a complete tournament graph on 5 nodes where // every pair has a directed relationship. The generating cycle is // the "mother-son" nourishing relationship; the overcoming cycle is // the "grandfather-grandson" controlling relationship. // // The quinary system (base 5, the third prime) completes the // mixed-radix state space: 2⁶ × 3⁴ × 5 = 64 × 81 × 5 = 25,920. package wuxing // Phase is one of the five phases. type Phase uint8 const ( Wood Phase = 0 // 木 mù — growth, expansion, spring Fire Phase = 1 // 火 huǒ — transformation, testing, summer Earth Phase = 2 // 土 tǔ — stabilization, centering, late summer Metal Phase = 3 // 金 jīn — refinement, contraction, autumn Water Phase = 4 // 水 shuǐ — dissolution, storage, winter ) // String returns the English name. func (p Phase) String() string { return [5]string{"Wood", "Fire", "Earth", "Metal", "Water"}[p] } // Chinese returns the Chinese character and pinyin. func (p Phase) Chinese() (character string, pinyin string) { chars := [5]string{"木", "火", "土", "金", "水"} pins := [5]string{"mù", "huǒ", "tǔ", "jīn", "shuǐ"} return chars[p], pins[p] } // Generates returns the phase this one generates (mother → son). // Wood→Fire, Fire→Earth, Earth→Metal, Metal→Water, Water→Wood. func (p Phase) Generates() Phase { return (p + 1) % 5 } // GeneratedBy returns the phase that generates this one (son ← mother). func (p Phase) GeneratedBy() Phase { return (p + 4) % 5 } // Overcomes returns the phase this one controls (grandfather → grandson). // Wood→Earth, Earth→Water, Water→Fire, Fire→Metal, Metal→Wood. func (p Phase) Overcomes() Phase { return (p + 2) % 5 } // OvercomeBy returns the phase that controls this one. func (p Phase) OvercomeBy() Phase { return (p + 3) % 5 } // Correspondence holds the associations of a phase across domains. type Correspondence struct { Phase Phase Character string // Chinese character Pinyin string // romanized pronunciation Direction string // cardinal direction Season string // seasonal association Color string // associated color YinOrgan string // zàng organ (solid) YangOrgan string // fǔ organ (hollow) Sense string // sense organ Taste string // flavor Emotion string // emotional correspondence Climate string // weather pattern Planet string // celestial body Creature string // heavenly creature } // Correspondences returns the full correspondence table for all five phases. func Correspondences() [5]Correspondence { return correspondences } var correspondences = [5]Correspondence{ { Phase: Wood, Character: "木", Pinyin: "mù", Direction: "East", Season: "Spring", Color: "Green", YinOrgan: "Liver", YangOrgan: "Gallbladder", Sense: "Eyes", Taste: "Sour", Emotion: "Anger", Climate: "Wind", Planet: "Jupiter", Creature: "Azure Dragon", }, { Phase: Fire, Character: "火", Pinyin: "huǒ", Direction: "South", Season: "Summer", Color: "Red", YinOrgan: "Heart", YangOrgan: "Small Intestine", Sense: "Tongue", Taste: "Bitter", Emotion: "Joy", Climate: "Heat", Planet: "Mars", Creature: "Vermilion Bird", }, { Phase: Earth, Character: "土", Pinyin: "tǔ", Direction: "Center", Season: "Late Summer", Color: "Yellow", YinOrgan: "Spleen", YangOrgan: "Stomach", Sense: "Mouth", Taste: "Sweet", Emotion: "Pensiveness", Climate: "Dampness", Planet: "Saturn", Creature: "Yellow Dragon", }, { Phase: Metal, Character: "金", Pinyin: "jīn", Direction: "West", Season: "Autumn", Color: "White", YinOrgan: "Lungs", YangOrgan: "Large Intestine", Sense: "Nose", Taste: "Pungent", Emotion: "Grief", Climate: "Dryness", Planet: "Venus", Creature: "White Tiger", }, { Phase: Water, Character: "水", Pinyin: "shuǐ", Direction: "North", Season: "Winter", Color: "Black", YinOrgan: "Kidneys", YangOrgan: "Bladder", Sense: "Ears", Taste: "Salty", Emotion: "Fear", Climate: "Cold", Planet: "Mercury", Creature: "Black Tortoise", }, } // Relation describes how two phases interact. type Relation uint8 const ( Self Relation = 0 // same phase Generating Relation = 1 // shēng: this generates other Generated Relation = 2 // shēng: other generates this Overcoming Relation = 3 // kè: this overcomes other Overcome Relation = 4 // kè: other overcomes this ) // Relate returns the relationship from phase a to phase b. func Relate(a, b Phase) Relation { if a == b { return Self } if a.Generates() == b { return Generating } if a.GeneratedBy() == b { return Generated } if a.Overcomes() == b { return Overcoming } return Overcome } // Lifecycle maps lattice operations to phases: // // Wood — growth: nucleation, topology expansion // Fire — testing: validation, trial execution // Earth — stabilization: integration, lock-in deepening // Metal — refinement: pruning, coherence strengthening // Water — dissolution: recycling, solution return // // The generating cycle (shēng) is the natural lifecycle: // // grow → test → stabilize → refine → dissolve → grow // // The overcoming cycle (kè) is the correction mechanism: // // growth corrects stagnation (Wood→Earth) // stabilization corrects chaos (Earth→Water) // dissolution corrects rigidity (Water→Fire) // testing corrects excess (Fire→Metal) // refinement corrects sprawl (Metal→Wood) type Lifecycle struct { Current Phase } // Next advances to the next phase in the generating (shēng) cycle. func (l *Lifecycle) Next() Phase { l.Current = l.Current.Generates() return l.Current } // Correct jumps to the phase this one overcomes (kè correction). func (l *Lifecycle) Correct() Phase { l.Current = l.Current.Overcomes() return l.Current } // FullState combines all three systems into one mixed-radix state. // Binary (I Ching): 0-63, Ternary (Tao): 0-80, Quinary (Wu Xing): 0-4. // Total state space: 64 × 81 × 5 = 25,920. type FullState struct { Hexagram uint8 // 0-63: I Ching binary state Position uint8 // 0-80: Tao Te Ching ternary position Phase Phase // 0-4: Wu Xing quinary phase } // Encode packs a FullState into a single uint16. // hexagram + 64*position + 64*81*phase func (fs FullState) Encode() uint16 { return uint16(fs.Hexagram) + uint16(fs.Position)*64 + uint16(fs.Phase)*64*81 } // DecodeFullState unpacks a uint16 into a FullState. func DecodeFullState(v uint16) FullState { hex := uint8(v % 64) v /= 64 pos := uint8(v % 81) v /= 81 phase := Phase(v % 5) return FullState{Hexagram: hex, Position: pos, Phase: phase} }