Refactor marriage pregnancy logic in UserCharacterWorker and SQL: Updated the conception process to occur daily instead of hourly, simplifying the fertility mechanics. Enhanced documentation for clarity on the new daily conception approach and adjusted related SQL queries to reflect these changes. Introduced a mechanism to track the last fertility date to prevent multiple conceptions in a single day.
This commit is contained in:
@@ -1662,9 +1662,10 @@ pub const QUERY_AUTOBATISM: &str = r#"
|
||||
);
|
||||
"#;
|
||||
|
||||
// Biologische Fruchtbarkeit nach Alter der Frau (Jahres-Wahrscheinlichkeit).
|
||||
// Worker würfelt stündlich: P_stunde = 1 - (1 - P_jahr)^(1/8760), damit 24×/Tag zusammen
|
||||
// dieselbe kumulative Jahresaufteilung wie früher 1×/Tag mit P_tag = 1 - (1 - P_jahr)^(1/365).
|
||||
// Biologische Fruchtbarkeit nach Alter der Frau (Jahres-Wahrscheinlichkeit prob_year).
|
||||
// Konzeption: genau ein Wurf pro Ehe und Kalendertag (`UserCharacterWorker`), mit random() < prob_year.
|
||||
// Entspricht „ein Spieljahr pro Kalendertag“: keine 24× stündlichen Versuche mehr, keine „Hochzeitsnacht“
|
||||
// als Extra-Event — erste mögliche Konzeption am nächsten täglichen Fertilitätslauf nach der Hochzeit.
|
||||
// Grenzen in Tagen: 1 Jahr ≈ 365 Tage (mother_age_days).
|
||||
// Erstes gemeinsames Kind (0 Zeilen in child_relation für dieses Paar): prob_year mindestens 1.0
|
||||
// im Alter 18–~44 (6570–16000 Tage), damit kinderlose Ehen nicht über viele Jahre ohne Nachwuchs bleiben.
|
||||
@@ -1715,7 +1716,7 @@ pub const QUERY_CLEAR_STALE_MARRIAGE_PREGNANCY_DUE: &str = r#"
|
||||
AND marriage_pregnancy_due_at < NOW() - INTERVAL '30 days';
|
||||
"#;
|
||||
|
||||
/// Stündlicher Konzeptionswurf (Ehe): bei Treffer wird `marriage_pregnancy_due_at` auf +5 Tage gesetzt.
|
||||
/// Täglicher Konzeptionswurf (Ehe): bei Treffer wird `marriage_pregnancy_due_at` auf +5 Tage gesetzt.
|
||||
pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
|
||||
WITH paired AS (
|
||||
SELECT
|
||||
@@ -1811,7 +1812,7 @@ pub const QUERY_TRY_MARRIAGE_CONCEPTION_UPDATE: &str = r#"
|
||||
FROM mother_age_final ma
|
||||
WHERE ma.mother_age_days >= 4380
|
||||
AND ma.mother_age_days < 18993
|
||||
AND random() < (1 - POWER(1 - ma.prob_year, 1.0/8760.0))
|
||||
AND random() < ma.prob_year
|
||||
)
|
||||
UPDATE falukant_data.relationship r
|
||||
SET marriage_pregnancy_due_at = NOW() + INTERVAL '5 days'
|
||||
@@ -1829,7 +1830,7 @@ pub const QUERY_MARRIAGE_PREGNANCY_COLUMN_READY: &str = r#"
|
||||
) AS ready;
|
||||
"#;
|
||||
|
||||
/// Ehe: ohne Migration 008 — stündlicher Wurf legt sofort ein Kind an (wie früher).
|
||||
/// Ehe: ohne Migration 008 — täglicher Wurf legt sofort ein Kind an (Daemon ruft 1×/Kalendertag auf).
|
||||
pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
|
||||
WITH paired AS (
|
||||
SELECT
|
||||
@@ -1926,11 +1927,11 @@ pub const QUERY_GET_LEGACY_MARRIAGE_INSTANT_PREGNANCY_CANDIDATES: &str = r#"
|
||||
father_uid,
|
||||
mother_uid,
|
||||
mother_age_days,
|
||||
(1 - POWER(1 - prob_year, 1.0/8760.0)) * 100 AS prob_pct
|
||||
prob_year * 100.0 AS prob_pct
|
||||
FROM mother_age_final
|
||||
WHERE mother_age_days >= 4380
|
||||
AND mother_age_days < 18993
|
||||
AND random() < (1 - POWER(1 - prob_year, 1.0/8760.0));
|
||||
AND random() < prob_year;
|
||||
"#;
|
||||
|
||||
pub const QUERY_INSERT_CHILD: &str = r#"
|
||||
|
||||
Reference in New Issue
Block a user