iching¶
A simple model I Ching.
- All data and probabilities taken from Wikipedia at:
-
blur.iching.
get_hexagram
(method='THREE COIN')¶ Return one or two hexagrams using any of a variety of divination methods.
The
NAIVE
method simply returns a uniformally randomint
between1
and64
.All other methods return a 2-tuple where the first value represents the starting hexagram and the second represents the ‘moving to’ hexagram.
To find the name and unicode glyph for a found hexagram, look it up in the module-level hexagrams dict.
Parameters: method (str) – 'THREE COIN'
,'YARROW'
, or'NAIVE'
, the divination method model to use. Note that the three coin and yarrow methods are not actually literally simulated, but rather statistical models reflecting the methods are passed to blur.rand functions to accurately approximate them.Returns: int – If method == 'NAIVE'
, theint
key of the found hexagram. Otherwise a tuple will be returned.tuple: A 2-tuple of form
(int, int)
where the first value is key of the starting hexagram and the second is that of the ‘moving-to’ hexagram.Raises: ValueError if
method
is invalidExamples:
The function being used alone:
>>> get_hexagram(method='THREE COIN') # Might be... (55, 2) >>> get_hexagram(method='YARROW') # Might be... (41, 27) >>> get_hexagram(method='NAIVE') # Might be... 26
Usage in combination with hexagram lookup:
>>> grams = get_hexagram() >>> grams (47, 42) # unpack hexagrams for convenient reference >>> initial, moving_to = grams >>> hexagrams[initial] ('䷮', '困', 'Confining') >>> hexagrams[moving_to] ('䷩', '益', 'Augmenting') >>> print('{} moving to {}'.format( ... hexagrams[initial][2], ... hexagrams[moving_to][2]) ... ) Confining moving to Augmenting
-
blur.iching.
hexagrams
(dict)¶ A dict of the brief information on the 64 hexagrams in the form
{number: (hexagram_symbol, chinese_character, english_translation)}
For example,
hexagrams = { 1: ('䷀', '乾', 'Force'), 2: ('䷁', '坤', 'Field'), 3: ('䷂', '屯', 'Sprouting'), 4: ('䷃', '蒙', 'Enveloping'), . . . 64: ('䷿', '未濟', 'Not Yet Fording') }