11

Pakistani Pool


This is a game that originated in Pakistan, where players gamble on the number of heads that will show when 25 coins are tossed. In this implementation, six players may take part. If no-one guesses correctly, all bets are retained in the pool for the next throw. All start with £10 and the game ends if any player is reduce to zero cash.
   Names of players are collected and each given £10, and then in line 140 the game loop is entered. Each player is asked for his or her guess and then PROCTHROW is called 25 times, one for each coin. PROCTHROW shows H and T alternately for a little while before settling randomly for one or the other. After the throw, each player in turn is told the result of his or her bet and finally a check is made that all have some cash for the next round.

Variables

P$(6)Array containing names of players
C%(6)The cash state of each player
H%(6)The number of heads that each player bets on
P%Total number of players, 1 to 6
X%General counter
H%Number of heads thrown
T%Number of tails thrown
F%Flag; if 0, no player guessed correctly
POOL%Cash held in pool
Z%Spin count in coin tossing
W%Dummy
C%Colour of double-size print

   10 REM - Pakistani Pool
   20 DIM P$(6),C%(6),H%(6)
   30 MODE7:PRINTSTRING$(19,"oO")
   40 PROCDBL(10,5,130,"PAKISTANI POOL")
   50 PRINT'''STRING$(19,"oO")
   60 CLS:INPUT''"How many players (max 6)...?"P%
   70 IF P%<1 OR P%>6 GOTO60
   80 FOR X%=1 TO P%
   90 PRINT''CHR$(128+X%);"Player #";X%;" -"
  100 PRINT"What is your name ";
  110 INPUT P$(X%):C%(X%)=0:NEXT:POOL%=0
  120  
  130 CLS:REM - Game loop
  140 FOR X%=1 TO P%
  150 PRINT''CHR$(128+X%);P$(X%);
  160 PRINT" - heads out of 25 ";:INPUT H%(X%):NEXT
  170  
  180 REM - Coins tossed
  190 CLS:PROCDBL(5,5,129,"THE THROW -")
  200 PROCDBL(8,15,130,"HEADS   TAILS")
  210 PRINTTAB(0,10);CHR$131;:H%=0:T%=0
  220 FOR C%=2 TO 26:PROCTHROW:NEXT C%
  230 PRINTTAB(15,21);"PRESS RETURN...";:INPUT Q$
  235  
  240 REM - SETTLE BETS
  250 F%=0:FOR X%=1 TO P%:CLS
  260 PROCDBL(5,3,128+X%,P$(X%))
  270 IF H%(X%)=H% GOTO330
  280 PROCDBL(5,6,129,"LOST")
  290 C%(X%)=C%(X%)-1
  300 PRINT''"You have £";C%(X%);" left"
  310 PRINT"Press RETURN...";:INPUT Q$
  320 GOTO400
  330 PROCDBL(5,6,131,"WON!")
  340 IF POOL%=0 GOTO370
  350 PRINT''CHR$133;"YOU SCOOP £";POOL%;" FROM THE POOL."
  360 C%(X%)=C%(X%)+POOL%:POOL%=0
  370 C%(X%)=C%(X%)+P%-1
  380 PRINT''"You now have £";C%(X%)'
  390 PRINT'"Press RETURN...";:INPUT Q$:F%=1
  400 NEXT
  410 REM - CHECK ALL HAVE CASH
  420 Z%=0:FOR X%=1 TO P%:IF C%(X%)<=0 Z%=1
  430 NEXT X%:IF Z%=0 GOTO460
  440 CLS:PROCDBL(5,5,131,"FINAL SCORES")
  450 FOR X%=1 TO P%:PRINTP$(X%)," - £";C%(X%):NEXT:END
  455  
  460 REM  - CHECK POOL
  470 IF F%<>0 GOTO130
  480 POOL%=POOL%+P%:CLS
  490 PRINT''''CHR$129;"THERE IS £";POOL%;" IN THE POOL"
  500 PRINTTAB(15,21);"PRESS RETURN...";:INPUT Q$
  510 GOTO 130
  520  
  530 DEFPROCTHROW
  540 FOR Z%=1 TO 10
  550 PRINTTAB(C%,10);"O":W%=INKEY(5):PRINTTAB(C%,10);"I"
  560 W%=INKEY(5):NEXT Z%
  570 PRINTTAB(C%,10);:IF RND(2)=2 PRINT"T":T%=T%+1:GOTO590
  580 PRINT"H":H%=H%+1
  590 S$=STR$H%+"       "+STR$T%
  600 PROCDBL(10,18,130,S$)
  610 ENDPROC
  620 DEFPROCDBL(X%,Y%,C%,X$)
  630 PRINTTAB(X%,Y%);CHR$C%;CHR$141;X$
  640 PRINTTAB(X%,Y%+1);CHR$C%;CHR$141;X$:ENDPROC