A Web of Relationships --- Five Elements, Ten Gods, and Combinations in Code
The real complexity of Four Pillars of Destiny (Saju) lies not in the 22 characters themselves but in the "relationships" between them. The generating and overcoming cycles of the Five Elements (Oheng, 五行), the 10 classifications of the Ten Gods (Sipsin, 十神), and the dozens of combinations in Combinations, Clashes, and Punishments (合沖刑破害). Translating this web of relationships into code was the most challenging --- and the most fascinating --- part of the project.
Five Elements: Two Implementation Approaches
The generating and overcoming cycles of the Five Elements are the most fundamental axis of Saju analysis. Wood generates Fire, Fire generates Earth, Earth generates Metal, Metal generates Water, Water generates Wood. For overcoming: Wood overcomes Earth, Earth overcomes Water, Water overcomes Fire, Fire overcomes Metal, Metal overcomes Wood.
There are broadly two ways to implement these relationships in code.
The first is a mapping table approach. You explicitly write "Wood generates Fire" as a table entry. It is explicit and easy to read. The domain relationships are immediately visible in the code. Modifications and verification are straightforward.
The second is an index arithmetic approach. Index the Elements as Wood (0), Fire (1), Earth (2), Metal (3), Water (4). The generating relationship is (current + 1) % 5, and the overcoming relationship is (current + 2) % 5. It is concise and mathematically elegant --- the cyclic structure of the Five Elements expressed through modular arithmetic.
Both approaches have merits, so I kept both in the project. Mapping tables serve data reference and verification; index arithmetic handles runtime calculations. It may look like duplication, but each serves a distinct purpose.
The mapping table is used when you need to ask "Is this relationship correct?" --- in code reviews, tests, and debugging, you can glance at the table and confirm immediately. Index arithmetic is used inside the analysis engine when fast determination is needed. As long as tests verify that both methods always produce identical results, either can be safely used.
Ten Gods: 10 Relationships Based on the Day Stem
The Ten Gods (Sipsin, 十神) is one of the most important analytical frameworks in Saju interpretation. It classifies the relationship between the Day Stem (the Stem of the Day Pillar, representing "the self") and each of the other seven characters.
The basic principle works like this. First, determine the Element relationship between the Day Stem and the other character. Same Element means Companion. The Element I generate means Output. The Element that generates me means Resource. The Element I overcome means Wealth. The Element that overcomes me means Authority. That gives five basic relationship types.
Then Yin-Yang polarity is layered on. Within the same relationship type, matching polarity yields "Indirect" while opposing polarity yields "Direct." Companion splits into Rob Wealth and Friend. Output splits into Eating God and Hurting Officer. Resource splits into Indirect Seal and Direct Seal. Wealth splits into Indirect Wealth and Direct Wealth. Authority splits into Seven Killings and Direct Officer. Five base types expand to ten --- hence "Ten Gods."
The implementation challenge is that this classification changes entirely depending on who the Day Stem is. When the Day Stem is Gap (甲, Yang Wood) versus Jeong (丁, Yin Fire), the same Gyeong (庚, Yang Metal) produces a different Ten Gods result. Gap sees Gyeong as Seven Killings, but Jeong sees Gyeong as Direct Wealth. With 10 possible Day Stems and 10 possible counterparts (among Stems alone), that is 100 Ten Gods mappings.
Building all 100 manually is inefficient. Instead, combining the Five Elements generating/overcoming logic with Yin-Yang polarity logic automatically determines the Ten Gods. Rule-based computation beats a mapping table here for maintainability.
Combinations, Clashes, and Punishments: The Explosion of Relationships
Combinations, Clashes, Punishments, Destructions, and Harms (合沖刑破害) is the system in Saju that deals with special interactions between characters. Coding this system was the most data-intensive task in the entire project.
Start with Stem Combinations. There are 5 pairs among the Heavenly Stems: Gap-Gi, Eul-Gyeong, Byeong-Sin, Jeong-Im, Mu-Gye. Each pair transforms into a specific Element. Gap and Gi combine into Earth; Eul and Gyeong combine into Metal.
Branch interactions are far more complex. Three Harmonies (三合) come in 4 sets: In-O-Sul (寅午戌) form Fire, Sa-Yu-Chuk (巳酉丑) form Metal, Sin-Ja-Jin (申子辰) form Water, Hae-Myo-Mi (亥卯未) form Wood. Directional Combinations (方合) also come in 4 sets: In-Myo-Jin (寅卯辰) form Eastern Wood, Sa-O-Mi (巳午未) form Southern Fire, Sin-Yu-Sul (申酉戌) form Western Metal, Hae-Ja-Chuk (亥子丑) form Northern Water.
Six Harmonies (六合) are 6 pairs: Ja-Chuk, In-Hae, Myo-Sul, Jin-Yu, Sa-Sin, O-Mi. Each harmony transforms into a specific Element.
Six Clashes (六沖) are also 6 pairs: Ja-O, Chuk-Mi, In-Sin, Myo-Yu, Jin-Sul, Sa-Hae.
Punishments (刑) come in 3 types: the Punishment of Ingratitude (In-Sa-Sin), the Punishment of Incivility (Chuk-Sul-Mi), and Self-Punishment (Jin-Jin, O-O, Yu-Yu, Hae-Hae).
Destructions (破) and Harms (害) each have several additional pairs.
Listing every combination yields substantial volume. 5 Stem Combinations, 4 Three Harmony sets, 4 Directional Combination sets, 6 Six Harmony pairs, 6 Six Clash pairs, 3 Punishment types, 6 Destruction pairs, 6 Harm pairs. Include associated attributes (transformed Element, conditions for activation, etc.) and the data footprint is not trivial.
AI Generating Massive Data Tables in One Pass
The moment I most dramatically felt AI's strength during this project was when I asked Claude to generate all Combinations, Clashes, and Punishments data as code --- and it produced an accurate, complete data table in a single response.
All 5 Stem Combinations with their resulting Elements. All 4 Three Harmony sets with their resulting Elements, distinguished by peak/birth/storage positions. All 4 Directional Combinations with Elements. All 6 Six Harmony pairs with resulting Elements. All 6 Six Clash pairs. All 3 Punishment types with their corresponding Branch combinations. Everything in one response.
What if I had typed it all manually? I would have had reference materials open, entered one pair at a time, and checked for typos. Chinese characters are inconvenient to type, and similar-looking characters are easy to confuse: In (寅) and Myo (卯), Jin (辰) and Sa (巳), Yu (酉) and Sul (戌). A single wrong character throws off the analysis.
The accuracy of AI-generated data was remarkable. Cross-referencing against the design document revealed almost no errors. Because the Combinations and Clashes data of Saju is a well-established academic system, AI's training data likely contains highly accurate information.
"Almost no errors" is not "zero errors," of course. Verification was absolutely necessary, and a couple of spots did require corrections. But compared to typing everything from scratch, the "AI generates + human verifies" workflow was vastly superior in both time and accuracy.
The Twelve Life Stages and the Yin Stem Forward/Reverse Debate
The Twelve Life Stages is a system that maps the energy lifecycle of an Element through 12 phases: Birth, Bathing, Capping, Success, Peak, Decline, Sickness, Death, Burial, Severance, Conception, Nurturing.
Implementation is a mapping table: for each Heavenly Stem, map which Life Stage it occupies in each of the 12 Earthly Branches. But here I hit the project's second school divergence: the Yin Stem forward vs. reverse debate.
Yang Stems (Gap, Byeong, Mu, Gyeong, Im) are uncontested. Everyone agrees that Gap starts at Birth in In (寅), moves to Bathing in Myo (卯), and proceeds forward.
The debate is about Yin Stems (Eul, Jeong, Gi, Sin, Gye). One school says Yin Stems run in reverse --- if Yang Stems go clockwise through the 12 stages, Yin Stems go counterclockwise. The other school says Yin Stems also proceed forward.
When I asked AI about this debate, the answer was: "The majority of modern Saju practice applies the reverse for Yin Stems." But a caveat is needed here. "Majority" does not necessarily mean "correct." It is a school's choice.
I applied the Part 2 design principle here as well. The default follows the modern majority --- Yin Stems reverse --- but a setting allows switching to forward. AI's input was referenced, but the final design decision preserved flexibility.
The Layered Structure of Relationships
After implementing all Combinations, Clashes, and Punishments, stepping back revealed that these relationships form a layered structure.
The most fundamental layer is Five Elements generating and overcoming. What is the Element relationship between two characters?
Above that sits the Ten Gods layer. Combining Element relationship and Yin-Yang polarity relative to the Day Stem yields 10 classifications.
Then comes the Combinations/Clashes/Punishments layer. Special interactions produced by specific character combinations.
The Twelve Life Stages form a separate axis --- they evaluate the energy state of an Element, making them more about "status" than "relationship."
This layered structure was reflected in the code architecture. The Five Elements analysis module sits beneath the Ten Gods analysis module, which sits alongside the Combinations/Clashes module and the Twelve Life Stages module. Each module references the results of the layer below. Because this structure was conveyed to AI through the design documents, AI-generated code naturally followed the layers.
Volume of Rules, Volume of Code
Wrapping up this part, what struck me most is that Saju is a "rule-dense domain." If Tarot was a "data-heavy domain," Saju is a "rule-heavy domain."
The most time-consuming part of Tarot was generating interpretation text for 78 cards. The most time-consuming part of Saju was translating every relationship rule between characters into code completely and accurately.
This difference also changed the nature of AI collaboration. In Tarot, AI was closer to a "content generator" --- producing interpretation text. In Saju, AI is closer to a "domain translator" --- converting Saju's rule system into code data structures and logic. Same AI collaboration, different role depending on the domain.
What I Learned Along the Way
First, there is no need to commit to a single implementation approach. Just as I kept both mapping tables and index arithmetic for the Five Elements, leveraging the strengths of each approach can be better than forcing a single choice.
Second, AI excels at generating large volumes of structured data accurately in one pass. For data-rich, accuracy-critical content like Combinations and Clashes, AI's advantage is maximized.
Third, AI's role shifts depending on the domain. Content generation, domain translation, logic implementation --- the most effective role for AI varies from project to project.
Next Up
The 22 characters and all their relationships are now in code. It is time to return to the true starting point of the system. The first step of any Saju analysis is converting a birth date and time into the Four Pillars, and that conversion requires a Manselyeok (calendar) engine. KASI Solar Term data, the korean-lunar-calendar library, and the True Solar Time correction algorithm. The world of calendars turns out to be far more complex than expected --- as Part 6 will demonstrate.
댓글
댓글 쓰기