5D Library › 纳甲装卦与奇门遁甲排盘的组合计算 · English
第五章 人盘、神盘与转盘生成的置换群
人盘与神盘
八门以同样的外圈为家:休一、生八、伤三、杜四、景九、死二、惊七、开六。旬首之宫的门为值使;值使从旬首之宫出发,每过一个时辰按洛书数序走一宫(阳顺阴逆,经过中五时按坤二计),八门随之整体转动。八神(值符、螣蛇、太阴、六合、白虎、玄武、九地、九天)从值符星的新宫起,阳遁顺排、阴遁逆排,所以神盘没有自己的自由度:它由天盘的转动与阴阳遁完全决定 (Ho 2003)。
推导
# Chapter 5. The human plate (doors), the spirits, and how many charts.
# Doors sit at home on the outer ring like the stars (Xiu 1, Sheng 8,
# Shang 3, Du 4, Jing 9, Si 2, Jing 7, Kai 6). The duty door is the door
# of the leading symbol's palace; it moves from there one palace per
# hour since the decade began, in Luoshu number order (forward in yang
# bureaus, backward in yin), through the centre if need be (counted as
# Kun 2), and all eight doors turn with it. The eight spirits start at
# the duty star's new palace and run round the ring, clockwise in yang
# bureaus and anticlockwise in yin: they add no freedom of their own.
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")
def nine(x):
return (x - 1) % 9 + 1
def outer(p):
return 2 if p == 5 else p
def turns(b, yang, k):
e = {s: nine(b + i) if yang else nine(b - i)
for i, s in enumerate(SYMBOLS)}
lead, stem, h = LEADER[k // 10], STEMS[k % 10], k % 10
src = outer(e[lead])
star = (RING.index(outer(e[lead if stem == "jia" else stem]))
- RING.index(src)) % 8
dest = nine(e[lead] + h) if yang else nine(e[lead] - h)
door = (RING.index(outer(dest)) - RING.index(src)) % 8
return star, door
if __name__ == "__main__":
joint, charts = {}, set()
for b in range(1, 10):
for y in (1, 0):
for k in range(60):
s, d = turns(b, y, k)
joint[s, d] = joint.get((s, d), 0) + 1
charts.add((b, y, s, d))
n = sum(joint.values())
door = [sum(c for (s, d), c in joint.items() if d == r)
for r in range(8)]
print(" door turn in eighths (turn:count):")
print(" " + " ".join("{}:{}".format(r, door[r]) for r in range(8)))
print(" door fu yin {:.4f}; door fan yin {:.4f}".format(
door[0] / n, door[4] / n))
print(" (star turn, door turn) pairs that occur: {} of 64".format(
len(joint)))
both = joint.get((0, 0), 0)
print(" star and door both fu yin: {:.4f}".format(both / n))
print(" distinct charts (earth plate, star turn, door turn): {:,d}"
.format(len(charts)))
print(" of 1,080 bureau-hours; spirits add nothing, being fixed by")
print(" the star turn and the dun")
print("\nReading: the human plate is a second rotation of the same")
print("ring, coupled to the first through the hour. The 1,080 bureau-")
print("hours give only 727 distinct arrangements of the three plates:")
print("different hours of one bureau can land on the same two turns,")
print("and only the hour stem itself then tells them apart.")
# door turn in eighths (turn:count):
# 0:240 1:120 2:120 3:120 4:120 5:120 6:120 7:120
# door fu yin 0.2222; door fan yin 0.1111
# (star turn, door turn) pairs that occur: 64 of 64
# star and door both fu yin: 0.1241
# distinct charts (earth plate, star turn, door turn): 727
# of 1,080 bureau-hours; spirits add nothing, being fixed by
# the star turn and the dun
#
# Reading: the human plate is a second rotation of the same
# ring, coupled to the first through the hour. The 1,080 bureau-
# hours give only 727 distinct arrangements of the three plates:
# different hours of one bureau can land on the same two turns,
# and only the hour stem itself then tells them apart.门盘的转动分布与星盘一样:不转(门伏吟)0.2222,转半圈(门反吟)0.1111。星的转法与门的转法八乘八共 64 种组合全部出现;星门同时伏吟占 0.1241。把地盘、星的转法与门的转法合起来,1,080 个局时只给出 727 种不同的三盘组合。同一局中的不同时辰,可能落在同样的两种转法上,只有时干本身把它们区分开。
转盘运算生成什么群
地盘是洛书九数上的平移与反射,天盘是外圈八宫的旋转(中宫不动)。若把这两种运算任意复合,能得到九个位置的哪些排列?
推导
# Chapter 5. Which permutations of the nine palaces the plates generate.
# Earth plates are the dihedral maps x -> b + x and x -> b - x on the
# Luoshu numbers 1..9 (p07). The heaven plate turns the eight outer
# palaces round the ring 1, 8, 3, 4, 9, 2, 7, 6 and leaves the centre.
# A heaven-plate arrangement is "earth plate, then turn". We count the
# arrangements that charts actually use, and the size of the group that
# the two kinds of move generate inside S_9 (by closure).
RING = (1, 8, 3, 4, 9, 2, 7, 6)
def nine(x):
return (x - 1) % 9 + 1
def dihedral(b, yang):
return tuple(nine(b + x) if yang else nine(b - x) for x in range(9))
def turn(r):
t = {p: RING[(RING.index(p) + r) % 8] for p in RING}
t[5] = 5
return t
def after(perm, t):
return tuple(t[p] for p in perm)
def closure(gens):
ident = tuple(range(1, 10))
seen, frontier = {ident}, [ident]
while frontier:
nxt = []
for g in frontier:
for h in gens:
c = tuple(h[x - 1] for x in g)
if c not in seen:
seen.add(c)
nxt.append(c)
frontier = nxt
return seen
def parity(p):
seen, odd = set(), 0
for i in range(9):
if i in seen:
continue
j, n = i, 0
while j not in seen:
seen.add(j)
j, n = p[j] - 1, n + 1
odd += (n - 1) % 2
return odd % 2
if __name__ == "__main__":
used = {after(dihedral(b, y), turn(r)) for b in range(1, 10)
for y in (1, 0) for r in range(8)}
half = all(after(dihedral(b, 1), turn(4)) == dihedral(nine(10 - b), 0)
for b in range(1, 10))
print(" arrangements: 18 earth plates x 8 turns = {} distinct".format(
len(used)))
shift = tuple(nine(x + 1) for x in range(1, 10))
mirror = tuple(nine(10 - x) for x in range(1, 10))
rho = tuple(turn(1)[x] for x in range(1, 10))
g = closure([shift, mirror, rho])
print(" yin plate of bureau 10 - b = yang plate of bureau b turned")
print(" half way round the ring, for every b: {}".format(half))
print(" group generated by the Luoshu shift, the mirror and one turn:")
print(" order {:,d}; all of S_9 ({:,d}): {}".format(
len(g), 362880, len(g) == 362880))
print(" the turn is an {} permutation (an 8-cycle)".format(
"odd" if parity(rho) else "even"))
print("\nReading: composed freely, the two moves of the plates reach")
print("every one of the 362,880 arrangements of nine symbols. Charts use")
print("only 72 of them, because every yin earth plate is a yang plate")
print("turned half way round: a tiny and highly structured subset.")
# arrangements: 18 earth plates x 8 turns = 72 distinct
# yin plate of bureau 10 - b = yang plate of bureau b turned
# half way round the ring, for every b: True
# group generated by the Luoshu shift, the mirror and one turn:
# order 362,880; all of S_9 (362,880): True
# the turn is an odd permutation (an 8-cycle)
#
# Reading: composed freely, the two moves of the plates reach
# every one of the 362,880 arrangements of nine symbols. Charts use
# only 72 of them, because every yin earth plate is a yang plate
# turned half way round: a tiny and highly structured subset.答案是全部:洛书平移、反射与外圈转一格这三种运算,生成九个位置上的整个对称群 ,共 362,880 个排列。外圈转一格是一个八循环,是奇置换,所以不可能只停留在偶置换的交错群里。
但排盘实际用到的只是其中极小的一部分。18 个地盘乘以 8 种转法本应是 144 种天盘排列,实际只有 72 种,因为阴遁 局的地盘正好等于阳遁 局的地盘转半圈:程序对九个局逐一验证了这一点。换言之,阴遁的地盘不是新的排列,只是阳遁地盘的反吟。
假说 · 尚未验证
作者的推测(尚未验证): 「阴遁地盘等于阳遁地盘转半圈」这一性质,来自外圈次序中相对两宫之和为十(一与九、八与二、三与七、四与六)。它可能是设计者有意利用洛书的对称,使阴阳二遁在转盘上共用一套结构。什么会证明这一推测不当:若能找到早期文献表明外圈次序的选择出于与对称无关的理由(例如方位与节气的对应),这一性质就只是巧合的后果。
小结
人盘是同一外圈的第二种旋转,神盘没有自己的自由度。1,080 个局时只给出 727 种不同的三盘组合。转盘的两种运算复合起来能生成整个 ,但排盘只用到其中 72 种天盘排列,因为每个阴遁地盘都是某个阳遁地盘转半圈。
参考文献
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).