Growing Sequences
String concatenation with RND grows the sequence each round — the game gets harder until memory fails.
Until now the sequence has been hardcoded — “132” every time. Memorise it once and you win forever. A real memory game does not let you off that easily. Each round, a random colour is added to the end of the sequence. Round 1: one flash. Round 5: five flashes, all from memory. The string grows until the player’s memory gives out.
Growing the String
Replace the fixed LET s$="132" with this line at the start of each round:
82 LET s$=s$+STR$ (INT (RND*4)+1)
s$=s$+STR$(INT(RND*4)+1) does three things in one expression:
INT(RND*4)+1picks a random number from 1 to 4 — one of the four panel colours.STR$(...)converts that number to a string character.s$=s$+...appends the new character to the end of the existing sequence.
If s$ is "13" and the random number is 4, then s$ becomes "134". Each round, the string grows by one character. Round 1 has one colour. Round 5 has five. Round 10 has ten.

The Game Loop
Initialise the sequence as empty (LET s$="") and the score as zero (LET sc=0) before the first round. The flow becomes:
- Append a random colour to the sequence string.
- Play the whole sequence (FOR/NEXT through the string).
- Player repeats the whole sequence.
- If correct — increment score, display “Correct!”, GO TO step 1.
- If wrong — game over.
GO TO at the end of a successful round sends the program back to step 1. The sequence string is the entire game state — one variable holds everything the game needs to remember.
Score Tracking
LET sc=sc+1 after each completed round. Display the score on the header bar with PRINT AT 0,26; PAPER 1; INK 6;"Sc: ";sc. The score updates at the start of each round so the player always knows where they stand.
String Concatenation
s$=s$+"4" joins two strings into one. The original string stays intact and the new character goes on the end. This is called concatenation — gluing strings together. It is the same operation in most programming languages, though the symbol varies (some use . or & instead of +).
Try This
- Play a few rounds. How far can you get before your memory fails?
- Add
PRINT AT 19,1;s$to display the sequence on screen during testing. Remove it when you are done — seeing the answer ruins the game.
What You’ve Learnt
- String concatenation —
s$=s$+"4"appends a character to the end of a string - STR$ with RND —
STR$(INT(RND*4)+1)produces a random digit character “1” to “4” - Growing state — the sequence string gets longer each round; the game gets harder
- GO TO as game loop — jumping back to the start of the round creates an endless game that only stops on failure
- Score tracking —
LET sc=sc+1counts completed rounds