5D Library › 纳甲装卦与奇门遁甲排盘的组合计算 · English
第六章 格局的频率、约定的分歧与相邻时辰
击刑与入墓
奇门的判断大量依赖「格局」:某个符号落在某一宫。以天盘为准,最常用的两类是六仪击刑(戊到震三、己到坤二、庚到艮八、辛到离九、壬到巽四、癸到巽四)与三奇入墓。入墓的规则在通行书中至少有三种写法:通行的「乙坤、丙乾、丁艮」;阴阳同生同死,丁与丙同墓于戌(乾六);阳死阴生,乙墓于戌(乾六)。下面的程序对全部 1,080 个局时统计这些格局。
推导
# Chapter 6. How often the named patterns occur, and under which rules.
# Heaven plate as in p08: each outer star carries the earth-plate symbol
# of its home palace round the ring; the centre's symbol rides with Rui.
# Patterns read on the heaven plate (palace numbers):
# "six yi punish" (ji xing): wu on 3, ji on 2, geng on 8, xin on 9,
# ren on 4, gui on 4;
# "three qi in the tomb" (ru mu), three printed conventions:
# common yi on 2, bing on 6, ding on 8
# same-life yi on 2, bing on 6, ding on 6 (yin and yang stems
# share their tomb)
# yang-dies yi on 6, bing on 6, ding on 8 (yin stems take the
# tomb of the opposite cycle)
SYMBOLS = ("wu", "ji", "geng", "xin", "ren", "gui", "ding", "bing", "yi")
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
"gui")
RING = (1, 8, 3, 4, 9, 2, 7, 6)
LEADER = ("wu", "ji", "geng", "xin", "ren", "gui")
PUNISH = {"wu": 3, "ji": 2, "geng": 8, "xin": 9, "ren": 4, "gui": 4}
TOMB = {"common": {"yi": 2, "bing": 6, "ding": 8},
"same-life": {"yi": 2, "bing": 6, "ding": 6},
"yang-dies": {"yi": 6, "bing": 6, "ding": 8}}
def nine(x):
return (x - 1) % 9 + 1
def outer(p):
return 2 if p == 5 else p
def heaven(b, yang, k):
e = {s: nine(b + i) if yang else nine(b - i)
for i, s in enumerate(SYMBOLS)}
lead, stem = LEADER[k // 10], STEMS[k % 10]
r = (RING.index(outer(e[lead if stem == "jia" else stem]))
- RING.index(outer(e[lead]))) % 8
where = {}
for s, p in e.items():
src = 2 if p == 5 else p
where[s] = RING[(RING.index(src) + r) % 8]
return where
def flags(where):
punish = any(where[s] == p for s, p in PUNISH.items())
tomb = {c: any(where[s] == p for s, p in t.items())
for c, t in TOMB.items()}
return punish, tomb
if __name__ == "__main__":
rows = [flags(heaven(b, y, k)) for b in range(1, 10) for y in (1, 0)
for k in range(60)]
n = len(rows)
print(" {:,d} bureau-hours".format(n))
print(" six yi punish somewhere on the heaven plate: {:.4f}".format(
sum(p for p, _ in rows) / n))
for c in TOMB:
print(" a qi in the tomb, {:9s} rule: {:.4f}".format(
c, sum(t[c] for _, t in rows) / n))
names = list(TOMB)
for i in range(3):
for j in range(i + 1, 3):
d = sum(t[names[i]] != t[names[j]] for _, t in rows) / n
print(" tomb verdict differs, {} vs {}: {:.4f}".format(
names[i], names[j], d))
print("\nReading: some 'punishment' is on the heaven plate in more")
print("than half of all charts and a qi is in a tomb in about a third.")
print("The three printed tomb rules disagree about a given chart for")
print("between a fifth and two fifths of all bureau-hours.")
# 1,080 bureau-hours
# six yi punish somewhere on the heaven plate: 0.5296
# a qi in the tomb, common rule: 0.3426
# a qi in the tomb, same-life rule: 0.3361
# a qi in the tomb, yang-dies rule: 0.3315
# tomb verdict differs, common vs same-life: 0.2102
# tomb verdict differs, common vs yang-dies: 0.1944
# tomb verdict differs, same-life vs yang-dies: 0.4046
#
# Reading: some 'punishment' is on the heaven plate in more
# than half of all charts and a qi is in a tomb in about a third.
# The three printed tomb rules disagree about a given chart for
# between a fifth and two fifths of all bureau-hours.天盘某处出现六仪击刑的局时占 0.5296,过半;三奇入墓按三种规则分别占 0.3426、0.3361、0.3315,都约三分之一。频率相近,并不表示判断相近:对同一个局时,三种规则意见不一的比例两两为 0.2102、0.1944 与 0.4046。也就是说,同一张盘「有没有奇入墓」,换一本书,有五分之一到五分之二的机会得到相反的回答。
天禽的处理。 程序中天禽所携中五宫之奇仪随天芮同转,并同样计入击刑与入墓统计。
五不遇时:歌诀与公式
「五不遇时」指时干克日干且阴阳相同(七杀)的时辰。由第 66 本的五鼠遁公式,时干为 模 10,七杀之干为日干加 6;解这个同余方程就得到每日的五不遇时。
推导
# Chapter 6. The "five non-meeting hours" from the five-rats formula.
# An hour is "non-meeting" when its stem controls the day stem with the
# same polarity (the seven-killings relation): hour stem = day stem + 6
# (mod 10). With the hour stem 2 (D mod 5) + h (mod 10) for branch h,
# this is solvable in h for every day, and twice when the stem returns
# at the hai and xu hours. The verse as usually printed lists one hour
# per day stem.
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
"gui")
BRANCHES = ("zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen",
"you", "xu", "hai")
VERSE = ("geng-wu", "xin-si", "ren-chen", "gui-mao", "jia-yin", "yi-chou",
"bing-zi", "ding-you", "wu-shen", "ji-wei")
def hours_of(d):
return ["{}-{}".format(STEMS[(2 * (d % 5) + h) % 10], BRANCHES[h])
for h in range(12)]
if __name__ == "__main__":
total = 0
for d in range(10):
bad = [x for x in hours_of(d) if x.split("-")[0] == STEMS[(d + 6)
% 10]]
total += len(bad)
mark = "" if bad == [VERSE[d]] else " <- verse lists {}".format(
VERSE[d])
print(" {:4s} day: {}{}".format(STEMS[d], " ".join(bad), mark))
print(" non-meeting hours among 10 x 12 = 120 day-hours: {} = {:.4f}"
.format(total, total / 120))
print("\nReading: the verse is the five-rats formula solved for the")
print("seven-killings stem; it lists the first solution only. On ji")
print("and geng days the same stem comes round again in the xu or hai")
print("hour, so the formula gives a second non-meeting hour that the")
print("verse omits.")
# jia day: geng-wu
# yi day: xin-si
# bing day: ren-chen
# ding day: gui-mao
# wu day: jia-yin
# ji day: yi-chou yi-hai <- verse lists yi-chou
# geng day: bing-zi bing-xu <- verse lists bing-zi
# xin day: ding-you
# ren day: wu-shen
# gui day: ji-wei
# non-meeting hours among 10 x 12 = 120 day-hours: 12 = 0.1000
#
# Reading: the verse is the five-rats formula solved for the
# seven-killings stem; it lists the first solution only. On ji
# and geng days the same stem comes round again in the xu or hai
# hour, so the formula gives a second non-meeting hour that the
# verse omits.公式的解与通行歌诀「甲日庚午乙辛巳……」逐日相符,只有两处例外:己日与庚日,同一天干在戌时或亥时又出现一次,所以公式给出第二个五不遇时(己日乙亥、庚日丙戌),歌诀只列了第一个。在 120 个日干—时支组合中,五不遇时共 12 个,占 0.1000。
相邻时辰
第 66 本说明了出生时间误差对四柱的影响。对奇门,问题是:同一局中,相邻两个时辰的盘在格局上差多少?
推导
# Chapter 6. One double-hour of timing error: does the chart change?
# For every bureau-hour k (0-59) the heaven plate (p08, p11) is compared
# with the next hour k + 1 of the same bureau. We count how often the
# fu yin flag, the "punishment" flag and the common-rule "tomb" flag
# change, i.e. how much a reading built on these flags depends on which
# side of a double-hour boundary a birth or a question falls.
SYMBOLS = ("wu", "ji", "geng", "xin", "ren", "gui", "ding", "bing", "yi")
STEMS = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren",
"gui")
RING = (1, 8, 3, 4, 9, 2, 7, 6)
LEADER = ("wu", "ji", "geng", "xin", "ren", "gui")
PUNISH = {"wu": 3, "ji": 2, "geng": 8, "xin": 9, "ren": 4, "gui": 4}
TOMB = {"yi": 2, "bing": 6, "ding": 8}
def nine(x):
return (x - 1) % 9 + 1
def outer(p):
return 2 if p == 5 else p
def chart(b, yang, k):
e = {s: nine(b + i) if yang else nine(b - i)
for i, s in enumerate(SYMBOLS)}
lead, stem = LEADER[k // 10], STEMS[k % 10]
r = (RING.index(outer(e[lead if stem == "jia" else stem]))
- RING.index(outer(e[lead]))) % 8
where = {s: RING[(RING.index(outer(p)) + r) % 8] for s, p in e.items()}
return (r == 0,
any(where[s] == p for s, p in PUNISH.items()),
any(where[s] == p for s, p in TOMB.items()))
if __name__ == "__main__":
changes = [0, 0, 0]
pairs = 0
for b in range(1, 10):
for y in (1, 0):
for k in range(59):
a, c = chart(b, y, k), chart(b, y, k + 1)
pairs += 1
for i in range(3):
changes[i] += a[i] != c[i]
for name, c in zip(("fu yin", "punishment", "tomb (common)"), changes):
print(" {:14s} flag changes between neighbouring hours: {:.4f}"
.format(name, c / pairs))
print(" (over {:,d} pairs of neighbouring bureau-hours)".format(pairs))
print("\nReading: each of these flags changes between one double-hour")
print("and the next for two fifths to more than half of all pairs, so")
print("a reading built on them depends heavily on exact timing.")
# fu yin flag changes between neighbouring hours: 0.4030
# punishment flag changes between neighbouring hours: 0.5499
# tomb (common) flag changes between neighbouring hours: 0.4840
# (over 1,062 pairs of neighbouring bureau-hours)
#
# Reading: each of these flags changes between one double-hour
# and the next for two fifths to more than half of all pairs, so
# a reading built on them depends heavily on exact timing.在同一局的 1,062 对相邻时辰中,伏吟与否改变的占 0.4030,有无击刑改变的占 0.5499,有无入墓(通行规则)改变的占 0.4840。以这些格局为依据的判断,对时辰的边界极为敏感:起盘时刻若落在时辰交界附近,应当同时看相邻时辰的盘。
小结
天盘击刑出现在过半的局时中,入墓约三分之一;三种通行的入墓规则对同一张盘的判断两两不一致的比例在 0.1944 与 0.4046 之间。五不遇时是五鼠遁公式的解,歌诀漏列了己日与庚日的第二个解。相邻时辰之间,伏吟、击刑、入墓这些标记有四成到五成半会改变。
Fan, Y. (2026). Najia Hexagram Encoding and Qimen Dunjia Combinatorial Engines: Eight-Palace Group Actions, Sexagenary Void Cosets, Split-Supplement versus Intercalation Divergences and Nine-Palace Rotor Permutations [纳甲装卦与奇门遁甲排盘的组合计算] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090182 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).