My programs issues

pascal111 judas.the.messiah.111 at gmail.com
Wed Aug 10 17:32:45 UTC 2022


On Wednesday, 10 August 2022 at 14:45:05 UTC, Andrey Zherikov 
wrote:
> On Wednesday, 10 August 2022 at 14:08:59 UTC, pascal111 wrote:
>> This version has modern features, it's 1) functional 2) 
>> goto-less.
>
> There is nothing modern ;-D

Take a look in this linear programming and you will know what's 
the modern:

'''BASIC

10 ' ----------------------------------------------
20 '                 ACEY DUECEY
30 ' ----------------------------------------------
40 '
50 '       Program by G C Lindridge  27/12/90
60 '
70 CLEAR : KEY OFF : CLS : SCREEN 0 : WIDTH 80
80 DEFINT A-Z
90 GOSUB 220                                       'INPUT SCREEN
100 GOSUB 510                                      'CREATE PACK
110 GOSUB 750                                      'SHUFFLE CARDS
120 SCREEN 1                                       'LARGE DISPLAY
130 TD = 1500                                      'TIME DELAY
140 GOSUB 930                                      'PLAY THE GAME
150 WIDTH 80 : SCREEN 0
160 PRINT "END ACEY DUECEY"
170 PRINT : PRINT "Do you want to play again?  Y/N" : PRINT
180 CH$ = INKEY$ : IF CH$ = "" THEN 180
190 IF CH$ = "Y" THEN 70 ELSE SYSTEM
200 END
210 ' ----------------------------------------------
220 '                                   INPUT SCREEN
230 ' ----------------------------------------------
240 PRINT TAB(33);"ACEY DUECEY"
250 PRINT TAB(33);"-----------"
260 PRINT : PRINT
270 PRINT TAB(24);"You and the computer play the game."
280 PRINT TAB(24);"You both start with 1000 units."
290 PRINT TAB(24);"Bets are from 1 to 200 units."
300 PRINT
310 PRINT TAB(24);"Can you send the computer broke?"
320 PRINT : PRINT
330 PRINT TAB(24);"[ 1 ]  To see the User Guide"
340 PRINT TAB(24);"[ 2 ]  Play Acey Duecey"
350 CH$ = INKEY$ : IF CH$ = "" THEN 350
360 IF CH$ = "1" THEN GOSUB 2150
370 MIN = 1
380 LIMIT = 200
390 HUMANBANK = 900
400 COMPBANK = 900
410 KITTY = 200
420 RETURN
430 ' ----------------------------------------------
440 '                                  PRESS ANY KEY
450 ' ----------------------------------------------
460 LOCATE 25,1 : PRINT ,,,"Press any key to continue";
470 WHILE INKEY$ = "" : WEND
480 CLS
490 RETURN
500 ' ----------------------------------------------
510 '                                    CREATE PACK
520 ' ----------------------------------------------
530 DIM CARD(52)
540 'GIVE GAME VALUES TO CARDS
550 FOR J = 0 TO 3
560   FOR K = 1 TO 13
570     CARD(J*13+K) = K+1
580   NEXT K
590 NEXT J
600 RETURN
610 ' ----------------------------------------------
620 '                                     SHOW CARDS
630 ' ----------------------------------------------
640 LOCATE 1,1
650 FOR K = 52 TO 1 STEP-1
660   IF CARD(K) < 11 THEN PRINT USING "####";CARD(K);
670   IF CARD(K) = 11 THEN PRINT "   J";
680   IF CARD(K) = 12 THEN PRINT "   Q";
690   IF CARD(K) = 13 THEN PRINT "   K";
700   IF CARD(K) = 14 THEN PRINT "   A";
710 NEXT K
720 PRINT : PRINT
730 RETURN                                          'END DISPLAY
740 ' ----------------------------------------------
750 LOCATE 24,1 :           PRINT "[SHUFFLE]       ";
760 ' ----------------------------------------------
770 RANDOMIZE TIMER
780 FOR K = 52 TO 2 STEP -1
790   X = INT(RND(1)*K)+1
800   SWAP CARD(K),CARD(X)
810 NEXT K
820 SHOE = 52                                       'PUT CARDS IN 
SHOE
830 RETURN
840 ' ----------------------------------------------
850 '                                     TIME DELAY
860 ' ----------------------------------------------
870 FOR K = 1 TO TD
880   FOR L = 1 TO TD
890   NEXT L
900 NEXT K
910 RETURN
920 ' ----------------------------------------------
930 '                                  PLAY THE GAME
940 ' ----------------------------------------------
950 WHILE (BET$ <> "Q") AND (HUMANBANK > MIN) AND (COMPBANK > 
MIN) 'CONTINUE
960   P = 0 : BET$ = ""                              'INITIALISE
970   PLHAND = 0
980   FOR K = 1 TO 3
990     PLCARD(K) = 0
1000   NEXT K
1010   BADCARDS = 0
1020   IF BET$ = "Q" THEN 1100                       'QUIT THE 
GAME
1030   IF (SHOE < 5) THEN GOSUB 750                  'RESHUFFLE 
POINT
1040   GOSUB 850                                     'TIME DELAY
1050   CLS
1060   GOSUB 1180                                    'HUMAN PLAYER
1070   IF (SHOE < 5) THEN GOSUB 750                  'RESHUFFLE 
POINT
1080   GOSUB 1540                                    'COMPUTER 
PLAYER
1090 WEND
1100 RETURN                                          'END DEALING
1110 ' ----------------------------------------------
1120 '                                    DEAL A CARD
1130 ' ----------------------------------------------
1140 CARD = CARD(SHOE)                               'THE TOP CARD
1150 SHOE = SHOE - 1                                 'REMOVE CARD 
FROM PACK
1160 RETURN                                          'DEAL CARD
1170 ' ----------------------------------------------
1180 '                                   HUMAN PLAYER
1190 ' ----------------------------------------------
1200 LOCATE 24, 1 : PRINT "HUMAN BANK";HUMANBANK;
1210 LOCATE 24,21 : PRINT "COMPUTER BANK";COMPBANK;
1220 GOSUB 1910
1230 HUMANBET = 0
1240 GOSUB 1120                                      'DEAL A CARD
1250 PLCARD(1) = CARD
1260 GOSUB 1120                                      'DEAL A CARD
1270 PLCARD(2) = CARD
1280 IF PLCARD(1) < PLCARD(2) THEN SWAP PLCARD(1),PLCARD(2)  
'CARD(1) IS HIGH
1290 P = 1
1300 R = 80 : C = P*32 - 32 : GOSUB 2000             'SHOW CARD 
IN BOX
1310 P = 2
1320 R = 80 : C = P*32      : GOSUB 2000             'SHOW CARD 
IN BOX
1330 IF PLCARD(2)+1 >= PLCARD(1) THEN 1500           'NO SPACE 
BETWEEN CARDS
1340 LOCATE 25, 1 : INPUT;"MAKE A BET ",BET$
1350 IF BET$ = "Q" THEN 1520                         'QUIT THE 
GAME
1360 HUMANBET = INT(ABS(VAL(BET$)))                  'BET UNITS
1370 IF HUMANBET = 0 THEN 1500                       'REJECT HAND
1380 IF HUMANBET > KITTY THEN LET HUMANBET = KITTY   'LIMIT BET
1390 IF HUMANBET > LIMIT THEN LET HUMANBET = LIMIT   'MAXIMUM BET
1400 IF HUMANBET > HUMANBANK THEN LET HUMANBET = HUMANBANK   'BET 
THE LOT
1410 GOSUB 1120                                      'DEAL A CARD
1420 P = 3
1430 PLCARD(P) = CARD
1440 R = 16 : C = P*32 - 64 : GOSUB 2000             'SHOW CARD 
IN BOX
1450 HUMANBANK = HUMANBANK-HUMANBET
1460 KITTY = KITTY + HUMANBET
1470 IF (PLCARD(3)>= PLCARD(1)) OR (PLCARD(3) < =  PLCARD(2)) 
THEN 1500
1480 HUMANBANK = HUMANBANK+2*HUMANBET
1490 KITTY = KITTY - 2*HUMANBET
1500 FOR K = 1 TO 1000 : NEXT K
1510 GOSUB 1910                                      'KITTY
1520 RETURN
1530 ' ----------------------------------------------
1540 '                                COMPUTER PLAYER
1550 ' ----------------------------------------------
1560 LOCATE 24,21 : PRINT "COMPUTER BANK";COMPBANK;
1570 COMPBET = 0
1580 GOSUB 1120                                      'DEAL A CARD
1590 PLCARD(1) = CARD
1600 GOSUB 1120                                      'DEAL A CARD
1610 PLCARD(2) = CARD
1620 IF PLCARD(1) < PLCARD(2) THEN SWAP PLCARD(1),PLCARD(2)  
'CARD(1) IS HIGH
1630 P = 1
1640 R = 80 : C = P*32 + 160 : GOSUB 2000            'SHOW CARD 
IN BOX
1650 P = 2
1660 R = 80 : C = P*32 + 192 : GOSUB 2000            'SHOW CARD 
IN BOX
1670 IF PLCARD(2)+1 >= PLCARD(1) THEN 1870           'NO SPACE 
BETWEEN CARDS
1680 FOR K = 1 TO SHOE
1690   IF CARD(K) >= PLCARD(1) OR CARD(K) <= PLCARD(2)THEN LET 
BADCARDS = BADCARDS+1
1700   IF BADCARDS >= SHOE/2 THEN LET K = SHOE
1710 NEXT K
1720 COMPBET = INT((SHOE-2*BADCARDS)/SHOE*COMPBANK)  'ADVANTAGE 
BET
1730 IF COMPBET < 1 THEN LET COMPBET = 0 : GOTO 1870
1740 IF COMPBET > KITTY THEN LET COMPBET = KITTY     'LIMIT BET
1750 IF COMPBET > LIMIT THEN LET COMPBET = LIMIT     'MAXIMUM BET
1760 IF COMPBET > COMPBANK THEN LET COMPBET = COMPBANK       'BET 
THE LOT
1770 LOCATE 25,21 : PRINT "COMPUTER  BET";COMPBET;
1780 GOSUB 1120                                      'DEAL A CARD
1790 P = 3
1800 PLCARD(P) = CARD
1810 R = 16 : C = P*32 + 128 : GOSUB 2000            'SHOW CARD 
IN BOX
1820 COMPBANK = COMPBANK-COMPBET
1830 KITTY = KITTY + COMPBET
1840 IF (PLCARD(3)>= PLCARD(1)) OR (PLCARD(3) < =  PLCARD(2)) 
THEN 1870
1850 COMPBANK = COMPBANK+ 2*COMPBET
1860 KITTY = KITTY - 2*COMPBET
1870 FOR K = 1 TO 2000 : NEXT K
1880 GOSUB 1910                                      'KITTY
1890 RETURN
1900 ' ----------------------------------------------
1910 '                                          KITTY
1920 ' ----------------------------------------------
1930 IF KITTY <> 0 THEN 1970
1940 HUMANBANK = HUMANBANK-100
1950 COMPBANK = COMPBANK-100
1960 KITTY = 200
1970 LOCATE 25,21 : PRINT "        KITTY";KITTY;
1980 RETURN
1990 ' ----------------------------------------------
2000 '                         PICTURE PLAYERS' CARDS
2010 ' ----------------------------------------------
2020 PICTURE = PLCARD(P)
2030 LINE (C+4,R+4)-(C+30,R+44),,B                   'DRAW CARD 
BORDER
2040 IF PICTURE = 10 THEN LET PIP$ = "1O"
2050 IF PICTURE = 11 THEN LET PIP$ = "J "
2060 IF PICTURE = 12 THEN LET PIP$ = "Q "
2070 IF PICTURE = 13 THEN LET PIP$ = "K "
2080 IF PICTURE = 14 THEN LET PIP$ = "A "
2090 IF PICTURE < 10 THEN LET PIP$ = RIGHT$(STR$(PICTURE),1)+" "
2100 LOCATE R/8+2,C/8+2 : PRINT PIP$;                'DRAW PIPS
2110 SUIT$ = CHR$(INT (RND(1)*4)+3)                  'CARD SUIT
2120 LOCATE R/8+4,C/8+3 : PRINT SUIT$;               'DRAW SUIT
2130 RETURN
2140 ' ----------------------------------------------
2150 CLS :              PRINT ,,"      ACEY  DUECEY" : PRINT
2160 ' ----------------------------------------------
2170 PRINT ,"This is a gambling card game. A player is dealt a"
2180 PRINT ,"two card hand face up. The player now has the choice"
2190 PRINT ,"of folding the hand or betting on the hand."
2200 PRINT ,"If he folds, the next player is dealt a hand."
2210 PRINT ,"If he bets, he is dealt a third card."
2220 PRINT ,"If this card is between the other two cards he wins."
2230 PRINT ,"If this card is equal to either card or is more than"
2240 PRINT ,"the big card or less than the small card he loses."
2250 PRINT ,"Cards are as normal with Ace a high card. No suits."
2260 PRINT
2270 PRINT ,"TO FOLD: Bet 0. Alternatively press [Return] key."
2280 PRINT ,"TO QUIT: Enter Q as a bet."
2290 PRINT
2300 PRINT ,"BETTING: All bets are in units of 1."
2310 PRINT ,"Each player contributes 100 units to a kitty."
2320 PRINT ,"Bet Limits:  Minimum 1 unit.  Maximum 200 units."
2330 PRINT ,"A bet is unable to exceed what remains in the kitty."
2340 PRINT ,"A player bets to win 'EVENS'. Winnings are taken"
2350 PRINT ,"from the kitty, losing bets are added to the kitty."
2360 PRINT
2370 PRINT ,"When the kitty is empty, the players again 
contribute"
2380 PRINT ,"100 units each.";
2390 GOSUB 440                                       'PRESS ANY 
KEY
2400 RETURN

'''


More information about the Digitalmars-d-learn mailing list