fix: 신강·신약을 득령 먼저 보고 판정 — 월령 오행이 일간을 도우면 +0.15, 45~55%는 중화 (未월 己土가 시주 하나로 신약이 되던 문제)
This commit is contained in:
1 parent
b9dd0f203d
commit
263f01b4f1
9 files changed
+43
-11
No files matched your search
@@ -54,6 +54,7 @@ class SajuMe(WebPacketProtocol):
|
||||
elements: dict[str, float] = Field({}, description="오행 세력 점수 木火土金水 (월지 30·일지 20·나머지 10, 지지는 지장간 날 수로 나눔)")
|
||||
top_element: Optional[str] = Field(None, description="가장 센 오행")
|
||||
strong: Optional[bool] = Field(None, description="신강이면 true, 신약이면 false")
|
||||
strength: Optional[str] = Field(None, description="신강 · 중화 · 신약 (득령이면 돕는 몫에 가산, 45~55% 사이는 중화)")
|
||||
support: Optional[float] = Field(None, description="일간을 뺀 점수 중 일간을 돕는 기운 몫 0~1")
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def _res(r: Reading) -> Res_Saju:
|
||||
pillars=[SajuPillar(position=pos, stem=p.stem, branch=p.branch, stem_ko=ko(p.stem), branch_ko=ko(p.branch), stem_element=stem_element(p.stem), branch_element=branch_element(p.branch),
|
||||
stem_ten_god=gods[pos]["stem"], branch_ten_god=gods[pos]["branch"]) for pos, p in pillars],
|
||||
hour_known=c.hour is not None, jeol_warning=c.jeol_on_birth_day, scene=r.scene[0], scene_desc=r.scene[1], scene_icon=r.scene_icon, need=r.need,
|
||||
elements=strength.elements, top_element=strength.top, strong=strength.strong, support=strength.support,
|
||||
elements=strength.elements, top_element=strength.top, strong=strength.strong, strength=strength.label, support=strength.support,
|
||||
),
|
||||
today=SajuToday(
|
||||
day=today.day, pillar=ko(today.facts.pillar.stem + today.facts.pillar.branch), ten_god=today.facts.stem_ten_god, title=T.TEN_GOD_TEXT[today.facts.stem_ten_god][0],
|
||||
|
||||
@@ -10,7 +10,10 @@ POSITION_POINTS = {
|
||||
("year", "stem"): 10, ("year", "branch"): 10, ("month", "stem"): 10, ("month", "branch"): 30,
|
||||
("day", "stem"): 10, ("day", "branch"): 20, ("hour", "stem"): 10, ("hour", "branch"): 10,
|
||||
}
|
||||
STRONG_FROM = 0.5 # 일간을 뺀 점수 중 비겁·인성 몫이 이 이상이면 신강
|
||||
# 월령: 태어난 달의 오행. 일간 오행이 이와 같거나(왕) 달이 일간을 생하면(상) 득령. 강약은 득령을 먼저 본다
|
||||
SEASON_ELEMENT = dict(zip("寅卯巳午申酉亥子辰戌丑未", "木木火火金金水水土土土土"))
|
||||
DEUK_RYEONG_BONUS = 0.15 # 득령이면 돕는 몫에 더한다
|
||||
STRONG_FROM, WEAK_BELOW = 0.55, 0.45 # (돕는 몫 + 득령 가산) 이 이상이면 신강, 미만이면 신약, 사이는 중화
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -18,7 +21,12 @@ class Strength:
|
||||
elements: dict[str, float] # 오행별 점수 (일간 포함), 木火土金水 순
|
||||
top: str # 가장 센 오행
|
||||
support: float # 일간을 뺀 점수 중 일간을 돕는 오행(같은 오행·생해 주는 오행) 몫 0~1
|
||||
strong: bool
|
||||
deuk_ryeong: bool
|
||||
label: str # 신강 · 중화 · 신약
|
||||
|
||||
@property
|
||||
def strong(self) -> bool:
|
||||
return self.label == "신강"
|
||||
|
||||
|
||||
def char_points(chart: Chart) -> list[tuple[str, str, str, float]]:
|
||||
@@ -48,4 +56,7 @@ def chart_strength(chart: Chart) -> Strength:
|
||||
support += points if el in helpers else 0.0
|
||||
elements = {k: round(v, 1) for k, v in elements.items()}
|
||||
ratio = round(support / others, 3)
|
||||
return Strength(elements, max(elements, key=elements.get), ratio, ratio >= STRONG_FROM)
|
||||
deuk = SEASON_ELEMENT[chart.month.branch] in helpers
|
||||
judged = ratio + (DEUK_RYEONG_BONUS if deuk else 0.0)
|
||||
label = "신강" if judged >= STRONG_FROM else "신약" if judged < WEAK_BELOW else "중화"
|
||||
return Strength(elements, max(elements, key=elements.get), ratio, deuk, label)
|
||||
@@ -36,7 +36,7 @@ async def test_reading_for_anyone_gives_me_today_and_cards(offline):
|
||||
assert [p["stem"] + p["branch"] for p in r["me"]["pillars"]] == ["乙亥", "己卯", "甲辰"] and r["me"]["hour_known"] is False
|
||||
assert r["me"]["scene"].endswith("기운") and r["today"]["title"] and 0 <= r["today"]["score"] <= 100
|
||||
assert [(p.get("stem_ten_god"), p["branch_ten_god"]) for p in r["me"]["pillars"]] == [("겁재", "편인"), ("정재", "겁재"), (None, "편재")]
|
||||
assert r["me"]["top_element"] == "木" and r["me"]["strong"] is True and r["me"]["elements"]["木"] == 58.3
|
||||
assert r["me"]["top_element"] == "木" and r["me"]["strong"] is True and r["me"]["strength"] == "신강" and r["me"]["elements"]["木"] == 58.3
|
||||
kinds = [x["kind"] for x in r["today"]["cards"]]
|
||||
assert "when" in kinds and "do" in kinds and "wear" in kinds
|
||||
# 근거 줄은 쉬운 말 + 괄호 용어, 숫자 없이
|
||||
|
||||
@@ -269,6 +269,15 @@ def test_summer_earth_chart_reads_hot_and_dry_not_rainy():
|
||||
assert climate.strength.top == "土" and climate.strength.strong
|
||||
|
||||
|
||||
def test_month_rooted_day_master_stays_strong_whatever_the_hour():
|
||||
# 未월 己土는 득령(월령 土) — 시주가 물·쇠라도 신강, 득령 없는 같은 몫이면 낮게
|
||||
for h in range(0, 24, 2):
|
||||
s = chart_strength(make_chart(date(1959, 7, 16), time(h, 30)))
|
||||
assert s.deuk_ryeong and s.label == "신강", (h, s)
|
||||
winter = chart_strength(make_chart(date(1959, 12, 20))) # 子월 — 己土 득령 아님
|
||||
assert not winter.deuk_ryeong
|
||||
|
||||
|
||||
def test_month_dries_summer_earth_and_soaks_winter_earth():
|
||||
assert seasoned("己", "未")[1] < 0 < seasoned("己", "子")[1]
|
||||
assert seasoned("壬", "未")[0] > seasoned("壬", "子")[0]
|
||||
|
||||
Reference in new issue
Block a user