--- title: "Lemonade" id: 60602 type: "computer_media" slug: "lemonade-2" url: "http://localhost/computer_media/lemonade-2/" markdown_url: "http://localhost/computer_media/lemonade-2.md" published_at: "2025-09-23T18:59:40+00:00" modified_at: "2026-04-03T07:58:00+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2025/09/lemonade-stand.png" excerpt: "A four-player lemonade-stand trading game where daily weather, pricing strategy, and advertising spend combine to determine who turns the biggest profit over 14 days." 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 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Lemonade%20%281982%29%28N%20Beer%29%28TS1000%29%28US%29%28Program%29.zip" mediadate: "1982" images: - url: "http://localhost/wp-content/uploads/2025/09/lemonade-stand.png" article_media: - id: 8619 title: "Program Printout: Lemonade" type: "article" url: "http://localhost/article/program-printout-lemonade/" media_type_tags: "Game" --- Lemonade is a multi-player business simulation game for two to four players, spanning up to 14 days of trading. Each day, players manage a lemonade stall at “Lemondsville,” purchasing advertising boards and bottles of lemonade, then setting a price per glass, with weather (sunny, rainy, or snowy) affecting visitor numbers and hence potential sales. Sales are computed using a demand formula influenced by price, visitor count, advertisement spend, and a random factor, with a market-sharing adjustment applied when total demand across players exceeds visitor numbers. End-of-game standings are displayed using CHR$(U+156) to print UDG characters as player tokens. *** ## Program Structure The program is organised into three broad sections: 1. **Initialisation (lines 278–531):** Title display, optional instructions branch, player and day count input, and array allocation/reset. 2. **Main game loop (lines 532–1320):** Outer loop over days (`E`), inner loop over players (`F`) for purchasing decisions, followed by sales calculation and reporting loops. 3. **End-of-game and utilities (lines 1329–9520):** Final scoreboard, replay prompt, SAVE/RUN lines, instructions subroutine, and a stub subroutine at 9500. ## Array Declarations | Array | Size | Purpose | | --- | --- | --- | | `M(P)` | P | Each player’s money balance | | `A(P)` | P | Advertising boards purchased | | `R(P)` | P | Declared but never used | | `L(P)` | P | Price per glass in pence | | `B(P)` | P | Bottles purchased | | `Q(P)` | P | Glasses available (bottles × 10) | | `I(P)` | P | Declared but never used | | `S(P)` | P | Glasses sold this day (re-DIM’d each day at line 980) | Notably, `R(P)` and `I(P)` are allocated but never written or read during play, wasting a small amount of memory. ## Sales Demand Model The core economic simulation at lines 1030–1085 works as follows: - Base demand: `S(C) = (V*10) / L(C)` — inversely proportional to price. - If price is between 31 and 50 pence, demand is replaced with a small random fraction of visitors, sharply reducing sales. - If price exceeds 50 pence, demand is forced to zero. - Advertising bonus: `Z = RND * A(C) * 5`, then `S(C) += Z*2`. - A 75% efficiency factor is applied: `S(C) = INT(S(C) * 0.75)`. After individual demands are computed, lines 1130–1170 implement a market-sharing mechanism: if total demand across all players exceeds visitor count, the surplus (divided evenly) is subtracted from each player’s sales. This is a simple but effective way to model competition. Sales are then capped at the player’s available glasses (`Q(H)`), clamped to zero if negative, and also capped at total visitors (`V`). ## Weather System Each day, `W = INT(RND*4)` selects a weather type. Values 0 and 3 both map to “SUNNY”, giving it a 50% probability, while “RAIN” and “SNOW” each have 25%. The base visitor count `G` is set to 175, 75, or 10 respectively. Actual visitors are `V = INT(RND*50) + G`, adding up to 49 random visitors on top. ## Pricing and Cost Variables Each day, advertising board cost (`AP`) and bottle cost (`BP`) are randomised: - `AP = INT(RND*3)+1` — £1, £2, or £3 per board. - `BP = INT((RND*4)+1)*0.5` — £0.5, £1.0, £1.5, or £2.0 per bottle. Each bottle yields 10 glasses. Money is deducted at input time (lines 680, 775) and earned at end-of-day based on `INT(S(J)*L(J))/100` (converting pence to pounds). The profit display on line 1270 correctly subtracts bottle and advertising costs from revenue. ## Notable Techniques and Idioms - **Busy-wait delays:** Lines 540–541, 840–850, 950–960, 1280–1290 use empty `FOR`/`NEXT` loops (up to 125 iterations) as timing delays — a standard Sinclair BASIC technique. - **INKEY$ polling:** Lines 290–320 and 1390–1420 use the poll-and-branch pattern for single-keypress input without pressing ENTER. - **Re-dimensioning inside a loop:**`DIM S(P)` at line 980 is called inside the day loop, which reinitialises the array to zero each day — a deliberate reset technique. - **CHR$(U+156):** Line 1345 uses `CHR$(U+156)` to print UDG characters A–D as player identifiers on the scoreboard (UDG “A” = CHR$ 144, but 1+156=157 = UDG “n”, suggesting an off-by-one; with U=1 to 4, this gives CHR$ 157–160). - **`INT ABS L(F)` at line 820:** Sanitises the price input to a non-negative integer, preventing negative pricing exploits. - **Scalar variable `I` shadows array `I(P)`:** Line 1030 uses plain `I` (not `I(C)`) as a temporary, which is legal but potentially confusing given the array of the same letter. ## Source Code ``` 278 PRINT "L E M O N A D E" 279 PRINT "-----------------------------" 280 PRINT AT 10,0;"DO YOU REQUIRE INSTRUCTIONS ? (Y/N)" 290 LET A$=INKEY$ 300 IF A$="Y" THEN GOTO 9000 310 IF A$="N" THEN GOTO 330 320 GOTO 290 330 CLS 340 PRINT AT 10,0;"HOW MANY PLAYERS (2-4) ?" 350 INPUT P 360 IF P<2 OR P>4 THEN GOTO 350 361 CLS 362 PRINT AT 10,0;"HOW MANY DAYS DO YOU WANT TO PLAY (MAX=14) ?" 363 INPUT AD 364 IF AD<1 OR AD>14 THEN GOTO 363 369 CLS 370 DIM M(P) 380 DIM A(P) 390 DIM R(P) 395 DIM L(P) 400 DIM B(P) 410 DIM Q(P) 420 DIM I(P) 430 FOR F=1 TO P 440 LET M(F)=25 470 LET A(F)=0 500 LET R(F)=0 530 LET B(F)=0 531 NEXT F 532 FOR E=1 TO AD 533 PRINT "L E M O N A D E %D%A%Y ";E;AT 2,0;"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''" 534 LET W=INT (RND*4) 535 IF W=0 OR W=3 THEN LET W$="%S%U%N%N%Y" 536 IF W=1 THEN LET W$="%R%A%I%N" 537 IF W=2 THEN LET W$="%S%N%O%W" 538 PRINT AT 10,10;W$ 539 PRINT AT 15,0;"LEMONDSVILLE WEATHER REPORT" 540 FOR U=1 TO 100 541 NEXT U 551 LET AP=INT (RND*3)+1 552 LET BP=INT ((RND*4)+1)*0.5 553 FOR F=1 TO P 560 CLS 570 PRINT "L E M O N A D E" 571 PRINT ,,"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''" 580 PRINT ,,,,,,"%P%L%A%Y%E%R ";F 590 PRINT ,,,,"%M%O%N%E%Y £";M(F) 600 PRINT ,,,,"%A%D%V%E%R%T%I%S%E%M%E%N%T%S ? EACH BOARD COSTS £";AP 610 INPUT A(F) 660 PRINT AT 12,15;A(F) 670 PRINT AT 13,0;" " 680 LET M(F)=M(F)-(A(F)*AP) 690 PRINT AT 9,7;M(F);" " 700 PRINT AT 15,0;"%B%O%T%T%L%E%S ? EACH BOTTLE MAKES 10 GLASSES" 710 PRINT "BOTTLES COST £";BP 720 INPUT B(F) 770 PRINT AT 15,8;B(F) 775 LET M(F)=M(F)-(B(F)*BP) 790 PRINT AT 9,7;M(F);" " 800 PRINT AT 16,0;" %P%R%I%C%E% %O%F% %L%E%M%O%N%A%D%E% %P%E%R% %G%L%A%S%S ? IN PENCE" 810 INPUT L(F) 820 LET L(F)=INT ABS L(F) 830 PRINT AT 18,28;L(F);"P" 835 PRINT AT 19,0;" " 840 FOR T=1 TO 100 850 NEXT T 860 NEXT F 870 IF W$="%S%U%N%N%Y" THEN LET G=175 880 IF W$="%R%A%I%N" THEN LET G=75 890 IF W$="%S%N%O%W" THEN LET G=10 900 CLS 910 PRINT "L E M O N A D E %D%A%Y ";E 920 PRINT ,,"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''" 921 PRINT AT 6,9;W$ 925 LET V=INT (RND*50)+G 930 PRINT AT 6,9;W$ 940 PRINT AT 10,0;"TODAY THERE WERE ";V;" VISITORS" 950 FOR U=1 TO 125 960 NEXT U 970 CLS 980 DIM S(P) 990 FOR C=1 TO P 1000 LET Q(C)=B(C)*10 1010 NEXT C 1020 FOR C=1 TO P 1030 LET I=V*10 1040 LET S(C)=I/L(C) 1050 IF L(C)>30 AND L(C)<=50 THEN LET S(C)=INT (RND*(V/(V-2))) 1060 IF L(C)>50 THEN LET S(C)=0 1070 LET Z=RND*A(C)*5 1080 LET S(C)=S(C)+(Z*2) 1085 LET S(C)=INT (S(C)*0.75) 1090 NEXT C 1095 LET N=0 1100 FOR O=1 TO P 1110 LET N=N+S(O) 1120 NEXT O 1130 IF N>V THEN LET M=N-V 1140 IF N>V THEN LET M=INT (M/P) 1150 IF N>V THEN FOR Y=1 TO P 1160 IF N>V THEN LET S(Y)=S(Y)-M 1170 IF N>V THEN NEXT Y 1180 FOR H=1 TO P 1190 IF S(H)>Q(H) THEN LET S(H)=Q(H) 1195 IF S(H)<0 THEN LET S(H)=0 1196 IF S(H)>V THEN LET S(H)=V 1200 NEXT H 1210 FOR J=1 TO P 1220 PRINT "L E M O N A D E" 1230 PRINT "''''''''''''''''''''''''''''''''''''''''''''''''''''''''''" 1241 LET MY=INT (S(J)*L(J))/100 1242 LET M(J)=M(J)+MY 1250 PRINT ,,,,"%P%L%A%Y%E%R ";J;" %M%O%N%E%Y £";M(J);" " 1260 PRINT ,,,,"%Y%O%U% %S%O%L%D ";S(J);" %G%L%A%S%S%E%S" 1265 PRINT ,,,,"%Y%O%U% %H%A%D% %E%N%O%U%G%H% %L%E%M%O%N%A%D%E% %F%O%R ";Q(J) 1266 PRINT ,,,,"%P%R%I%C%E% %O%F% %L%E%M%O%N%A%D%E% %P%E%R% %G%L%A%S%S ";L(J);"P" 1267 PRINT ,,,,"%A%D%V%E%R%T%I%S%E%M%E%N%T%S ";A(J) 1270 PRINT ,,,,"%P%R%O%F%I%T £";MY-BP*B(J)-AP*A(J) 1280 FOR U=1 TO 100 1290 NEXT U 1300 CLS 1310 NEXT J 1320 NEXT E 1329 REM %T%H%E% %N%E%X%T% %L%I%N%E% %D%O%E%S% %N%O%T% %M%A%K%E% %S%E%N%S%E%,% %S%O% %I% %H%A%V%E% %D%I%S%A%B%L%E%D% % %I%T%.% % % % % % % % % % % % % % % % % % % % % % % %(%J%I%M%G%) 1330 REM GOSUB 10 1335 PRINT AT 5,19; 1340 FOR U=1 TO P 1345 PRINT TAB 19;"%P%L%A%Y%E%R ";CHR$ (U+156) 1350 PRINT TAB 21;"£";M(U) 1360 PRINT 1365 PRINT 1370 NEXT U 1380 PRINT AT 3,0;"ANOTHER GAME (Y OR N) ?" 1390 LET X$=INKEY$ 1400 IF X$="Y" THEN GOTO 330 1410 IF X$="N" THEN STOP 1420 GOTO 1390 8998 SAVE "LEMONADE" 8999 RUN 9000 CLS 9010 PRINT " L E M O N A D E" 9020 PRINT ,,,,,,"THE OBJECT OF THIS GAME IS TO MAKE AS MUCH MONEY (£) AS POSSIBLE." 9025 PRINT "YOU OWN A STALL NEAR A BEACH IN THE RESORT OF LEMONDSVILLE. YOU SELL LEMONADE AND TRY TO MAKE A PROFIT. TO START WITH YOU HAVE £25 TO BUY LEMONADE FROM THE WHOLESALER." 9030 PRINT "YOU CAN ALSO ADVERTISE YOUR LEMONADE BUT IT ALL COSTS MONEY." 9040 PRINT AT 21,0;"PRESS ANY KEY" 9050 IF INKEY$="" THEN GOTO 9050 9060 GOTO 330 9500 FOR F=1 TO 5 9510 NEXT F 9520 RETURN ```