Skip to content

Instantly share code, notes, and snippets.

@atr000
Created March 14, 2011 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atr000/869328 to your computer and use it in GitHub Desktop.
Save atr000/869328 to your computer and use it in GitHub Desktop.
iching.c
2
Ch'en
Earth, mother, people, etc.,
submission.
23
Po
Collapse, splitting apart,
dispersion.
8
Pi
Union, concord,
collaboration.
20
Kuan
Observation,
contemplation.
16
Yu
Harmonious joy,
enthusiasm.
35
Chin
Advance,
progress.
45
Ts'ui
Gathering together,
collection.
12
P'i
Retrogression, stagnation,
failure.
15
Ch'ien
Modesty,
humility.
52
Ken
Checking, keeping still,
stability.
39
Chien
Inhibition, obstruction,
difficulty.
53
Chien
Progressive advance,
gradual progress.
62
Hsiao Kuo
Small excess,
minor proponderance.
56
Lu
Wanderer,
wandering.
31
Hsien
Influence, wooing,
mutual influence.
33
Tun
Retreat,
regression.
7
Shih
Group action,
multitude.
4
Meng
Youthful inexperience,
obscurity.
29
K'an
Abysmal,
sinking.
59
Huan
Dissolution,
dispersion.
40
Chieh
Loosening,
deliverance.
64
Wei Chi
Not quite up to accomplishment,
what is not yet accomplished.
22
K'un
Oppression,
repression.
6
Sung
Conflict,
contention.
46
Sheng
Rising and advancing,
pushing upward.
18
Ku
Decaying, destroying,
major power.
48
Ching
Well,
source.
57
Sun
Mildness,
penetration.
32
Heng'
Constance, duration,
perserverance.
50
Ting
Cauldron,
Nourishment.
28
Ta Kuo
Large excess,
major proponderance.
44
Kou
Meeting, intercourse,
coming to meet.
24
Fu
Returning,
reversal.
27
I
Nourishment,
sustinance.
3
Chun
Initial difficulties,
bursting.
42
I
Increase,
addition.
51
Chen
Shock,
exciting power.
21
Shih ho
Biting through,
criminal proceedings.
17
Sui
Following,
succession.
25
Wu wang
Freedom from error,
innocence.
36
Ming I
Darkening of the light,
lack of appreciation.
22
Pi
Ornamental,
model.
63
Chi Chi
Completion, consummation,
accomplishment.
37
Chia Jen
Members of a family,
family.
55
Feng
Abundance,
prosperity.
30
Li
Clinging, brightness,
adherence, or of fire and light.
49
Ko
Revolution,
change.
13
T'ung Jen
Companionship,
community.
19
Lin
Approach,
advance.
41
Sun
Decrease, lessening,
diminuition.
60
Chieh
Regulation, limitation,
regulated restriction.
61
Chung Fu
Central sincerity,
truth.
54
Kuei Mei
Marrying maiden,
marriage.
38
K'uei
Division and disunion,
opposition.
58
Tui
Joy, lake,
pleasure.
10
Lu
Treading carefully,
deliberate action.
11
T'ai
Peace, progress,
success.
26
Ta Ch'u
Major restraint,
great taming force.
5
Hsu
Delaying,
waiting.
9
Hsiao Ch'u
Minor restraint,
taming force.
34
Ta Chung
Great strength,
major power.
14
Ta Yu
Great posession,
abundance.
43
Kuai
Break-through,
resoluteness.
1
Ch'ien
Heaven, king, father, etc.,
firmness.
/* Roll the I-ching.
* Rewritten from a ada program late one night when I had nothing
* else to do but glare at levee, by David Parsons.
* Even if I could copyright it, I couldn't take the loss
* of self-respect.
*/
#include <stdio.h>
#define STRINGLGTH 40
typedef char hexagram[6];
typedef char short_string[STRINGLGTH];
hexagram hex;
int hex_number;
short_string s1, s2, s3, s4;
int i, hex_num;
FILE *dat, *fopen();
#define put(s) fputs(s, stdout)
throw_i_ching (hex_number, h)
hexagram h;
int *hex_number;
{
int flips = rand();
*hex_number = (1+flips) % 64;
for (i=0; i<6; i++)
h[i] = flips & (1<<i); /* tstbit(flips, i); */
} /*throw_i_ching*/
put_solid_line()
{
register i;
for (i=0; i<15; i++)
putchar('-');
} /*put_solid_line*/
put_broken_line()
{
register i;
for (i=0; i<15; i++)
if (i < 5 || i>9)
putchar('-');
else
putchar(' ');
} /*put_broken_line*/
put_hexagram (h)
hexagram h;
{
register i;
for (i = 0; i < 6; i++) {
if (h[i])
put_solid_line();
else
put_broken_line();
putchar('\n');
}
} /*put_hexagram*/;
main()
{
char scratch[80];
long timex;
time(&timex);
srand((unsigned)timex);
if (dat = fopen("c:/lib/i_ching.dat", "r")) {
putchar('\n');
throw_i_ching(&hex_num, hex); /* flip the tokens */
put_hexagram (hex); /* and display the results */
while (hex_num > 0) { /* skip to expected hexagram */
for (i = 0; i< 4; i++)
fgets(scratch, 80, dat);
hex_num = hex_num - 1;
}
fgets (s1, STRINGLGTH-1, dat); /* read data on the hexagram */
fgets (s2, STRINGLGTH-1, dat);
fgets (s3, STRINGLGTH-1, dat);
fgets (s4, STRINGLGTH-1, dat);
put ("\nHexagram: "); put (s1); /* strings have \n already */
put ("Name: "); put (s2);
put ("Meaning: "); put (s3);
put (" "); put ("the symbol of\n");
put (" "); put (s4);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment