--- title: "Shrink" id: 70835 type: "computer_media" slug: "shrink" url: "http://localhost/computer_media/shrink/" markdown_url: "http://localhost/computer_media/shrink.md" published_at: "2026-08-23T15:08:00+00:00" modified_at: "2026-08-23T23:28:02+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/08/shrink.png" alt: "Shrink screen" excerpt: "Play patient to an AI therapist that scans your typed responses for keywords, reverses your pronouns, and fires back eerily plausible therapeutic replies." 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: "Artificial Intelligence" slug: "artificial-intelligence" taxonomy: "genre" url: "http://localhost/type/artificial-intelligence/" - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Shrink%20%28198x%29%28-%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2026/08/shrink.png" alt: "Shrink screen" media_type_tags: "Artificial Intelligence, Game" --- # Shrink Shrink is a conversational psychotherapy simulation in the style of the classic ELIZA program, where the computer plays the role of a therapist named “Dr. Timex Sinclair.” The program scans user input for 40 trigger keywords stored in a DATA array, each mapped to a corresponding response block address in array r(), then uses RESTORE to jump to that block and print one of up to five randomly selected responses. A substitution subroutine at line 400 performs pronoun reversal (e.g., “i am” → “you are”, “my” → “your”) on the portion of the user’s input following the matched keyword, inserting it into responses marked with an asterisk. The program also detects repeated input, single-character responses, and handles capitalization normalization by converting the first letter of the user’s name and lowercasing the entire input string before matching. *** ### Program Structure The program is organized into several distinct functional zones: - **Lines 5–26:** Setup — dimension and populate the response-address array `r()` from DATA, set constants. - **Lines 30–55:** Introduction screen and name input with capitalization fix. - **Lines 60–360:** Main conversation loop (up to 20 exchanges). - **Lines 370–380:** Session termination message. - **Lines 400–500:** Pronoun-substitution subroutine. - **Line 1000:** Keyword DATA (40 entries matching `kn=40`). - **Line 1500:** Unused placeholder DATA (`"f"`). - **Line 2000:** Substitution pair DATA (9 pairs, matching `sn=9`). - **Lines 3000–5400:** Response text DATA blocks, each containing 4 response strings. - **Line 9999:** SAVE command. ### Keyword Matching Engine The program stores 40 keywords at line 1000 and their corresponding BASIC DATA line addresses in array `r(kn)`. At lines 125–200, it appends a period to the user’s input, then scans it with a sliding window of width `kl` (the keyword length) checking for substring matches via `a$(j TO j+kl-1)=k$`. On a match, it saves the response block address into `k` and the position just after the keyword into `kp`, then jumps to line 300. If no keyword matches, `k` defaults to 5400 (the generic “can you be more specific” block). ### Response Selection At line 300, `RESTORE k` seeks to the matched response block. A loop then reads between 1 and 5 DATA items (`1+RND*4`), leaving `r$` holding a pseudo-randomly selected response. This gives each keyword up to four possible replies. The trailing asterisk convention (`r$(rl)="*"`) signals that the subroutine at line 400 should append transformed user text. ### Pronoun Substitution Subroutine (Lines 400–500) When a response string ends with `*`, the subroutine extracts the portion of the user’s input starting at `kp` (just past the matched keyword) into `m$`. It then applies 9 find-and-replace pairs from line 2000 DATA — such as “i am”→”you are”, “my”→”your”, ” i “→” you ” — using a manual sliding-window replacement loop (lines 445–470). The transformed string is concatenated to the response. If `kp>=l` (nothing follows the keyword), the subroutine returns immediately without appending anything. The substitution pairs in DATA at line 2000 include some asymmetric pairs and spacing anomalies. For example, `"you are","I am"` appears where the direction seems reversed, and spacing in entries like `" you."," me"` may cause partial matches in some contexts. ### Input Normalization Before keyword matching, lines 90–100 iterate through each character of the input and convert uppercase letters (ASCII 65–90) to lowercase by adding 32 to their character code. Apostrophes are stripped in-place at line 95 by splicing the string. This is done to simplify keyword matching without needing case-insensitive comparison. The user’s display name `n$` has only its first character capitalized (line 52). ### Special Cases | Condition | Line(s) | Behavior | | --- | --- | --- | | Empty input | 80 | Prompts user to speak their mind, skips to next prompt | | Input “stop” | 81 | Halts execution immediately | | Single-character input | 87 | Forces response block 5400 (generic replies) | | Repeated input | 110 | Forces response block 5000 (“you just said that…”) | | 20th question reached | 86 | Jumps to session-end message | | Response ends in “.” | 325 | Strips trailing period before printing | ### Repeat Detection `b$` is initialized to `"*"` at line 10 and updated to the current input `a$` at line 120 after the repeat check. If the normalized input matches the previous input (`a$=b$`), the program routes to response block 5000 which chastises the user for repeating themselves. The asterisk initialization ensures the first input never falsely triggers this path. ### Name Personalization Lines 330–340 append the user’s name to responses with 50% probability (`RND>0.5`), adding `", ";n$` after the response text. This gives the therapist simulation a more personal feel without requiring name insertion into every response string. ### Notable Bugs and Anomalies - Line 100 uses `IF i<>LEN a$ THEN GO TO 92` — this uses not-equal rather than less-than, which means the final character of `a$` is never processed by the normalization loop. This could leave the last character un-lowercased if it is uppercase. - Line 1500 contains `DATA "f"` with no apparent purpose. It sits between the keyword DATA and the substitution pair DATA but is never deliberately RESTOREd to by the program logic; it may be a remnant of an earlier version. - Some response strings in the DATA blocks contain multiple internal spaces (e.g., `"Do you think it is normal to want *"`), which will appear as extra spaces in the printed output. - The word “appologize” in line 3240 DATA is misspelled. - Line 95 strips apostrophes but the check occurs inside the normalization loop which stops one character before the end (per the bug in line 100), so a trailing apostrophe would survive. ## Source Code ``` 5 REM "SHRINK" 6 REM Creative GAMES,pg.38 10 LET kn=40: LET sn=9: DIM r(kn): LET b$="*" 20 FOR i=1 TO kn: READ r(i): NEXT i 25 DATA 3000,3000,3010,3010,3020,3020,3030,3030,3040,3100,3110,3120,3130,3130,3140,3150,3150,3160,3170,3170,3180,3180,3180,3180,3180,3180,3190,3190 26 DATA 3200,3200,3210,3210,3210,3210,3220,3220,3230,3230,3230,3240 30 CLS : PAPER 7: BORDER 7: INK 0 40 PRINT AT 0,0;"Welcome" 41 PRINT AT 3,0;"I am Dr. Timex Sinclair" 42 PRINT AT 6,0;"Please make yourself comfortable" 45 PRINT AT 9,0; "What is your first name?" 50 INPUT LINE n$: IF n$="" THEN PRINT ''"Please don't be shy.": GO TO 45 52 IF n$(1)>="a" THEN LET n$(1)=CHR$ (CODE n$(1)-32) 55 PRINT 'n$'' 60 PRINT "What would you like to discuss, ";n$ 70 FOR q=1 TO 20 80 INPUT LINE a$: IF a$="" THEN PRINT ''"Try to tell me what's on your mind, ";n$: GO TO 350 81 IF a$="stop" THEN STOP 85 PRINT 'a$'' 86 IF q=20 THEN GO TO 370 87 IF LEN a$=1 THEN LET k=5400: GO TO 300 90 LET i=1 92 LET ch=CODE a$(i): IF ch<=90 AND ch>=65 THEN LET a$(i)=CHR$ (ch+32) 95 IF a$(i)="'" THEN LET a$=a$(1 TO i-1)+a$(i+1 TO ) 100 LET i=i+1: IF i<>LEN a$ THEN GO TO 92 110 IF a$=b$ THEN LET k=5000: GO TO 300 120 LET b$=a$ 125 RESTORE 1000 130 LET a$=a$+".": LET l=LEN a$ 140 FOR i=1 TO kn: READ k$: LET kl=LEN k$ 170 FOR j=1 TO l-kl+1 180 IF a$(j TO j+kl-1)=k$ THEN LET k=r(i): LET kp=j+kl: GO TO 300 190 NEXT j 200 NEXT i 210 LET k=5400 300 RESTORE k: FOR i=1 TO 1+RND*4: READ r$: NEXT i 320 LET rl=LEN r$: IF r$(rl)="*" THEN GO SUB 400 325 IF r$(LEN r$)="." THEN LET r$=r$(1 TO LEN r$-1) 330 PRINT r$; 340 IF RND>0.5 THEN PRINT ", ";n$ 350 PRINT '' 360 NEXT q 370 PRINT INK 2;"Well, I'm afraid that I have"'"another client waiting, ";n$;'"I've enjoyed talking to you."'"Goodbye." 380 STOP 400 LET r$=r$( TO rl-2): IF kp>=l THEN RETURN 410 RESTORE 2000: LET m$=a$(kp TO ) 420 FOR i=1 TO sn 430 READ s$,t$ 440 LET sl=LEN s$: LET tl=LEN t$: LET j=1 445 IF j>LEN m$-sl+1 THEN GO TO 480 450 IF m$(j TO j+sl-1)=s$ THEN LET m$=m$(1 TO j-1)+t$+m$(j+sl TO ): LET j=j+tl-1 460 LET j=j+1 470 GO TO 445 480 NEXT i 490 LET r$=r$+m$ 500 RETURN 1000 DATA "do you","dont you","can you","cant you","do i","dont i","can i","cant i","i feel","i think","am i","are you","i cannot","i can't","i can","im","i am","i want","because","so that","who","why","when","where","how","what","kill","hit ","die","dead","ts2068","ts","compu","key","tv","telev"," off","stop","shut ","sorry" 1500 DATA "f" 2000 DATA "i am","you are","you are","I am"," you."," me","you ","I "," me."," you"," i "," you "," am "," are "," my","your","your","my" 3000 DATA "Why do you ask whether I *","Sometimes I do *","Would you like me to *","No I do not *" 3010 DATA "Would you like me to *","Can you *","Do you think i can *","Why do you ask this" 3020 DATA "Perhaps you do *","Would you like to *","What answer would you like","Do you think you will *" 3030 DATA "Do you want to *","Would you like to be able to *","Is it normal to *","Have you asked anyone else this" 3040 DATA "Please explain these feelings","Do you like feeling this way","Do you often feel *" 3100 DATA "Are you sure","Why do you think *","You seem uncertain","What makes you think *" 3110 DATA "Do you want to be *","I think you may be *","Do you often ask yourself this","Is this important to you" 3120 DATA "I would prefer not to say","Tell me whether you are *","Do you like to think that I am *","Perhaps you think I am *" 3130 DATA "Why cant you","Are you sure you cant *","Would you like to *","Is this normal for you" 3140 DATA "Can you really","Can your friends *","Do you like being able to *","Can you always *" 3150 DATA "Have you always been *","Do you dream about being *","Do you want me to be *","Do you enjoy being *" 3160 DATA "Why do you want *","How long have you wanted this","Do you think it is normal to want *","How much do you want this" 3170 DATA "Is this the only reason","Are there other reasons","Is this really why","Do you believe this is the real reason" 3180 DATA "Let's forget that. Why are you asking questions","How would you like me to answer that","Does the question worry you","Do you want to sit in my chair" 3190 DATA "Do you like violence","Do you have violent fantasies","Please calm yourself","I have a pistol in my drawer" 3200 DATA "Does death interest you","Do you like graveyards","Do you have morbid dreams","Are you often morbid" 3210 DATA "Do you like computers","Are you frightened of machines","What do you do when you are not here","What color are computers in your dreams" 3220 DATA "Are you keen on TV","Do you find TV boring","Is your TV big","Would you prefer to be watching Bizarre" 3230 DATA "I will ignore that","Your time is not yet up","Do you like being aggressive","I am trained to be tolerant" 3240 DATA "Thats OK","Don't appologize","Why are you sorry","Not at all" 5000 DATA "You just said that","You are repeating yourself","Why do you repeat yourself","Please dont repeat yourself" 5400 DATA "Can you be more specific","I see - go on","That is interesting","Do you feel happy about this discussion" 9999 SAVE "SHRINK" ```