This program implements a two-player Memory (Concentration) card-matching game on a 6×8 grid. Pairs of 12 different block-graphic symbols are randomly placed in the array A(6,8), and players take turns entering row and column coordinates to reveal and match hidden tiles. The grid uses inverse-video question marks (%?) as face-down tile covers, and matched tiles are replaced with a blank space. Scores for Player 1 (B) and Player 2 (C) are tracked, and the game ends when all 24 pairs (B+C=24) have been matched. The program uses FAST mode during initialization and switches to SLOW mode before gameplay begins.
Program Analysis
Program Structure
The program divides cleanly into three phases: initialization, board display, and the main game loop.
- Lines 5–120: Setup — runs in
FASTmode, randomises, dimensions the board array, defines the symbol string, and places pairs randomly. - Lines 130–185: Board rendering — prints the title, column headers, row labels, and the initial grid of hidden tiles; then switches to
SLOWmode. - Lines 190–520: Game loop — alternates players via
GOSUB 230, handles input, reveals tiles, checks for matches, updates scores, and detects the end of the game.
Data Representation
The 6×8 array A(6,8) stores integer values 1–12, each appearing exactly twice. These values index into the 24-character string A$ (line 40), where each pair of characters encodes one block-graphic symbol using zmakebas two-character escapes. The 12 distinct symbols are drawn from the ZX81 block-graphic character set: ▘ ▝ ▖ ▄ ▌ ▗ ▀ ▐ ▟ ▙ ▛ ▘.
Because each symbol occupies exactly 2 characters in A$, the PRINT AT statement on line 270 correctly prints a two-character graphic with A$(F) — this works because ZX81 BASIC A$(F) returns a single character at position F, so actually only one character is printed per reveal. The pairing of characters in A$ is therefore decorative rather than functional; each match index selects one character.
Random Placement Algorithm
Lines 50–120 use a collision-rejection loop to place pairs. The outer loop runs I from 1 to 12 (one symbol value per pair), and the inner loop runs J from 1 to 4 — meaning four copies of each symbol are placed, not two. This is a bug: with 12 symbols × 4 placements = 48 required slots but only 48 cells (6×8=48), the board is completely filled, but players must find groups of four identical tiles rather than pairs, making the game harder than a standard Concentration game.
Turn Management
The current player is held in variable Z (1 or 2). After a failed match, lines 350–380 toggle Z between 1 and 2. On a successful match, the scoring branch at lines 460–510 increments B (Player 1’s score) or C (Player 2’s score) and prints them at fixed screen positions. The player does not switch after a successful match, giving the matching player another turn — consistent with standard Concentration rules.
Key BASIC Idioms
LET X=INT(RND*6+1)/INT(RND*8+1)— standard ZX81 integer range idiom for 1–6 and 1–8.IF A(X,Y)<>0 THEN GOTO 70— collision rejection; retries until an empty cell is found.PAUSE 100at line 330 — gives players time to see both revealed tiles before they are hidden again on a mismatch.- Inverse-video characters in
PRINTstrings (e.g.%G%U%E%S%S) render the title and hidden-tile marker in inverse video.
Screen Layout
| Screen row | Content |
|---|---|
| 1 | Title: “GUESS BACK” (inverse video) |
| 3 | Column numbers 1–8 |
| 5, 7, 9, 11, 13, 15 | Grid rows for board rows 1–6 |
| 11, col 3 | Player 1 score (B) |
| 11, col 29 | Player 2 score (C) |
| 17 | Current player indicator |
| 19 | Input prompts / match result |
Content
Source Code
5 FAST
6 RAND
10 DIM A(6,8)
20 LET B=0
30 LET C=0
40 LET A$="\' \ '\ .\. \: \..\''\ :\.:\:.\:'\':"
50 FOR I=1 TO 12
60 FOR J=1 TO 4
70 LET X=INT (RND*6+1)
80 LET Y=INT (RND*8+1)
90 IF A(X,Y)<>0 THEN GOTO 70
100 LET A(X,Y)=I
110 NEXT J
120 NEXT I
130 PRINT AT 1,11;"% %G%U%E%S%S% % %B%A%C%K% "
140 PRINT AT 3,10;"1 2 3 4 5 6 7 8"
150 FOR I=1 TO 6
160 PRINT AT 2*I+3,8;I;
170 PRINT "\@@%?\@@%?\@@%?\@@%?\@@%?\@@%?\@@%?\@@%?\@@"
180 NEXT I
185 SLOW
190 LET Z=1
200 PRINT AT 17,6;"PLAYER ";Z;" GOES"
210 GOSUB 230
220 GOTO 200
230 PRINT AT 19,15;"1ST"
240 INPUT X
250 INPUT Y
260 LET F=A(X,Y)
270 PRINT AT 2*X+3,2*Y+8;A$(F)
280 PRINT AT 19,15;"2ND"
290 INPUT R
300 INPUT T
310 LET S=A(R,T)
320 PRINT AT 2*R+3,2*T+8;A$(S)
330 PAUSE 100
340 IF F=S THEN GOTO 440
350 IF Z=1 THEN GOTO 380
360 LET Z=1
370 GOTO 390
380 LET Z=2
390 LET Y$="%?"
400 PRINT AT 19,15;"NO "
410 PRINT AT 2*X+3,2*Y+8;Y$
420 PRINT AT 2*R+3,2*T+8;Y$
430 RETURN
440 PRINT AT 19,15;"OK "
450 LET Y$=" "
460 IF Z=1 THEN GOTO 500
470 LET C=C+1
480 PRINT AT 11,29;C
490 GOTO 520
500 LET B=B+1
510 PRINT AT 11,3;B
520 IF B+C<>24 THEN GOTO 410
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
