LOGITrumps

Type
Game
Category
Top Trumps card game (BASIC 10-liner)
Author
Logiker
Published in
BASIC 10-liner Contest 2020 (NOMAM 2020)
Year
2020
Language
Atari BASIC
Requirements
Any 8-bit Atari with Atari BASIC (16K is plenty)

About the program

Logiker is known in the retro scene for the multi-platform BASIC challenges he organises. His 2020 ten-liner turns the playground card game Top Trumps into a duel against the computer, using a deck of eight famous home computers: the ZX80, Amiga 500, C64, C16, Apple ][, Atari 400, Amstrad CPC464 and C128. Each card has three values: the year the machine came out, its RAM in KB and its number of colours. You and the computer each start with four cards. On your turn you pick a category. If your card beats the computer's, you win its card, and if it doesn't, you lose yours. The first side to run out of cards loses. This is the "LOGITrumps Atari 800" version. The game itself is in plain Atari BASIC with no Turbo BASIC needed, which makes it a good first ten-liner to type in.

Typing it in

Every line fits within the editor's 120 characters, so you can type it exactly as listed, with one exception.

Fix line 10's name string. Line 100 cuts the machine names out of T$ in fixed six-character fields (T$(Z*6-5,Z*6)). In the surviving web transcription, runs of spaces have been collapsed to one, so the names come out garbled ("zx80 a", "500 c6"…). The game still plays, but to get readable cards, pad each name to exactly six characters when you type T$:

T$="zx80 a500 c64 c16 a][ a400 cpc464c128 "

That's zx80+2 spaces, a500+2, c64+3, c16+3, a][+3, a400+2, cpc464, then c128+2. This is a reconstruction from the slicing code, not a copy of the original disk file.

How to play

The screen shows the card counts as you:computer (both start at 4), then your top card: >name, its year, kb and cols. When it's your turn, 1-3: asks for a category: 1 = year, 2 = RAM, 3 = colours. The computer's card is then shown, along with the category in play, and you get :-) for a win or :-( for a loss. When you win you choose again. When you lose, the computer chooses: it calls colours (3) if its card has more than 16 KB of RAM, and age (1) otherwise.

Watch out for category 1. The year is stored as 1990 minus year, so the older computer wins that comparison. The Apple ][ (1977) is a strong card.

How it works

The DATA in line 90 holds year-offset, KB and colours for each machine (e.g. 3,512,4096 is the Amiga 500: 1987, 512 KB, 4096 colours). Line 30 shuffles by placing cards at random in two arrays, P() for the player and C() for the computer, which hold positions in each hand. The odd-looking P(P*X)=… assignments only take effect when the random slot was empty (X=1), because otherwise they write harmlessly to element 0. A tie changes neither hand, and both cards simply go to the back.

Variations to try

Add your own favourite machines. Extend T$ (six characters per name) and the DATA, raise the 8s in lines 20, 30 and 40, and change the deal so that each side gets half the deck. For example, an Atari 800XL card (1983, 64 KB, 256 colours) would be 7,64,256, since the first value is 1990 minus the year.

Listing

10 DIM T$(100):T$="zx80 a500 c64 c16 a][ a400 cpc464c128 ":R=4:E=4:DIM A(10,3):DIM C(10):DIM P(10)
20 ? CHR$(125);"LogiTrumps":FOR I=1 TO 8:READ X,Y,Z:A(I,1)=X:A(I,2)=Y:A(I,3)=Z:P(I)=0:C(I)=0:NEXT I:I=0:U=1:K=1
30 P=INT(RND(1)*8)+1:X= NOT (C(P)+P(P)):P(P*X)=(K)*(K<5):C(P*X)=(K-4)*(K>4):K=K+X:IF K<9 THEN GOTO 30
40 N=N+1:PP=0:CC=0:FOR I=1 TO 8:CC=CC+(C(I)=N)*I:PP=PP+(P(I)=N)*I:NEXT I:B=1+(A(CC,2)>16)*2:? R;":";E:Z=PP:GOSUB 100
50 IF U THEN ? "1-3:";:INPUT B
60 Z=CC:GOSUB 100:? B:P(PP)=N+R:C(CC)=N+E:IF A(PP,B)>A(CC,B) THEN ? ":-)":P(CC)=N+R+1:C(CC)=0:R=R+1:E=E-1:U=1
70 IF A(PP,B)<A(CC,B) THEN ? ":-(":C(PP)=N+E+1:P(PP)=0:R=R-1:E=E+1:U=0
80 IF E<>0 AND R<>0 THEN GOTO 40
90 ? "*** GAME OVER ***":END:DATA 10,1,2, 3,512,4096, 8,64,16, 6,16,121, 13,4,15, 11,8,128, 6,64,27, 5,128,16
100 PRINT ">";T$(Z*6-5,Z*6):PRINT 1990-A(Z,1):PRINT A(Z,2);" kb ":PRINT A(Z,3);" cols":RETURN

Credits