# Inkblot

INKBLOT is a program that produces "inkblots" similar to those used in the famous Rorschach Inkblot tests. The program generates these inkblots randomly so that literally millions of different patterns can be produced.

INKBLOT is one of the programs in "More BASIC Computer Games".

```PROCEDURE inkblot
PRINT TAB(26);"INKBLOT"
PRINT TAB(20);"CREATIVE COMPUTING"
PRINT TAB(18);"MORRISTOWN, NEW JERSEY"
PRINT \ PRINT \ PRINT
REM *** WORKS BY PLOTTING ELLIPSES AND THEIR MIRROR IMAGES
DIM A(12,13):REAL;B\$:STRING[36];A\$(36):STRING[1]
REM CHOOSE FROM 5 TO 12 ELLIPSES
M=INT(8*RND(1))+5
REM CREATE SIZE, LOCATION AND ANGLE OF M ELLIPSES
FOR L = 1 TO M
A(L,1) = 34*RND(1)
A(L,2) = 80*RND(1)
A(L,3) = (15*RND(1)+2)^2
A(L,4) = (15*RND(1)+2)^2
T=PI*RND(1)
A(L,5) = COS(T)
A(L,6) = SIN(T)
A(L,7) = A(L,5)*A(L,6)
A(L,5) = A(L,5)*A(L,5)
A(L,6) = A(L,6)*A(L,6)
A(L,8) = A(L,1)*A(L,1)*A(L,6)
A(L,9) = A(L,1)*A(L,1)*A(L,5)
A(L,10) = A(L,1)*A(L,7)
A(L,11) = -2*A(L,1)*A(L,6)
A(L,12) = -2*A(L,1)*A(L,5)
A(L,13) = A(L,6)/A(L,4)+A(L,5)/A(L,3)
NEXT L
REM *** PRINT TOP BORDER; B\$ CONTAINS 36 DOLLAR SIGNS
B\$="\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$"
PRINT B\$;B\$
PRINT B\$;B\$
REM *** LOOP Y IS Y-COORDINATE OF PLOT; EACH TIME Y LOOP
REM *** IS EXECUTED, A LINE IS PRINTED
FOR Y = 79.9 TO 0 STEP -1.6
A\$(1) = "\$" \ A\$(2) = "\$"
FOR P = 3 TO 36 \ A\$(P) = " " \ NEXT P
REM *** LOOP E CHECKS THE EQUATION OF EACH ELLIPSE TO SEE
REM *** IF IT INTERSECTS THE LINE TO BE PRINTED
FOR E=1 TO M
Y1=Y-A(E,2)
Y2=Y1*Y1
Y3=Y1*A(E,10)
Y4=Y1*A(E,7)
B=(A(E,12)+Y4)/A(E,3)+(-Y4+A(E,11))/A(E,4)
C=(Y2*A(E,6)+A(E,9)-Y3)/A(E,3)+(Y2*A(E,5)+A(E,8)+Y3)/A(E,4)-1
R=B*B-4*A(E,13)*C
IF R>=0 THEN
R=SQR(R)
REM *** FIND WHERE THE LINE INTERSECTS IN THE ELLIPSE
R1=INT(-(B+R)/2/A(E,13)+1)
IF R1<=34 THEN
R2=INT((R-B)/2/A(E,13))
IF R2>=1 THEN
IF R2>=35 THEN R2=34 \ ENDIF
IF R1<=0 THEN R1=1 \ ENDIF
REM *** FILL IN THE LINE WHERE IT CROSSES THE ELLIPSE
FOR J=R1+2 TO R2+2
A\$(J) = "\$"
NEXT J
ENDIF
ENDIF
ENDIF
NEXT E
REM *** PRINT LINE
FOR K=1 TO 36 STEP 1 \ PRINT A\$(K); \ NEXT K
FOR K=36 TO 1 STEP -1 \ PRINT A\$(K); \ NEXT K
PRINT
NEXT Y
REM *** PRINT BOTTOM BORDER
PRINT B\$;B\$
PRINT B\$;B\$
END
```

Sidst opdateret: 2018/10/06
Website vedligeholdt af Søren Roug