Lemonade

Date: 1982
Type: Program
Platform(s): TS 1000
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

ArraySizePurpose
M(P)PEach player’s money balance
A(P)PAdvertising boards purchased
R(P)PDeclared but never used
L(P)PPrice per glass in pence
B(P)PBottles purchased
Q(P)PGlasses available (bottles × 10)
I(P)PDeclared but never used
S(P)PGlasses 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.

Content

Appears On

Related Products

Related Articles

The children are screaming, the sun is roasting, it is a perfect day for the beach. You are the budding...

Related Content

Image Gallery

Lemonade

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
\n1000 LET Q(C)=B(C)*10
\n1010 NEXT C
\n1020 FOR C=1 TO P
\n1030 LET I=V*10
\n1040 LET S(C)=I/L(C)
\n1050 IF L(C)>30 AND L(C)<=50 THEN LET S(C)=INT (RND*(V/(V-2)))
\n1060 IF L(C)>50 THEN LET S(C)=0
\n1070 LET Z=RND*A(C)*5
\n1080 LET S(C)=S(C)+(Z*2)
\n1085 LET S(C)=INT (S(C)*0.75)
\n1090 NEXT C
\n1095 LET N=0
\n1100 FOR O=1 TO P
\n1110 LET N=N+S(O)
\n1120 NEXT O
\n1130 IF N>V THEN LET M=N-V
\n1140 IF N>V THEN LET M=INT (M/P)
\n1150 IF N>V THEN FOR Y=1 TO P
\n1160 IF N>V THEN LET S(Y)=S(Y)-M
\n1170 IF N>V THEN NEXT Y
\n1180 FOR H=1 TO P
\n1190 IF S(H)>Q(H) THEN LET S(H)=Q(H)
\n1195 IF S(H)<0 THEN LET S(H)=0
\n1196 IF S(H)>V THEN LET S(H)=V
\n1200 NEXT H
\n1210 FOR J=1 TO P
\n1220 PRINT "L   E   M   O   N   A   D   E"
\n1230 PRINT "\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''"
\n1241 LET MY=INT (S(J)*L(J))/100
\n1242 LET M(J)=M(J)+MY
\n1250 PRINT ,,,,"%P%L%A%Y%E%R ";J;"      %M%O%N%E%Y £";M(J);"   "
\n1260 PRINT ,,,,"%Y%O%U% %S%O%L%D ";S(J);" %G%L%A%S%S%E%S"
\n1265 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)
\n1266 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"
\n1267 PRINT ,,,,"%A%D%V%E%R%T%I%S%E%M%E%N%T%S ";A(J)
\n1270 PRINT ,,,,"%P%R%O%F%I%T £";MY-BP*B(J)-AP*A(J)
\n1280 FOR U=1 TO 100
\n1290 NEXT U
\n1300 CLS 
\n1310 NEXT J
\n1320 NEXT E
\n1329 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%)
\n1330 REM GOSUB 10
\n1335 PRINT AT 5,19;
\n1340 FOR U=1 TO P
\n1345 PRINT TAB 19;"%P%L%A%Y%E%R ";CHR$ (U+156)
\n1350 PRINT TAB 21;"£";M(U)
\n1360 PRINT 
\n1365 PRINT 
\n1370 NEXT U
\n1380 PRINT AT 3,0;"ANOTHER GAME (Y OR N) ?"
\n1390 LET X$=INKEY$
\n1400 IF X$="Y" THEN GOTO 330
\n1410 IF X$="N" THEN STOP 
\n1420 GOTO 1390
\n8998 SAVE "LEMONADE"
\n8999 RUN 
\n9000 CLS 
\n9010 PRINT "   L  E  M  O  N  A  D  E"
\n9020 PRINT ,,,,,,"THE OBJECT OF THIS GAME IS TO   MAKE AS MUCH MONEY (£) AS       POSSIBLE."
\n9025 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."
\n9030 PRINT "YOU CAN ALSO ADVERTISE YOUR     LEMONADE BUT IT ALL COSTS MONEY."
\n9040 PRINT AT 21,0;"PRESS ANY KEY"
\n9050 IF INKEY$="" THEN GOTO 9050
\n9060 GOTO 330
\n9500 FOR F=1 TO 5
\n9510 NEXT F
\n9520 RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top