The ZX80/1 As Fortune Cookie

See all articles from SYNC v1 n5
Author(s): Craig Breighner
Publication: SYNC
Pub Details: SYNC v1 n5 (Volume 1, Issue 5)
Date: September/October 1981
Pages: 39
The Chinese characters for I Ching
The Chinese characters for I Ching

In addition to reputed oracular powers, the I Ching has proven to be a source of fascination for mathematicians and computer scientists. This ancient Chinese system of divination comprises one of the earliest known examples of a binary counting scheme.

The I Ching [Book of Changes] uses solid and broken lines to construct curious little six-line figures or “hexagrams” like the one shown below:

An I Ching hexagram
An I Ching hexagram
———————
———  ———
———————
———————
———  ———
———————

Since there are only two possible values for each of the six lines (solid/broken) it is not surprising that there are 64, or 2^6 hexagrams.

Associated with each hexagram is a special interpretation based on the interrelationship of solid and broken lines in the figure. This interpretation is believed to hold a particular relevance for the person for whom the hexagram has been constructed.

There are several ways to construct an I Ching hexagram. Some methods use either milfoil or yarrow stalks. The stalks are hard to come by, so bamboo is often substituted. But the complexity of some of these methods—it is said that they can only be learned from a master—would seem to defy any kind of straightforward algorithmic definition (at least any that would fit into 1K of RAM).

However, there are other methods. One is to use coins. This method has great popularity even in the Orient. A relatively simple version follows:

1) Toss three coins simultaneously.

2) Assign “point values” to the coins—2 for heads; 3 for tails.

3) Add up the total points for all three coins.

4) If the total equals 6 or 8 draw a broken line (- -). If the total equals 7 or 9 draw a solid line (—).

5) Repeat this procedure until six lines have been drawn, bottom to top.

Now, this method can be readily simulated on the ZX80. The accompanying Basic program can be lots of fun at parties. And who knows? It may even hold a deeper significance for those who consider themselves to be particularly “in tune” with their machines.

The program uses two nested FOR… NEXT… loops. The outer loop controls the number of lines in the hexagrams (6); the inner loop the number of coins (3) to be tossed.

Unfortunately, the program does not tell the user what his or her hexagram means (What did you expect in 1K, anyway?). But an excellent source of in-depth interpretations for each hexagram is I Ching: Book of Changes, Causeway Books, New York. This is an inexpensive reprint of James Legge’s 1882 translation. It is still highly regarded both for its accuracy and its completeness. Because of Legge’s notoriety as an orientalist, this translation should be available at most large municipal and university libraries.

100 DIM I(6)
110 PRINT "DOES YOUR FUTURE LIE
#IN HARMONY WITH THE";
120 Print "#ELECTRONIC PULSE OF
#THEUNIVERSE?"
130 PRINT
140 PRINT "CONSULT THE ORACLE O
F THE","I CHING: PRESS";
150 PRINT "#NEWLINE TO CREATEAN
#I CHING HEXAGRAM."
160 INPUT A$
170 FOR J=1 TO 6
180 LET K=0
190 FOR L=1 TO 3
210 LET K=K+INT (RND*2)+1
220 NEXT L
230 LET I(7-J)=K
240 NEXT J
250 CLS
260 PRINT "YOUR HEXAGRAM:"
270 PRINT
280 FOR J=1 TO 6
290 LET K=I(J)
300 IF K=4 OR K=6 OR K=8 THEN G
OTO 330
310 PRINT "▄▄▄▄▄"
320 GOTO 340
330 PRINT "▄▄#▄▄"
340 NEXT J

Notes:

310: Use the graphic on the 6 key 5 times.

330: Use the graphic on the 6 key 2 times, space, 2 times.

This program will work on 4K ROM with the following changes:

210 LET K=K+RND(2)+1

Use the graphic on the W key in lines 310 and 330.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.