DEV Community

taurus yao
taurus yao

Posted on

The 5-Step Algorithm Behind a Zi Wei Dou Shu Chart - Worked by Hand, With Every Convention Flagged

Most chart-based systems are pipelines. A small, well-defined input goes through a fixed sequence of deterministic transforms and comes out the other side as a large, structured artifact. Zi Wei Dou Shu - a Chinese system of charting built on the lunar calendar - is a clean case study, because its arithmetic is fixed and auditable, and almost every genuinely hard question lives at the boundaries rather than in the interpretation.

This post walks the five mechanical steps on a single worked example, and flags at each step the places where independent implementations legitimately diverge. Those divergence points are the reason two tools can disagree about a chart without either one being wrong, and knowing where they are is what makes a chart checkable in the first place.

The input is unglamorous: a Gregorian date, a clock time, and a sex. The output is a 12-slot grid (the "palaces"), each slot carrying a palace name, a branch, a stem, a Five Element Bureau, and a set of stars. Everything in between is arithmetic.

Worked example throughout: born 12 September 1992, 10:20, female.

Step 1 - Convert the birth data, and decide about true solar time

The chart is built on the lunar calendar, not the Gregorian one, so the first step converts the civil date to a lunar date and expresses the birth time as a double-hour (a two-hour block), not as clock minutes.

  • Worked example: 1992-09-12 10:20 becomes lunar year 1992, month 8, day 16, in the Si double-hour. The year pillar is Ren-Shen.

This step looks objective and is not entirely so:

  • True solar time. Clock time is not solar time. A 10:20 birth can fall in a different double-hour once longitude correction (and, in some methods, the equation of time) is applied. Some implementations correct for this, others take the clock as given. Near a boundary, this alone moves the chart.
  • Where the correction is anchored. Correction needs a birthplace. Historical moves and the choice of a nearby city both introduce small differences.
  • Lunar month boundaries. Whether a lunar month starts at the astronomical new moon or an adopted civil date can differ by a day between data sources, which is enough to shift the month count.
  • Leap months. For a birth in an intercalary month, systems differ on whether to count it in its own right or fold it into the preceding month.

Step 2 - Locate the Life Palace and the Body Palace

The twelve palaces are anchored by the Life Palace. The classical procedure runs the month count forward from the Yin palace, then the hour count backward from wherever the month count landed.

BRANCHES = ["Zi", "Chou", "Yin", "Mao", "Chen", "Si",
            "Wu", "Wei", "Shen", "You", "Xu", "Hai"]

def palaces(lunar_month, hour_index):
    # hour_index: 0 = Zi, 1 = Chou, ... 5 = Si, ... 11 = Hai
    # movement 1 - Yin holds month 1, count forward to the birth month
    month_pos = (2 + (lunar_month - 1)) % 12
    # movement 2 - put Zi at month_pos; life counts backward, body forward
    life = (month_pos - hour_index) % 12
    body = (month_pos + hour_index) % 12
    return BRANCHES[life], BRANCHES[body]

palaces(8, 5)   # -> ('Chen', 'Yin')
Enter fullscreen mode Exit fullscreen mode
  • Worked example, movement 1: Yin as month 1, counting forward to month 8, gives the You palace.
  • Movement 2, Life: from You, set Zi there and count backward to the Si hour: You, Shen, Wei, Wu, Si, Chen - the Life Palace is Chen.
  • Movement 2, Body: same start, opposite direction: You, Xu, Hai, Zi, Chou, Yin - the Body Palace is Yin.

Two useful invariants fall out of the arithmetic. First, the Body Palace uses the same starting position as the Life count and runs the other way, so it can only ever land on six of the twelve palaces. Second, the hour index that drives both movements is a double-hour index, so every ambiguity from Step 1 inherits straight into this step.

Divergence points here: the direction convention used for each of the two movements; which double-hour actually feeds the count (inherited from Step 1); and late-Zi births, between 23:00 and midnight, where implementations disagree on whether that hour belongs to the current day or the next.

Step 3 - Fix the Five Element Bureau

The Life Palace is not only a position - it also takes a stem, assigned by the same stem cycle that assigns stems to the months of the year: the year stem anchors the Yin palace and the cycle runs forward from there. Life Palace stem and branch together form a sexagenary pair, and that pair's associated element and number give the Five Element Bureau.

  • Worked example: the year stem is Ren. Anchoring Yin with Ren and counting forward: Yin = Ren, Mao = Gui, Chen = Jia. The Life Palace is Jia-Chen, the pair for the Fire Six Bureau.
Element Bureau Number
Water Water Two 2
Wood Wood Three 3
Metal Metal Four 4
Earth Earth Five 5
Fire Fire Six 6

That number is not decorative. The next step consumes it.

Divergence at this step is almost always inherited: the mapping is a standard table, so a different bureau usually means Step 2 produced a different Life Palace.

Step 4 - Place the Zi Wei star

Zi Wei is positioned by a two-input lookup: the bureau number and the lunar day of birth. Given both, a fixed table returns the palace where Zi Wei sits. This star anchors the largest group of the main stars.

  • Worked example: bureau Fire Six, lunar day 16 -> Zi Wei sits in the Wu palace.

Divergence points: published tables have historically differed, especially for higher bureau numbers and the later days of a lunar month; and the wrap-around adjustment some presentations apply at month end varies in how aggressive it is. Because everything in Step 5 hangs off Zi Wei, a one-palace difference here propagates widely.

Step 5 - Distribute the fourteen main stars

The fourteen main stars travel in two groups. The Zi Wei group is placed relative to Zi Wei, running stepwise in one direction. The Tian Fu group is anchored by Tian Fu, positioned by a mirror relationship to Zi Wei, and runs stepwise in the opposite direction.

  • Worked example: Zi Wei in Wu, Tian Fu in Xu. Applying the two sequences gives:
Palace Main star(s)
Life Qi Sha
Siblings Tai Yang, Tian Liang
Spouse Wu Qu, Tian Xiang
Children Tian Tong, Ju Men
Wealth Tan Lang
Health Tai Yin
Travel Lian Zhen, Tian Fu
Friends -
Career Po Jun
Property -
Fortune Zi Wei
Parents Tian Ji

Two palaces hold no main star at all, which is normal: twelve palaces outnumber fourteen stars, and empty palaces are read through their opposite palace and the surrounding triangle rather than treated as blank.

Divergence points: which auxiliary and minor stars are included at all (the widest area of disagreement); how the Four Transformations that arise from the decade and the year are treated versus those from birth; and how much of the result a tool chooses to display.

Why two tools can disagree without either being wrong

Collect the divergence points and the picture is clean. Two charts for the same birth data can differ because of:

  • whether true solar time was applied, and how;
  • how the double-hour boundary and the late-Zi hour were treated;
  • lunar month boundary and leap month handling;
  • the direction convention used for the Life and Body palaces;
  • which published table variant placed Zi Wei;
  • which auxiliary and minor stars were included.

Almost none of these are disagreements about interpretation. They are disagreements about input and mechanics, and they happen before interpretation begins. That is why a comparison that looks only at the final reading is so often confusing: the two readings may not be describing the same chart at all.

How to check a calculator

  • Reproduce Steps 1 to 3 by hand. They are arithmetic you can do on paper. If a tool's Life Palace or bureau disagrees with your own count, stop and find out why.
  • Test a boundary case. Pick a birth a few minutes either side of a double-hour edge and see whether the chart moves. That tells you immediately whether solar-time correction is in play.
  • Ask what is being shown. A sparse chart may simply be filtered, not wrong.
  • Prefer tools that state their conventions. A chart with visible assumptions can be reasoned about; one with hidden assumptions cannot.

What the calculation does not do

All of the above produces a chart. It does not produce a reading. Interpretation is a separate layer: relationships between palaces, the transformations stars carry, and the decade and year cycles that activate different parts of the chart over time. Keeping the two layers distinct is the same discipline as keeping a deterministic core separate from the layer that narrates it, and it is what makes the core testable.

If you want to run the whole sequence on your own birth data, the full step-by-step walkthrough behind this post lives here: How a Zi Wei Dou Shu Chart Is Calculated.

Top comments (0)