A card game against the computer, played like baccarat. Both sides start with $100,000, and each hand begins with a bet of up to $10,000. Two cards are dealt to each side, with the computer’s first card face down, and only the last digit of a hand’s total counts, so tens and court cards are worth nothing. The player may take one more card, and the computer then draws if it is behind. A higher total wins the bet and equal totals are a push. The game ends when either side runs out of money.
Program Analysis
Program Structure
- Setup (lines 10–106): stakes
YMandCMare set to 100,000 and the deck is built as the 104-character stringA$, holding rank and suit pairs such asAS,0HorKD. - Betting (lines 1600–1660): shows both balances and accepts a bet no larger than $10,000 or the player’s balance.
- Deal (lines 115–440): two cards to the player on the left and two to the computer on the right. The computer’s first card is stored in
T$/U$(line 2000) and left blank on screen until the player decides whether to draw. - Resolution (lines 460–680): the hidden card is shown, the totals are compared, and the computer takes at most one extra card (tracked by setting the loop variable
Tto 0). - Subroutines: 900 draws a card outline with block graphics and picks a random unused card; 1000 and 1100 reduce the player’s and computer’s totals modulo 10 by repeated subtraction.
Card Handling
Line 950 picks a random position from 1 to 52 and retries if that pair in A$ has already been blanked. Dealt cards are removed by overwriting their pair with spaces, and the deck is rebuilt and reshuffled once more than 45 cards have been used. The card’s value comes from its position: lines 967–969 subtract 39, 26 and 13 in turn to reduce it to a rank from 1 to 13, and line 980 caps it at 10. A rank character of 0 is displayed as 10.
Potential Issues
- The bet is checked only against the $10,000 limit and the player’s balance. A negative bet is accepted and reverses the result of the hand.
- The computer’s balance is not checked when the bet is placed, so a bet can be larger than the amount the computer has left. The game simply ends once
CMdrops below 1.
Source Code
10 LET YM=100000
20 LET CM=100000
100 LET A$="AS2S3S4S5S6S7S8S9S0SJSQSKSAH2H3H4H5H6H7H8H9H0HJHQHKHAC2C3C4C5C6C7C8C9C0CJCQCKCAD2D3D4D5D6D7D8D9D0DJDQDKD"
105 LET CT=0
106 GOTO 1600
110 IF CT>45 THEN GOTO 1500
112 PRINT AT 15,3;"PRESS ENTER TO START GAME ::"
113 PAUSE 40000
114 GOTO 1600
115 RAND
120 CLS
130 LET X=1
140 LET Z=9
150 LET P=0
160 FOR T=1 TO 2
170 GOSUB 800
190 GOSUB 900
200 PRINT AT X+1,Z+1;C$
205 PRINT AT X+3,Z+2;B$
210 LET P=P+Y
220 LET X=X+3
230 LET Z=Z-2
240 NEXT T
250 GOSUB 1000
260 PRINT AT 19,1;"YOU HAVE ";P
300 LET R=1
310 LET S=17
320 LET D=0
330 FOR T=1 TO 2
340 GOSUB 850
350 GOSUB 900
360 LET D=D+Y
370 IF T=1 THEN GOTO 2000
400 PRINT AT R+1,S+1;C$
405 PRINT AT R+3,S+1;B$
410 LET R=R+3
420 LET S=S+2
430 NEXT T
440 GOSUB 1100
450 PRINT AT 19,17;"COMPUTER:"
460 PRINT AT 21,1;"DO YOU WANT A CARD?"
470 LET Q$=INKEY$
472 IF Q$="" THEN GOTO 470
473 PRINT AT 21,1;" "
475 PRINT AT 2,18;T$
476 PRINT AT 4,18;U$
480 IF Q$="N" THEN GOTO 550
490 GOSUB 800
500 GOSUB 900
510 PRINT AT X+1,Z+1;C$
515 PRINT AT X+3,Z+2;B$
520 LET P=P+Y
530 GOSUB 1000
540 PRINT AT 19,10;P
550 PRINT AT 19,27;D
555 IF D=P THEN GOTO 600
560 IF D>P THEN GOTO 650
563 IF T=0 THEN GOTO 670
565 GOSUB 850
570 GOSUB 900
572 LET D=D+Y
575 PRINT AT R+1,S+1;C$
576 PRINT AT R+3,S+2;B$
580 GOSUB 1100
590 PRINT AT 19,27;D
596 LET T=0
597 GOTO 550
600 PRINT AT 21,1;"[I][T]▟[S]█[A]█[T][I][E] [P][U][S][H]"
610 GOTO 110
650 PRINT AT 21,1;"[Y][O][U]█[L][O][S][E]"
652 LET YM=YM-B
653 LET CM=CM+B
654 IF YM<1 THEN GOTO 3000
660 GOTO 110
670 PRINT AT 21,1;"[Y][O][U]█[W][I][N]"
672 LET YM=YM+B
673 LET CM=CM-B
674 IF CM<1 THEN GOTO 4000
680 GOTO 110
800 LET I=X
810 LET J=Z
820 RETURN
850 LET I=R
860 LET J=S
870 RETURN
900 PRINT AT I,J;"▛▀▀▜"
910 FOR K=I+1 TO I+3
920 PRINT AT K,J;"▌ ▐"
930 NEXT K
940 PRINT AT I+4,J;"▙▄▄▟"
950 LET Y=INT (RND*52+1)
955 IF A$(Y*2-1 TO Y*2)=" " THEN GOTO 950
956 LET CT=CT+1
960 LET C$=A$(Y*2-1)
965 LET B$=A$(Y*2)
966 LET A$(Y*2-1 TO Y*2)=" "
967 IF Y>39 THEN LET Y=Y-39
968 IF Y>26 THEN LET Y=Y-26
969 IF Y>13 THEN LET Y=Y-13
970 IF C$="0" THEN LET C$="10"
980 IF Y>10 THEN LET Y=10
990 RETURN
1000 IF P<10 THEN RETURN
1010 LET P=P-10
1020 GOTO 1000
1100 IF D<10 THEN RETURN
1110 LET D=D-10
1120 GOTO 1100
1500 CLS
1510 PRINT AT 10,5;"RE-MIX AND SHUFFLING"
1520 GOTO 100
1600 CLS
1610 PRINT ,,"YOU HAVE","COMPUTER HAS","$";YM,"$";CM
1620 PRINT ,,,,"PLACE YOUR BET ($10,000 MAX.)?"
1630 INPUT B
1640 IF B>10000 THEN GOTO 1630
1650 IF B>YM THEN GOTO 1630
1660 GOTO 115
2000 LET T$=C$
2010 LET U$=B$
2020 GOTO 410
3000 PRINT AT 21,0;"YOU LOST EVERYTHING - TOO BAD."
3010 STOP
4000 PRINT AT 21,0;"YOU BROKE THE BANK."
4010 STOP
9998 SAVE "BURTS GAM[E]"
9999 RUNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
