--- title: "Concentration" id: 64780 type: "computer_media" slug: "concentration-2" url: "http://localhost/computer_media/concentration-2/" markdown_url: "http://localhost/computer_media/concentration-2.md" published_at: "2026-03-08T00:50:03+00:00" modified_at: "2026-03-30T21:41:32+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/03/Concentration-1.png" excerpt: "A one-player Concentration card game with all 52 cards laid out in a numbered grid, UDG suit symbols in red and black, and a turn counter tracking efficiency to the final pair." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_contents: - id: 64715 title: "Miscellaneous Programs" type: "computer_media" url: "http://localhost/computer_media/miscellaneous-programs/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/03/Concentration-1.png" - url: "http://localhost/wp-content/uploads/2026/03/Concentration-2.png" media_type_tags: "Game" --- # Concentration A one-player Concentration card game using a full 52-card deck. Cards are arranged face-down in a 10×5 grid (plus two extras), each identified by a position number from 1 to 52. On each turn the player enters two positions; matching card values are removed and the pair count increments, while non-matching cards are re-covered after a brief pause. Four UDG suit symbols — Hearts, Clubs, Diamonds, Spades — are defined and printed in red or black according to the card’s suit. The green PAPER 4 background simulates a card table, framed by a PLOT/DRAW border. Matching is by face value only, yielding 26 pairs across 13 ranks; the game ends when all pairs are found and reports the total number of turns taken. *** **UDG definitions (lines 20–30):** Four suit symbols are defined by POKEing 8 bytes each into named UDG slots: | Letter | Suit | UDG char | | --- | --- | --- | | H | Hearts | \h (151) | | C | Clubs | \c (146) | | D | Diamonds | \d (147) | | S | Spades | \s (162) | Line 60 stores the corresponding `CHR$` codes in array `S()` using `CODE S$(I)+79` — an elegant trick to convert the ASCII letter to its UDG character code without needing a lookup table. **Deck and shuffle (lines 70–90):** `C()` is filled 1–52, then shuffled by swapping each card with a random position across the full 52 (a slightly biased but functionally adequate algorithm). Suit `T(I)` and value `V(I)` are decoded from card number: suit = `INT((C(I)-1)/13)+1`, value = remainder within that suit group. Value string `V$="A23456789TJQK"` maps values 1–13 to display characters. **Grid layout (subroutine 390):** Card positions are determined by treating N as a two-digit number: tens digit → screen row (`L1=1+3*X10`), units digit → column (`C1=3*X1-2`), with a correction for units=0 (card 10, 20, etc.). This produces a grid of 10 cards per row across 5 full rows, with cards 51–52 in a partial sixth row. **Background (lines 100–120):** Line 100 prints a green (PAPER 4) tiled `██` pattern to simulate a card table baize. Line 120 overlays a white (PAPER 7) bordered play area using PLOT/DRAW — seven line segments forming a rectangle. **Card reveal (subroutine 340):** Displays value character and suit UDG in two rows. Ink color is determined by suit parity: odd suits (Hearts=1, Diamonds=3) get INK 2 (red); even suits (Clubs=2, Spades=4) get INK 0 (black). A box is drawn around the revealed card using PLOT/DRAW. Matching is by value only — any two cards sharing the same face value (e.g. any two Queens) form a valid pair regardless of suit, giving 4 cards of each value and 26 possible pairs in the deck. **Cover (subroutine 440):** Re-covers a card with INVERSE 1; N. For single-digit N, appends a `█` block to maintain consistent 2-character width. **Game loop (lines 140–300):** Prompts for two positions with input validation (integer, 1–52, not already matched, not the same card twice). On a correct match, `V(P1)` and `V(P2)` are set to 0 (the “already paired” sentinel). On a mismatch, both cards are re-covered after a pause. Choice and pair counts are updated after each turn. At 26 pairs the game congratulates the player and offers a restart. ## Source Code ``` 10 PAPER 7: INK 0: FLASH 0: BORDER 7: CLS 20 FOR I=1 TO 4: READ X$: FOR J=0 TO 7: READ X: POKE USR X$+J,X: NEXT J: NEXT I 30 DATA "H",34,119,127,127,62,62,28,8,"C",28,28,8,107,127,107,8,8,"D",8,28,62,127,62,28,8,0,"S",8,28,62,127,127,127,107,8 40 LET S$="HCDS": LET V$="A23456789TJQK" 50 DIM C(52): DIM T(52): DIM V(52): DIM S(4) 60 FOR I=1 TO 4: LET S(I)=CODE S$(I)+79: NEXT I 70 FOR I=1 TO 52: LET C(I)=I: NEXT I 80 FOR I=1 TO 52: LET R=INT (52*RND)+1:: LET Z=C(I): LET C(I)=C(R): LET C(R)=Z: NEXT I 90 FOR I=1 TO 52: LET T(I)=INT ((C(I)-1)/13)+1: LET V(I)=C(I)-13*(T(I)-1): NEXT I 100 PAPER 4: PRINT TAB 31: FOR I=1 TO 5: FOR J=1 TO 2: PRINT " ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ": NEXT J: PRINT TAB 31: NEXT I 110 PRINT " ██ ██ "'" ██ ██ ": PRINT TAB 7 120 PAPER 7: PLOT 0,175: DRAW 0,-151: DRAW 55,0: DRAW 0,24: DRAW 192,0: DRAW 0,127: DRAW -247,0 130 FOR N=1 TO 52: GO SUB 390: PRINT AT L1,C1; INVERSE 1;N: NEXT N 140 LET CH=0: LET PR=0: PRINT AT 16,8;"CHOICES: 0 PAIRS: 0" 150 PRINT AT 18,8,,: INPUT "ENTER FIRST LOCATION: =";P1 160 IF P1<>INT P1 OR P1>52 OR P1<1 THEN INPUT "INVALID - REENTER (1)=";P1: GO TO 160 170 IF V(P1)=0 THEN INPUT "ALREADY PAIRED -REENTER (1)=";P1: GO TO 160 180 LET N=P1: GO SUB 390: GO SUB 340 190 INPUT "ENTER SECOND LOCATION: =";P2 200 IF P2<>INT P2 OR P2>52 OR P2<1 THEN INPUT "INVALID - REENTER =";P2: GO TO 200 210 IF V(P2)=0 THEN INPUT "ALREADY PAIRED -REENTER =";P2: GO TO 200 220 IF P1=P2 THEN INPUT "PAIR MUST BE SEPARATE - REENTER ";P2: GO TO 200 230 LET N=P2: GO SUB 390: GO SUB 340 240 LET CH=CH+1: PRINT AT 16,17;CH 250 IF V(P1)<>V(P2) THEN GO TO 290 260 PRINT AT 18,8; INK 1;"Correct Choice!": LET V(P1)=0: LET V(P2)=0: LET PR=PR+1: PRINT AT 16,28;PR: BEEP .5,25: BEEP .5,15 270 IF PR=26 THEN PRINT AT 20,0;"YOU HAVE FINISHED AFTER ";CH;"TURNS": BEEP .5,20: BEEP .5,25: BEEP .5,20: GO TO 310 280 GO TO 300 290 PRINT AT 18,8;"DO NOT MATCH ": BEEP 1,-15: PAUSE 150: GO SUB 440: LET N=P1: GO SUB 390: GO SUB 440 300 GO TO 150 310 PAUSE 150: INPUT "PRESS 1 TO REPETE OR 0 TO STOP "; LINE Z$ 320 IF Z$="1" THEN RUN 330 STOP 340 PAPER 7: LET VN=V(N): LET SN=T(N): INK 2-(SN=2*INT (SN/2))*2 350 PRINT AT L1,C1;V$(VN);" ";AT L1+1,C1;" ";CHR$ S(SN) 360 INK 0 370 PLOT C1*8-1,176-8*L1: DRAW 17,0: DRAW 0,-17: DRAW -17,0: DRAW 0,17 380 BEEP 1,5: RETURN 390 LET X10=INT (N/10): LET X1=N-10*X10 400 IF X1=0 THEN LET X10=X10-1: LET X1=10 410 LET L1=1+3*X10 420 LET C1=3*X1-2 430 RETURN 440 PRINT AT L1,C1; INVERSE 1;N;: IF N<10 THEN PRINT "█" 450 PRINT AT L1+1,C1;"██": RETURN 9000 SAVE "CONC" LINE PI ```