MIND GAMES CODED IN 1 LINE! All of the below games fit within a single line of ZX-BASIC code. They also fit within the single screen limit so that none of the listings scroll when LIST-ed on a 48K spectrum. Load the tape then select a game from the main menu and it will load and run automatically, except for Blackjack which has to be started manually by typing 'r' i.e. RUN after loading. Click on any of the below links for relevant game documentation. The games Memory, Memory PvP, Matching Cards & Blackjack were developed by Digital Prawn & Einar Saukas. The game Simon was developed by Digital Prawn, Einar Saukas & Dr. BEEP. Memory PvP is a 2 Player game (Player versus Player). All other games are single player. Blackjack In-game screen. Program listing on 48K Spectrum. Key showing in-game features. Text Listing 1 LET n=23620: POKE PEEK 23618*n,33: RANDOMIZE : BORDER 4: PAPER 4: LET m=3: DIM c(52): FOR c=1 TO 52: LET f=.5+RND*c: LET c(c)=c(f): LET c(f)=c-1: NEXT c: DIM s(6): CLS : PRINT "$";m: LET p=1: GO SUB 1: LET p=2: GO SUB 1: GO SUB 1: POKE (s(2)>20)*n,24+3*(q=6): INPUT c$: POKE (c$>"")*n,20: LET p=1: GO SUB 1: POKE (s(1)9): RESTORE : READ c,q,s(p+4),r,t,u,l,s(p+2),s(p),v: PRINT PAPER 7; INK 2*(c(c)<4*r-6);AT p*4-1,q;" 23456789TAJQK"(r);" ";AT p*4,q;" ": RETURN : DATA c-1,s(p+4)+3,q,INT (c(c)/4)+2,s(p)+r+(10-r)*(r>11),s(p+2)+(r=11),t>21 AND u,u-l,t-10*l,s(2)<22 Credits This one-liner is loosely based on the full-size Blackjack game originally implemented by Einar Saukas & Eduardo Ito back in the 1980's. The full-size version was itself based on the well-known US-named blackjack card game, also known in the UK and some other places as 21 or Pontoon. (note:- this game is not to be confused with British Blackjack, which is known as "Crazy Eights" elsewhere). This one-liner game was a joint development between Digital Prawn and Einar Saukas. Instructions The variation of blackjack in this one-liner game first deals a single card to the dealer, and two cards to the player in each round. There is no hole-card, which makes this a European variation. The player then goes first, repeatedly deciding whether to Hit (accept a further card), or Stand (accept no more cards and finish their turn). After this, the dealer (CPU) takes its turn. To Hit, type any alphanumeric character into the INPUT prompt at the bottom of the screen, then press ENTER. To Stand, simply press ENTER at the INPUT prompt, entering an empty string. The goal of each round, as in most blackjack variations, is to reach a score as near as is possible to 21 points, without exceeding 21, in which case you would bust, losing the round. Numeric cards are worth their face value. In this game, the card "10" is represented by the character "T" to save space in the one-liner. Face Cards (Jack, Queen, King) are also worth 10. Aces are normally worth 11, except where that would cause the player to bust. In that case, one or more aces will be automatcally devalued during the round to 1 point such that the player does not bust. If the player immediatly starts the round with a blackjack (21 points in two cards), then the player automatically wins the round, without requiring any keyboard input. At the end of the round the player with the highest non-bust score wins the round. If the scores are equal then the round is a draw. The single letter indicator at the top of the screen indicates whether the human player won, lost or drew the round. In this game, the player starts with a balance of $3, and $1 is automatically gambled on each round. The goal is for the player to win a total of $10. As the player balance is not updated on the screen at the moment the game ends, the game winning condition is indicated by "$9 W" appearing at the top of the screen, and the program stopping. The game is lost if the player's cash is reduced to zero (Likewise indicated by "$1 L" appearing at the top of the screen). Technical Notes This program shows the use of GO SUB/RETURN in a one-liner program. This is achieved by taking advantage of the behaviour of the system variable NEWPPC. NEWPPC is normally set to zero when a program is initially RUN, but is automatically set to the current line number when certain statements are executed (in this case GO SUB). We take advantage of this fact to conditionally jump via NSPPC to a single subroutine in our one-liner program. The subroutine in this program is used to deal a single card. The playing cards in this game do not show the suit in order to save space in the one-liner, but cards are still correctly shown as either red (hearts and diamonds), or black (clubs and spades). Matching Cards In-game screen. Program listing on 48K Spectrum. Text Listing 1 BORDER 4: POKE 23693,33: CLS : RANDOMIZE : DIM c(53): FOR l=0 TO 51: PRINT AT INT (l/10)*3+2,3*l-30*INT (l/10);l+1: LET a=.5+RND*(l+1): LET c(l+1)=c(a): LET c(a)=1+INT (l/2): NEXT l: LET t=0: LET b=53: PRINT INVERSE 1;AT 20,0;" Lives:";l,"Score:";t;" Won!" AND t=26,: IF l*(t<26) THEN INPUT a: POKE (a<1 OR a>52 OR a=b)*23620,15: POKE (c(a)=0)*23620,15: RESTORE : READ q,r,i,y,x,w,v,m,s,c(a),c(b),b,l,t: PRINT PAPER 7; INK 2*i;AT y,x;"23456789%JQKA"(q-13*i);" ";AT y+1,x;" ": BEEP .5,24*m-12: FOR d=1 TO 150: NEXT d: PRINT AT w+m*(y+2-w),v+m*(x-v);" ";AT w+1+m,v;" ": POKE 23620,14-m: DATA c(a),c(b),q>13,3*INT (a/10-.1),3*a-10*y-3,3*INT (b/10-.1),3*b-10*w-3,q=r,m=0,s*q,s*r,a,l-s+m,t+m Instructions In this game, there is a set of shuffled playing cards hidden in a grid of 52 positions. The goal is to find all of the matching pairs of playing cards from the shuffled pack. Although the suit of each card is not directly shown, it is sufficient for this game that all hearts and diamonds cards are shown in red, whilst all clubs and spades cards are shown in black. A pair of cards is matched if their rank and colour are both the same. The player can only choose one card at a time, by inputting a number in the range 1 to 52. If the chosen card matches the previous one, both cards remain permanently on the screen, with their positional numbers removed, as they can no longer be selected again. Otherwise, the new card remains on screen, the previous card is hidden, and the player must choose again another card trying to match it with the latest one. The number of lives increases for each matched card and decreases otherwise. The game ends when either all matching pairs have been found, resulting in a winning score of 26, or all lives have been lost, losing the game. Credits The precursor to this game was a collaborative effort between Einar Saukas and Digital Prawn, originally designed as a letter based game. It was derived from an early version of Memory, but modified to allow a single selection per turn, rather than forcing two selections per turn as Memory does. All of the work converting the above letter based game into this card based game including graphics, colour changes, and further optimisations was done by Einar Saukas. Memory In-game screen. Program listing on 48K Spectrum. Text Listing 1 BORDER 0: POKE 23693,6: CLS : RANDOMIZE : DIM c(52): FOR b=0 TO 51: PRINT INK 7;AT INT (b/10)*3+1,3*b-30*INT (b/10);b+1: LET f=.5+RND*(b+1): LET c(b+1)=c(f): LET c(f)=65+INT (b/2): NEXT b: LET t=0: LET l=36: PRINT INK 5;AT 21,0;"Lives:";l,"Score:";t;" Won!" AND t=26,: LET f=f=0: IF l*(t<26) THEN INPUT STR$ b+CHR$ 6 AND f;a: POKE (a<1 OR a>52 OR a=b*f)*23620,16: POKE (c(a)=0)*23620,16: RESTORE : READ q,r,w,v,y,x,m,s,c(a),c(b),l,t,b: PRINT INVERSE m;AT w*3,v*3;CHR$ q;AT y*3,x*3;CHR$ r AND m: BEEP f/2,24*m-12: FOR d=1 TO 150*f: NEXT d: PRINT OVER f=m;AT w*3,v*3;" ";AT y*3,x*3;" ": POKE 23620,14: DATA c(a),c(b),INT (a/10-.1),a-10*w-1,INT (b/10-.1),b-10*y-1,q=r*f,m=0,s*q,s*r,l-s*f,t+m,a Instructions Your goal is to find matching pairs of hidden letters until every matched pair is found. There are 52 letters comprising of two scrambled alphabets arranged in a numbered grid. To select a pair of letters, input a pair of numbers between 1 and 52, pressing ENTER after each number. If the pair of selected letters matches then the score will increase by one, and the letters will be permanently displayed in INVERSE video. Otherwise, the number of lives will decrease by one, and the letters will be hidden again after a pause of a couple of seconds. The game ends when either there are no lives left (game lost), or all pairs have been found yielding a score of 26 points (game won). The initial number of available lives is 36, which makes the game challenging to a first time player, but not too difficult. More experienced players should focus on preserving a high number of lives on completion. Credits The development of this game (again a collaboration between Digital Prawn and Einar Saukas) has a long history of many different revisions and optimisations. The version finally settled on was due to alterations based on user feedback from World of Spectrum forum member "miskox", whose main suggestion was to show the first letter of a pair immediatly after selecting it, even before the second letter of the pair is selected. Memory PvP In-game screen. Program listing on 48K Spectrum. Text Listing 1 POKE 23693,48: CLS : RANDOMIZE : DIM c(52): DIM s(2): FOR b=0 TO 51: LET p=INT (b/10): PRINT AT p*3+2,1+3*b-30*p;b+1: LET f=.5+RND*(b+1): LET c(b+1)=c(f): LET c(f)=65+INT (b/2): NEXT b: LET p=1+(p=1): BORDER p*(b>0): INK p: PRINT AT 18+p,1;"P";p;":";s(p): LET f=f=0: IF b THEN INPUT STR$ b+CHR$ 6 AND f;a: POKE (a<1 OR a>52 OR a=b*f)*23620,18: POKE (c(a)=0)*23620,18: RESTORE : READ q,r,w,v,y,x,m,s,c(a),c(b),s(p),b: PRINT INVERSE m;AT 1+w*3,v;CHR$ q;AT 1+y*3,x;CHR$ r AND m: BEEP f/2,24*m-12: FOR d=1 TO 150*f: NEXT d: PRINT OVER f=m;AT 1+w*3,v;" ";AT 1+y*3,x;" ": POKE 23620,14-f*s: DATA c(a),c(b),INT (a/10-.1),3*a-30*w-2,INT (b/10-.1),3*b-30*y-2,q=r*f,m=0,s*q,s*r,s(p)+m,a*(s(1)+s(2)<26) Instructions In this game there are 52 letters from two shuffled alphabets hidden in a numbered grid. Two human players battle it out to try and find the greatest number of matching pairs before the game ends. Player 1 (BLUE) and Player 2 (RED) successively take turns to input a pair of numbers, revealing a hidden pair of letters. If the selected letters match, then the player's score is increased by one, the letters also remain visible on the screen in the player's own colour (INVERSE video) and the player retains control of the game, thus allowing them to select a subsequent pair of letters. Otherwise, the selected letters do not match and so they are hidden again after a couple of seconds, then control of the game passes to the opposing player. At all times during play, the BORDER colour indicates the current player (i.e. BLUE or RED). The game ends when all 26 matching pairs have been revealed, and the player with the highest score is declared the winner. The game is declared a draw if both players have the same score (i.e. 13 points each). Credits This game was developed from the single player game Memory. Modifications were made by Einar Saukas and Digital Prawn to convert that game to a two player version. This did require further optimisations from Einar to fit into the oneliner contest size limits, but overall the majority of the code remains quite similar to the single player version. Simon In-game screen. Program listing on 48K Spectrum. Text Listing 1 RANDOMIZE : LET a$="": POKE 23693,7: CLS : FOR k=1 TO 4: CIRCLE 131,84,CODE " #NR"(k): INK k: LET e=k=2 OR k=4: PRINT AT 6+10*(k>2),11+10*e;k: FOR p=-23 TO 0: PLOT 232*e-88-p,33-(k<3)*168-p: DRAW OVER 1;31,0: NEXT p: INK 8: LET a$=a$+"1234"(RND*4+.5): NEXT k: PRINT AT 10,14;"SIMON";AT 12,16;p: BORDER 0: INPUT ': FOR d=-2*PI TO 6 STEP PI/2: PLOT 131+35*SIN d+4*SGN d*COS d,84+35*COS d-4*SGN d*SIN d: DRAW 42*SIN d,42*COS d: NEXT d: FOR c=1 TO p: LET q=VAL a$(c): FOR v=1 TO 8: BEEP (v=5)/2,q*5-8-3*(q=4): PRINT AT v+4*(v<5)+9*(q>2),16*(q=2 OR q=4); OVER 1; BRIGHT v<5,: NEXT v: NEXT c: BORDER 6: FOR c=1 TO k: LET q$=INKEY$: POKE 23620,13+2*(c<=p)*(10+(q$>"0")*(q$<"5")-5*(q$=a$(c))): BEEP 1,-9 Instructions The goal of this game is to watch and listen to the sequences of flashing lights and then repeat them by pressing the numeric keys 1-4. The game starts with a sequence of one flashing light and progresses to longer sequences by adding an extra flash to the sequence on each turn. The length of the current sequence is indicated by the number in the middle of the game board. The BORDER is black whilst the CPU plays the current sequence (to be carefully observed by the player). When the sequence has finished playing, the border turns yellow to indicate the computer is ready to accept the player's input. There is no time limit on the player's input as the computer will wait indefinitely. If an incorrect button is pressed, then the game immediately ends with the board displaying the length of the current sequence that the player failed to reproduce correctly. Try to stay in the game as long as possible and you will notice that it gets considerably more difficult as the sequence gets longer. Each button has it's own unique note associated with it. More experienced players can remember the sequence as a tune, rather than as a sequence of numbers, which can help to remember longer sequences more easily. Credits This one-liner game was inspired by the well known Simon electronic game. Dr BEEP had originally made a one-liner game of this type called MUSICPLAYER and at the time of writing this is freely downloadable as part of his groundbreaking ONELINERS package from the World of Spectrum archives. The original idea to make the version on this page was sent to me by Einar Saukas, back in 2007. The initial version of this implementation was by Digital Prawn, after examining Dr. BEEP's MUSICPLAYER code. This version therefore borrows heavily from it. In particular, several of the program variables perform the same function, the random generator works in the same way. Also, the core algorthim of tune playback and user input detection works in fundamentally the same way as Dr. BEEP's original version. The initial version of the game needed many optimisations so that the graphics could be refined and the score printed onto the screen. These features could not originally be fitted into the available one-liner space. However, due to countless optimisations and refinements by Einar Saukas and Dr. BEEP, enough space was saved in order to greatly improve the game. Additional suggestions were supplied by World of Spectrum forum member "bigjon". Apart from optimisations, particular improvements were suggested by Einar Saukas (for example, the use of a black background because it works well when we use the BRIGHT attribute to flash the buttons), and also Dr. BEEP (for example, the use of PLOT and DRAW to draw the neatly shaped buttons).