Circle Games

See all articles from Sinc-Link v4 n6
Author(s): Mel Richardson
Publication: Sinc-Link
Pub Details: Sinc-Link v4 n6 (Volume 4, Issue 6)
Date: November/December 1986
Pages: 6-7

One of the delights of the Oliger Video Upgrade for the T/S 1000 is being able to run programs intended for machines beyond normal ZX capabilities. Peter McMullin has shown this with his recent article using the Modulo function and a “Computer Recreations” column by A.K. Dewdney in the September Scientific American prints the outline of a similar program by John E. Connett creating “Wallpaper For the Mind”. Connett found that using the formula for the graph of a circle (X²+Y²) to assign a colour to the point X,Y. A complex pattern of circles emerges with an underlying pattern of squares. Thus the program is called “CIRCLE²“.

The patterns appear to repeat, but a closer look shows this is not so and each area is subtly different from its neighbors. Although the program is quite simple, I recommend reading the article. It has two more routines and wonderful photos with more background than be covered here.

This program is written for the Oliger system with Fred Nachbaur‘s “Jobasic” but a normal ZX using “Graphica” or the 2068 should handle it. The lines up to 10 are Jobasic initiallization and should be changed for your system. The “IF USR M2 THEN…” is also Jobasic syntax.

The variables CORNA, CORNB & SIDE define the lower left corner and side length of the part of the plane of numbers to be examined. In other words, a smaller SIDE “magnifies” the image.

Lines 30-90 evaluate X²+Y² through the loops and places the resulting integer in “C”. Line 100 tests C for “eveness” and line 110 plots the point if C is even. It might be interesting to assign colours to ranges of C. You are encouraged to experiment with the variables and the array size in lines 30 and 40. The figures in line 110 centre the display and should be changed to suit the array size.

Some examples to try are:

CORNA -15, CORNB -20, SIDE 87
CORNA -30, CORNB 5, SIDE 40
CORNA 20, CORNB -10, SIDE 20.

Screen: CORNA -15, CORNB -20, SIDE 87
Screen: CORNA -15, CORNB -20, SIDE 87
Screen: CORNA -30, CORNB 5, SIDE 40
Screen: CORNA -30, CORNB 5, SIDE 40
Screen: CORNA 20, CORNB -10, SIDE 20
Screen: CORNA 20, CORNB -10, SIDE 20
   2 REM CIRCLE SQUARED
3 REM
4 REM JOBASIC,GRAPHICA OR OTHER HI-RES INITIALIZTION HERE
5 REM
8 REM INPUT VARIABLES
10 IF USR M2 THEN PRINT "CORNA? ";
12 IF USR M2 THEN INPUT CORNA
14 IF USR M2 THEN PRINT "CORNB? ";
16 IF USR M2 THEN INPUT CORNB
18 IF USR M2 THEN PRINT "SIDE? ";
20 IF USR M2 THEN INPUT SIDE
25 REM 170X120 PIXEL DISPLAY
30 FOR I=1 TO 170
40 FOR J=1 TO 120
60 LET X=CORNA+(SIDE*I/100)
70 LET Y=CORNB+(SIDE*J/100)
80 LET Z=X*X+Y*Y
90 LET C=INT Z
92 REM
95 REM TEST FOR EVENESS
100 LET E=C/2-INT (C/2)
110 IF NOT E THEN IF USR M2 THEN PLOT I+40,J+36
120 NEXT J
130 NEXT I
1000 IF USR M2 THEN PRINT AT 23,0;"Z-COPY R-RESTART"
1010 IF INKEY$="" THEN GOTO 1000
1020 IF INKEY$="Z" THEN IF USR M2 THEN COPY
1022 IF INKEY$="R" THEN RUN
1025 GOTO 1000

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