kintaiyi 0.2.3
Taiyi(太乙) is one of the three greatest Chinese Divination systems (三式) ever.

﻿﻿# **Python 太乙神數 Kintaiyi 堅太乙 年計 月計 日計 時計**
[![Python](https://img.shields.io/pypi/pyversions/kintaiyi)](https://pypi.org/project/kintaiyi/)
[![PIP](https://img.shields.io/pypi/v/kintaiyi)](https://pypi.org/project/kintaiyi/)
[![Downloads](https://img.shields.io/pypi/dm/kintaiyi)](https://pypi.org/project/kintaiyi/)
[![TG](https://img.shields.io/badge/chat-on%20telegram-blue)](https://t.me/gnatnek)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg?logo=paypal&style=flat-square)](https://www.paypal.me/kinyeah)&nbsp;

![alt text](https://github.com/kentang2017/kintaiyi/blob/master/pic/64459296_2342412609170469_2685042927293431808_n.jpg "太乙")
 ## 1. 導讀 Introduction
太乙神數是古代漢族占卜術的一種，與遁甲，六壬合稱三式，是推算天時以及歷史變化規律的術數學。周武王時以術數"卜世三十，卜年八百"推之，至邵雍形成歷史哲學而大備。據太乙神數推算，上古時有一年冬至日半夜，恰好日月合璧、五星連珠，定為甲子年、甲子月、甲子日、甲子時，稱作太極上元，上元甲子以來的年數，叫太乙積年。由太乙積年再求出太乙流年和太歲值卦，以斷本年各月的氣運凶吉，預測一些重大政治事件和天災人禍。採用五元六紀，三百六十年為一大周期，七十二年為一小周期，太乙每宮居三年，不入中宮，二十四年轉一周，七十二年遊三期。

太乙以一為太極生二目(主、客目)，二目生主客大小客與計神共八將。太乙乃天地之神，其星在太乙之前，統十六神而知風雨、水旱、兵革之事。昔黃帝與蚩尤大戰，適逢大霧，以霧書昏風後相，造指南車克之，是以取太乙之法，傳至今三千餘年，例目以為術數。外閱龍圖，內演龜文，凡天地之所以設君臣父子，之所以立陰陽，太乙了然演數則理昭著，太乙周行流運六十四卦，貴神入門十精之星，使經緯錯縮表理，集為一書。延續至今三千餘年不衰，為當今社會預測、決斷，提供了寶貴依據。

相傳太乙式產生于黃帝戰蚩尤時。其法大扺本于《易緯.乾鑿度》太乙行九宮法。採用五元六紀，三百六十年為一大周期，七十二年為一小周期，太乙每宮居三年，不入中宮，二十四年轉一周，七十二年遊三期。太乙以一為太極生二目(主、客目)，二目生主客大小客與計神共八將。(與易經太極分二儀，二儀生四象，四象生八卦相仿)。以太乙八將所乘十六神之方位關系定出格局。可佔內外祝福。又臨四時之分野，可佔水旱疾疫。再推三基五福大小遊二限，可預測古今治亂。又可推出年卦、月卦等。

Tai Yi Shen Shu is a form of divination from China. It is also one of the Three Styles (三式; sānshì; 'three styles') of divination, the others being Da Liu Ren and Qi Men Dun Jia. Tai Yi Shen Shu is used to predict macroscopic events like wars or the meaning of supernovae. One form of Tai Yi Shen Shu has been popularized over the centuries to predict personal fortunes. Genghis Khan, emperor of China, referred to Tai Yi at one point to decide whether or not his planned invasion of Japan would succeed. When the Tai Yi count indicated that invasion would prove unsuccessful, Khan decided not to invade Japan that year. Numerous similar examples abound in classical Chinese literature, especially among the dynastic histories.

The methodology is quite similar to the other arts with a rotating heavenly plate and fixed earthly plate. While the art makes use of the 8 trigrams as well as the 64 hexagrams as a foundation, analysis is conducted from the Tai Yi Cosmic Board and the array of symbols found thereon, with special reference to the position of symbols in specific palaces. Important symbols include the Calculator, the Scholar, Tai Yi and Tai Yi, for example.

A number of spirits rotate around the sixteen palaces of the Tai Yi cosmic board, of which there are 72 cosmic boards for the Yin Dun period of each year, and 72 cosmic boards for the Yang Dun period of the year. The spirits land in different palaces with each configuration of the cosmic board. Each cosmic board contains a number of "counts" or numbers – the Host Count and the Guest Count taking primary importance over the Fixed Count.

含史事對照的太鳦排盤 https://kintaiyi.streamlitapp.com


## 2. 安裝套件 Installation
```python
	pip install kintaiyi
	pip install --upgrade sxtwl, numpy, ephem, cn2an 
```
## 3. 起課方式 Quickstart
```python
	from kintaiyi import kintaiyi
	kintaiyi.Taiyi(658,5,31,0,14).pan(0) # 0 為年計；1 為月計；2 為日計：3 為時計 4為分計
	#{'太乙計': '年計', '太乙公式類別': '太乙統宗', '公元日期': '658年5月31日0時', '干支': ['戊午', '丁巳', '丙子', '戊子', '辛未'], '農曆': {'年': 658, '月': 4, '日': 24}, '紀元': '第一紀第二甲子元', '太歲': '午', '局式': {'文': '陽遁五十五局', '數': 55, '年': '理天', '積年數': 10154575}, '陽九': '午', '百六': '未', '太乙落宮': 3, '太乙': '艮', '天乙': '寅', '地乙': '艮', '四神': '坤', '直符': '申', '文昌': ['申', '始擊掩'], '始擊': '艮', '主算': [16, ['三才足數', '下和']], '主將': 6, '主參': 8, '客算': [0, ['無天，二曜虛蝕、五緯失度、慧孛飛流、霜雹為害', '無地，有崩地震、川竭蝗蝻之象', '無人，口舌妖言更相殘賊，疾疫、遷移、流亡']], '客將': 0, '客參': 5, '定算': [22, ['無地，有崩地震、川竭蝗蝻之象', '純陰']], '合神': '未', '計神': '申', '定目': '坤', '君基': '辰', '臣基': '亥', '民基': '寅', '五福': '艮', '帝符': '申', '太尊': '卯', '飛鳥': 1, '三風': 7, '五風': 5, '八風': 2, '大游': 1, '小游': 1, '二十八宿值日': '危', '太歲二十八宿': '角', '太歲值宿斷事': '大人有憂，兵出。', '始擊二十八宿': '危', '始擊值宿斷事': '歲多病，土工，兵起。', '十天干歲始擊落宮預測': '主中宮憂，土工興，山崩地動。', '八門值事': '景', '八門分佈': {3: '景', 4: '死', 9: '驚', 2: '開', 7: '休', 6: '生', 1: '傷', 8: '杜'}, '八宮旺衰': {7: '旺', 6: '相', 1: '胎', 8: '沒', 3: '死', 4: '囚', 9: '休', 2: '廢'}, '推太乙當時法': '太乙時計才顯示', '推三門具不具': '三門具。', '推五將發不發': '始擊掩。五將不發。', '推主客相闗法': '關生我，和', '推多少以占勝負': '客以少筭臨多，主人勝也。', '推太乙風雲飛鳥助戰法': '飛鳥方向不明確，和', '推雷公入水': '巽', '推臨津問道': '坤', '推獅子反擲': '酉', '推白雲捲空': '戌', '推猛虎相拒': '巽', '推白龍得雲': '子', '推回軍無言': '寅'}
	
```