English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

20.4 Billion-Character Fortune-Telling Database: A Zi Wei Dou Shu Open-Source Charting Engine as a Cultural Computing Experiment

Forum topic · ✨步子哥 · 2026-10-23

Summary

On October 15, 2026, GitHub user Renhuai123 released ziwei-doushu v4.0, an open-source Zi Wei Dou Shu (Purple Star Astrology) charting engine and dataset. The engine, written in TypeScript, encodes the full rules of the traditional system: 14 major stars, dozens of auxiliary stars, the Four Transformations, 12 palaces, pattern knowledge, and major/annual/monthly limit calculations. It includes true solar time correction based on city longitude, China's 1986-1991 daylight saving time, and lunar-solar conversion with leap-month handling. The v4.0 dataset covers 674,976 birth charts (1950-2026, 12 hour periods, male/female) with 13 analysis dimensions each—about 8.77 million interpretation segments totaling roughly 20.4 billion characters (56.6 GB uncompressed, 161 MB compressed across 77 yearly files). All output is deterministically generated from the engine plus an aphorism library, without AI, so identical inputs always yield identical readings. The project adopts Ni Haixia's Tianji school as its baseline, with 1,848 verbatim quotes annotated by episode and timestamp. The engine is MIT-licensed and the dataset CC BY 4.0, while the underlying aphorism rule library remains closed. Project: https://github.com/Renhuai123/ziwei-doushu

20.4 Billion-Character Fortune-Telling Database: A Zi Wei Dou Shu Open-Source Charting Engine as a Cultural Computing Experiment

The Scenario

At 3 a.m. on a winter day in 1956, in a courtyard house in Beijing's Xicheng District, a boy was born. In Zi Wei Dou Shu terms, this hour corresponds to a Renyin year, Xinmonth, Bingyin day, Guizi hour — with the Life Palace hosting Seven Killings and Army Breaker opposite.

The traditional approach was to find an old master and pore over books like *The Complete Book of Zi Wei Dou Shu* — checking stars, transformations, patterns, and fortune cycles. A single chart took most of a day.

On October 15, 2026, Renhuai123 released the ziwei-doushu v4.0 dataset on GitHub: 674,976 charts × 13 analysis dimensions = 8,774,688 interpretation segments, roughly 20.4 billion characters, 56.6 GB uncompressed. Compressed it is only 161 MB, split into 77 files by year.

Given anyone's birth date, hour, and sex, the corresponding 13-dimensional reading — overall destiny, personality, relationships, career, wealth, health, siblings, children, travel, social relations, property, blessings, parents — can be retrieved in seconds.

This is not AI fortune-telling. It is a centuries-old divination system encoded as deterministic algorithms in TypeScript, with all possible readings batch-generated.

The Core Engineering: Turning "A Master's Experience" into Code

The complexity of charting far exceeds what most people imagine. A complete chart involves:

  • 14 major stars (Ziwei, Tianji, Taiyang, Wuqu, Tong, Lianzhen, Tianfu, Taiyin, Tanlang, Jumen, Tianxiang, Tianliang, Qisha, Pojun)
  • Dozens of auxiliary stars (Zuofu, Youbi, Wenchang, Wenqu, Tiankui, Tianyue, Lucun, Tianma, etc.)
  • The Four Transformations (Lu, Quan, Ke, Ji — different each year)
  • 12 palaces (Life, Siblings, Spouse, Children, Wealth, Health, Travel, Friends, Career, Property, Fortune, Parents)
  • A pattern knowledge base (Ziwei-Tianfu conjunction, Killing-Breaking-Wolf configurations, Sun-Moon brightness, etc.)
  • Major limit / annual / monthly fortune cycle calculations
  • The ziwei-doushu project encodes all of this as TypeScript modules:

    | Module | Function | |--------|----------| | algorithm.ts | Core charting algorithm (641 lines) | | sihua.ts | Four Transformations system | | true-solar-time.ts | True solar time correction (longitude offset + equation of time) | | dst-cn.ts | China's 1986–1991 daylight saving time | | lunar-solar.ts | Lunar/solar calendar conversion and leap-month boundaries | | school-data.ts | Star brightness data across schools | | shier-shen.ts | Twelve spirits | | yunxian-context.ts | Fortune-cycle context (including childhood limit) | | cities.ts | City longitude database (including county-level units) |

    True solar time correction is a detail most charting software ignores — at the same Beijing time, Harbin and Urumqi differ by nearly two hours in true solar time, since Beijing time is the standard time at 120°E. ziwei-doushu corrects based on the birthplace's longitude, and even includes data for remote areas like Shennongjia and Aral.

    Ni Haixia's Tianji System: One School, Done Thoroughly

    Zi Wei Dou Shu has multiple schools — Sanhe, Sihua, Feixing, etc. — each interpreting the same star in the same palace differently. ziwei-doushu adopts Ni Haixia's Tianji system as its baseline.

    Ni Haixia (1954–2012) was a Taiwanese practitioner of Chinese medicine and divination; *Tianji* is his recorded lecture course on Zi Wei Dou Shu. The reason for choosing this school is stated clearly in the README:

    > Ni said in *Tianji*: "Zi Wei Dou Shu is inherently weaker at judging close relatives." (Vol. 2-1, 00:25:27)

    The project verified Ni's quotes word by word — 1,848 quotes, each annotated with the *Tianji* episode number and timestamp. Quotes without verifiable sources were deleted or replaced with verifiable ones. Sentences about transformations that never occur (e.g., Seven Killings transforming to Quan, Ziwei transforming to Ji) were removed. Assertions that hold only under certain conditions had those conditions added.

    This is extremely rare among open-source divination projects — most either wholesale accept tradition or wholesale reject it. ziwei-doushu took a third path: keep the traditional system, but every assertion must have a source, and every condition must be stated.

    What 20.4 Billion Characters Means

    The v4.0 dataset's scale:

  • 674,976 charts: Gregorian years 1950–2026 × actual days per month × 12 hour periods × male/female
  • 8,774,688 segments: 13 dimensions per chart
  • ~20.4 billion characters: ~30,000 characters per chart
  • 56.6 GB uncompressed, 161 MB compressed
This is not AI-generated. The README states explicitly: "Deterministic generation via charting engine + aphorism library, without AI — same input always yields same output."

Deterministic generation means: given the same birth date, hour, and sex, anyone running this engine gets the exact same reading. This is "reproducible divination." The biggest problem with traditional divination has always been that the same chart gets different readings from different masters — ziwei-doushu eliminates that ambiguity with code.

What is 20.4 billion characters? The full Chinese Wikipedia is roughly 3 billion characters. This dataset is 7 times that. Yet it covers only 77 years × 12 hour periods × 2 sexes = 1,848 combinations — averaging about 11 million characters per combination.

The Boundaries of Open Source: What Opens, What Doesn't

ziwei-doushu's licensing strategy is precise:

| Content | License | |---------|---------| | Charting engine code | MIT | | Interpretation dataset v4.0 | CC BY 4.0 | | Classical texts | Public domain | | Ni Haixia's quotes | CC BY-NC-SA 4.0 (non-commercial) | | The aphorism library itself | Not open-sourced |

Keeping the aphorism library closed is a key decision. The library is the rule set of "which star in which palace maps to which reading" — the core intellectual property of Ni's system. What is open-sourced is the engine (code) and the dataset (generated results), not the rule set (the knowledge itself).

It is like open-sourcing a compiler but not its standard library — you can run the engine and verify the correctness of results, but you cannot take Ni's interpretation rules to build a commercial product.

The Meaning of Cultural Computing

ziwei-doushu is more than a charting tool. It is a cultural computing experiment — re-encoding a centuries-old divination system with modern software engineering methods.

The experiment answers several questions:

1. Can traditional divination be formalized? Largely yes. The charting algorithm, Four Transformations, and pattern judgments all have explicit rules and can be encoded as deterministic programs.

2. Can differences between schools coexist? The project supports multi-school data via school-data.ts, defaulting to *Complete Book of Zi Wei Dou Shu* brightness, with a "Modern Revision v2" option in settings.

3. Where are the system's limits? The README explicitly states "judging close relatives has limitations" — Ni himself said Zi Wei Dou Shu is weaker there. Such self-awareness is extremely rare in this field.

4. Can open source preserve traditional culture? Annotating all 1,848 of Ni's quotes with sources, and open-sourcing the engine so anyone can verify results, is more durable than transmission by word of mouth.

One-Line Summary

When 20.4 billion characters of fortune data can be generated deterministically, traditional divination shifts from "do you believe it" to "is it accurate" — and accuracy can be verified.

---

🔗 Project: https://github.com/Renhuai123/ziwei-doushu 🔗 Live demo: metisziwei.com

Tags

#zi-wei-dou-shu#open-source#typescript#deterministic-generation#cultural-computing#astrology#dataset#ni-haixia

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178636374