How does the Qimen Dunjia Arrangement program determine the value symbol

Recently, I finished writing the entire Qimen Dunjia arrangement program, and the more difficult thing is to determine the value symbol and position.

The calculation of the value symbol depends on the first day of the sun pillar, which is Jia and Ji. No matter what the sky stem of the sun pillar is, it depends on the distance from the first day of the day.

tgday,dzday = self.__tiangan.index(self.bz[0][4]),self.__dizhi.index(self.bz[0][5])
##日柱天干和日柱地支
        """计算旬首,从日天干数一直减到5或者0,求地支数"""
        n = 0
        if tgday < 5:
            while tgday > 0:
                tgday -= 1
                n += 1
                if tgday == 0:
                    break
        else:
            while tgday > 5:
                tgday -= 1
                n += 1
                if tgday == 5:
                    break

        dizhi = (dzday+12-n)%12
        """计算旬首结束"""

dizhi represents the earthly branch corresponding to the first ten days, and this earthly branch determines the number of bureaus. Finding the number of rounds:

"""求上中下三元,四仲为上,四孟为中,四季为下"""
        flag = 0
        if dizhi in [0,3,6,9]:
            flag = 0
        elif dizhi in [2,5,8,11]:
            flag = 1
        elif dizhi in [1,4,7,10]:
            flag = 2
        ju_num = self.jq[flag]   #  局数
        """计算三元结束,确定了局数"""

At this time, the house position corresponding to ju_num is the position of the territory E, and then according to the house position, arrange according to the order of yang, yin, yang, yin and yin:

"""根据阴阳遁,排地盘天干"""
        undertiangan = {
    
    }
        if self.yinyang == 1:
            for i in range(9):
                num = (i+9+ju_num)%9
                if num == 0:
                    num = num + 9
                undertiangan[str(num)] = self.__qmtiangan[i%9]
        else:
            for i in range(9):
                num = (9 - i + ju_num) % 9
                if num == 0:
                    num = num + 9
                undertiangan[str(num)] = self.__qmtiangan[i%9]
        """排地盘天干结束"""

At this time, the arrangement of the heavenly stems of the land is completed, and the heavenly stems of the land and the corresponding houses are available, so the value of the heavenly disk can be easily determined.

Guess you like

Origin blog.csdn.net/miaoxingjundada/article/details/129657082