17

Derby


Another old favourite, especially when a group of friends congregate and shout themselves hoarse cheering on their fancied nag. Up to six can play, each starting with £100. The 'meet' starts a 2.00 pm and goes on until 6.00 pm, with a race every 15 minutes' game time, stopping sooner if any player runs out of cash. There is a pool of 20 horses, each with its own handicap. Only six horses are randomly selected out of the pool, so the possible permutations of horses running against each other are enormous. In addition, after every race the winning horse has its handicap increased - as per Jockey Club rules - while the others have theirs reduced. Similarly, Honest Joe the bookie will shorten the odds on winning horses and lengthen them on losers. The result is that it is a good test of judgement and skill at picking winners.
   The first screen gives the title and asks for the number of players. The second screen seeks each player's name and then we move into the game loop, which consists of three more screens. The first is the Honest Joe. We are given the number of six horses, their names and odds, each player in turn is asked for his or her bet - the number of the horse backed and the amount.
   The next screen is the race proper, and comprises four broad bands of green representing sections of the course. For verisimilitude we add posts and rails, a winning post and the start line, behind which we see the six horses and riders. On pressing RETURN, the names disappear and six horses race forward. As they reach the right edge of one section, they appear at the left edge of the one above, continuing in this way until one reaches the finish. The name of the winning horse is thrown on the screen and the action is frozen while players argue, if they feel like it - although it won't do them any good!
   The final screen addresses each player by name and gives news of what happened to their bet and their current cash state. If all have cash the game time is advanced and we return to Honest Joe Bloggs to place bets for the next race.
   Line 20 redefines a graphics character for horse and rider. The next lines prepare for coloured print, print the title and get the number of players, with line 140 DIMensioning the appropriate arrays. Line 200 prints requests to players in differentiating colours - a further aid to identification - and the next lines assign starting handicaps for each horse.
   Line 320 prepares the next screen, with Joe Bloggs's billboard header. Lines 250 to 310 have picked the six horses running and ensured that there are no duplicates; now we have a printout. Player's bets are accepted and checked and on line 600 we start to print the course. This is done by redefining the graphics area and clearing it to background green four times before drawing the rails, etc., on top. It will be remembered that CHR$224 has been redefined as the horse-and-rider graphic symbol; it is seen that the horses are placed in position in line 710, with the next lines printing the name by the side of each. The fearsome lines 880, 900 and 920 do the calculations to ensure that the correct horse graphic is alternately rubbed out and redrawn in its new position. The idea to grasp here is that the calculations are based upon a totally linear course, progressing from value 0 to 4888, and that dividing its linear position by 1279 gives the displayed row or portion of the course.

Variables

D$Start of line, yellow on blue
E$Ditto, red on blue
F$Spaces for clearance purposes
X%General counter
PL%Number of players
P%(PL%,2)Players' cash and bets
P$(PL%)Players' names
H%(20,2)Horses' handicaps and odds (Pool)
R%(6,3)Ditto (in current race), plus position
H$(20)Horses' names
HR%Game time; hour
MIN%Game time; minutes
P%Current player being addressed
Q$Dummy
X%General counter
Z%Ditto, used when checking against duplicates
W%Ditto, used when getting wager
H%Horse being bet on
T%Position of current horse
W%Number of winning horse
SP%Odds (starting price) of winner

   10 REM - Derby
   20 VDU23,224,8,24,26,127,188,36,66,129
   30 MODE7:S$=STRING$(30," ")
   40 D$=CHR$132+CHR$157+CHR$131
   50 E$=CHR$132+CHR$157+CHR$129
   60 F$=STRING$(10," ")+STRING$(10,CHR$8)
   70 FORX%=5 TO 15 STEP 10
   80 PRINTTAB(0,X%);CHR$129;STRING$(19,"Oo"):NEXT
   90 PROCDBL(12,9,137,"DERBY DAY")
  100 REPEAT
  110 PRINTTAB(0,17);"How many players (1-6)";:PL%=GET-48
  120 PRINT;PL%
  130 UNTIL PL%>0 AND PL%<7
  140 DIM P%(PL%,2),P$(PL%),H%(20,2),R%(6,3),H$(20)
  150 CLS:FORX%=1 TO 20:READ H$(X%):NEXT
  160 HR%=2:MIN%=0
  170 PRINT'''"Please input your names -"
  180 FOR P%=1 TO PL%
  200 PRINT'CHR$(P%MOD7+128);"Player #";P%;"...";
  210 INPUT P$(P%):P%(P%,0)=100
  220 NEXT:INPUT'''"Press RETURN...",Q$
  230 FOR X%=1 TO 20
  240 H%(X%,1)=RND(5)+3:H%(X%,2)=RND(3):NEXT
  250 FOR X%=1 TO 6
  260 Y%=RND(20)
  270 FOR Z%=1 TO X%-1
  280 IF Y%=R%(Z%,0) GOTO260 ELSE NEXT Z%
  290 R%(X%,0)=Y%:R%(X%,1)=H%(Y%,1)
  300 R%(X%,2)=H%(Y%,2):R%(X%,3)=0
  310 NEXT X%
  320 MODE7
  330 PRINTD$'D$;
  340 PRINT"H O N E S T    J O E   B L O G G S"
  350 PRINTD$'E$'E$;
  360 PRINT"******   M I C R O M E E T   ******"
  370 PRINTE$
  380 PRINTE$;" RUNNERS AND PRICES FOR  ";HR%;":";MIN%;" pm."
  390 PRINTE$
  400 FOR X%=6 TO 1 STEP -1
  410 VDU130,157,132:PRINT"No.";R%(X%,0);
  420 PRINTTAB(8);H$(R%(X%,0));TAB(27);R%(X%,1);" to 1"
  430 NEXT
  440 FOR W%=1 TO PL%
  450 PRINTTAB(0,15):FOR X%=1 TO 8:PRINTS$:NEXT
  460 REPEAT:PRINTTAB(0,15);P$(W%);" -"
  470 PRINT'"You have £";P%(W%,0)
  480 PRINT"How much do you bet";F$;
  490 INPUTP%(W%,1)
  500 UNTIL P%(W%,1)<=P%(W%,0) AND P%(W%,1)>0
  510 PRINTTAB(0,19);"On which number horse";F$;
  520 INPUT H%:X%=1
  530 IF R%(X%,0)=H% GOTO560
  540 X%=X%+1:IF X%<=6 GOTO530
  550 PRINT'"Horse #";H%;" not running.":GOTO510
  560 RESTORE:FORZ%=1TOH%:READH$:NEXT
  570 PRINT'"£";P%(W%,1);" on ";H$;" accepted."''
  580 INPUT"Press RETURN...",Q$
  590 P%(W%,2)=H%:NEXT W%
  600 REM - Prepare course
  610 MODE2:VDU18,0,130,16,18,0,132,0,0,0
  620 VDU24,0;232;1279;276;16,24,0;490;1279;534;16
  630 VDU24,0;748;1279;794;16,26,19,13,0,0,0,0
  640 REM - Finishing post and rails
  650 GCOL0,7:MOVE 1120,794:DRAW 1120,1023
  660 COLOUR1:COLOUR 130:PRINTTAB(17,0);"o"
  670 FORX%=232 TO 1002 STEP 258:PROCFENCE(X%):NEXT
  680 REM - Starting gate line-up
  690 MOVE 66,0:DRAW 66,232
  700 VDU5,18,4,0
  710 FOR X%=1 TO 6:MOVE 0,32*X%+32:PRINTCHR$224:NEXT:VDU4
  720 FOR X%=1TO6:RESTORE
  730 FOR Y%=1 TO R%(X%,0):READ H$:NEXT
  740 PRINTTAB(2,31-X%);H$:NEXT
  750 PRINTTAB(0,10);"UNDER ORDERS....";
  760 INPUT Q$:PRINTTAB(0,10);S$
  770 COLOUR2
  780 FOR X%=1TO6:RESTORE
  790 FOR Y%=1 TO R%(X%,0):READ H$:NEXT
  800 PRINTTAB(2,31-X%);H$:NEXT
  810 PRINTTAB(0,10);"THEY'RE OFF!"
  820 Q=INKEY(50):PRINTTAB(0,10);S$:VDU5:H%=0
  830  
  840 REM - THE RACE *****************
  850  
  860 REPEAT
  870 FOR X%=1 TO 6
  880 MOVE R%(X%,3)MOD1279,(R%(X%,3)DIV1279)*256+32*X%+32
  890 PRINTCHR$224
  900 T%=R%(X%,3)+R%(X%,2)+RND(20)+20
  910 R%(X%,3)=T%
  920 MOVE T%MOD1279,(T%DIV1279)*256+32*X%+32
  930 PRINTCHR$224
  940 IF T%>H% H%=T%
  950 NEXT:UNTIL H%>=4888
  960  
  970 REM - Find & give winner
  980 W%=0:H%=0
  990 FORX%=1 TO 6:IF R%(X%,3)>H% H%=R%(X%,3):W%=R%(X%,0)
 1000 NEXT X%:VDU4:COLOUR 9
 1010 PRINTTAB(0,11);H$(W%);" wins!"TAB(0,17):SP%=H%(W%,1)
 1020 COLOUR0:INPUTTAB(2,17),Q$:MODE7
 1030  
 1040 REM - Tote - adjust cash
 1050 FOR X%=1 TO PL%:CLS
 1060 PROCDBL(5,5,131,P$(X%))
 1070 PRINT''"Your £";P%(X%,1);
 1080 PRINT" bet on #";P%(X%,2);" (";H$(P%(X%,2));")"''
 1090 IF P%(X%,2)=W% GOTO1130
 1100 PROCDBL(5,11,129,"LOST")
 1110 P%(X%,0)=P%(X%,0)-P%(X%,1)
 1120 GOTO1150
 1130 PROCDBL(5,11,130,"WIN!"):PRINT''"At ";SP%;" to 1!"
 1140 P%(X%,0)=P%(X%,0)+P%(X%,1)*SP%
 1150 PRINT'"You have £";P%(X%,0)'''"Press RETURN....";
 1160 INPUT G$:NEXT X%:CLS
 1170 FOR X%=1 TO PL%:IF P%(X%,0)<=0 PROCEND:END
 1180 NEXT
 1190  
 1200 REM - Adjust race time
 1210 MIN%=MIN%+15:IF MIN%=60 MIN%=0:HR%=HR%+1
 1220 IF HR%>=6 PROCEND:END
 1230 REM - Adjust prices & handicaps
 1240 FOR X%=1 TO 6
 1250 IF R%(X%,0)<>W% GOTO1290
 1260 H%(R%(X%,0),1)=H%(R%(X%,0),1)-1
 1270 H%(R%(X%,0),2)=H%(R%(X%,0),2)-1
 1280 GOTO1310
 1290 H%(R%(X%,0),1)=H%(R%(X%,0),1)+1
 1300 H%(R%(X%,0),2)=H%(R%(X%,0),2)+1
 1310 NEXT:GOTO250:REM - NEXT RACE
 1320  
 1330 DEFPROCDBL(X%,Y%,C%,X$)
 1340 PRINTTAB(X%,Y%);CHR$C%;CHR$141;X$
 1350 PRINTTAB(X%,Y%+1);CHR$C%;CHR$141;X$
 1360 ENDPROC
 1370  
 1380 DEFPROCSPB
 1390 PRINTTAB(0,23);"Press SPACEBAR to continue....";
 1400 REPEAT:G$=GET$:UNTIL G$=" "
 1410 ENDPROC
 1420  
 1430 DATA Uncle Vanya,Running Wild,Spindrift,Owzyafarver
 1440 DATA White Tornado,Speedy Gonzalez,Saucy Minx,Black Friar
 1450 DATA Lively Lady,Spindleshanks
 1460 DATA My Hope,Baker's Boy,Sweetheart,Fred's Fancy
 1470 DATA Gillian Girl,Nosey Parker,Wild On,Muggins
 1475 DATA Chipmunk,Silver Star
 1480  
 1490 DEFPROCEND
 1500 CLS:PROCDBL(2,2,131,"CASH AT END")
 1510 PRINT':FORX%=1 TO PL%
 1520 PRINTP$(X%);TAB(20);"£";P%(X%,0)
 1530 NEXT:PRINT
 1540 PROCDBL(0,31,129,"THAT'S ALL FOLKS!"):ENDPROC
 1550  
 1560 DEFPROCFENCE(Y%)
 1570 MOVE 0,Y%:DRAW 1279,Y%
 1580 MOVE 0,Y%+40:DRAW 1279,Y%+40
 1590 FOR S%=1 TO 1279 STEP 100
 1600 MOVE S%,Y%:DRAW S%,Y%+40:NEXT
 1610 ENDPROC