IDENTIFICATION DIVISION. PROGRAM-ID. BJTRNR. * Blackjack trainer ELG 18-APR-1989 ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT LOG-FILE ASSIGN TO " ". SELECT LOG-FILE-2 ASSIGN TO " ". DATA DIVISION. FILE SECTION. FD LOG-FILE VALUE OF ID "BJSAVE.DAT". 01 LOG-RECORD. 05 LCURCNT PIC S9. 05 LCCHOICE PIC 9. 05 LVALUES. 10 LSTAND-VAL PIC S9. 10 LSPLIT-VAL PIC S9. 10 LDOUBLE-VAL PIC S9. 10 LSURR-VAL PIC S9. 10 LFLAGS-VAL PIC 9(4). 05 LDCARD. 10 LDCARD-DISP PIC XX. 10 LDCARD-VALUE PIC 99. 05 LPCARD1. 10 LPCARD1-DISP PIC XX. 10 LPCARD1-VALUE PIC 99. 05 LPCARD2. 10 LPCARD2-DISP PIC XX. 10 LPCARD2-VALUE PIC 99. FD LOG-FILE-2 VALUE OF ID "BJSAVE.DAT". 01 LOG2-RECORD PIC X(22). WORKING-STORAGE SECTION. * Possible Choices STAND(0),HIT(1),DOUBLE(2),SPLIT(3),SURRENDER(4) 01 CHOICES. 05 CORRECT-CHOICE PIC 9 COMP. 05 USER-CHOICE PIC 9 COMP. 05 INPUT-COUNT PIC S9 COMP. 05 NUM-CORRECT PIC 9(4) COMP VALUE 0. 05 NUM-WRONG PIC 9(4) COMP VALUE 0. 05 SCORE-CORRECT PIC 9(6)V9 COMP VALUE 0. 05 SCORE-WRONG PIC 9(6)V9 COMP VALUE 0. 05 CARD-COUNT-INPUT PIC X. 88 CARD-COUNTER VALUE "Y". 05 SPECIAL-CASE-INPUT PIC X. 88 ALWAYS-PLAYER VALUE "A". 88 ALWAYS-PAIRS VALUE "P". 88 ALWAYS-DEALER VALUE "D". 05 SURRENDER-INPUT PIC X. 88 SURRENDER-ALLOWED VALUE "Y". 05 LOG-FILE-INPUT PIC X. 05 INPUT-CARD PIC 99 COMP. 01 PLAYING-FLAGS. 05 FLAGS-VALUE PIC 9(4). 05 FLAG-DEF REDEFINES FLAGS-VALUE. 10 SPLIT-POSSIBLE-FLAG PIC 9. 88 SPLIT-POSSIBLE VALUE 1. 10 SOFT-HAND-FLAG PIC 9. 88 SOFT-HAND VALUE 1. 10 DOUBLE-DOWN-FLAG PIC 9. 88 DOUBLE-POSSIBLE VALUE 1. 10 SURRENDER-FLAG PIC 9. 88 SURRENDER-POSSIBLE VALUE 1. 01 LOG-FILE-FLAGS. 05 LOGGING-FLAG PIC 9. 88 LOGGING-ON VALUE 1. 05 REVIEWING-FLAG PIC 9. 88 REVIEWING-ON VALUE 1. 01 COUNT-VALUES. 05 CURRENT-COUNT PIC S9 COMP VALUE 0. 05 SPLIT-VALUE PIC S9 COMP. 05 STAND-VALUE PIC S9 COMP. 05 DOUBLE-VALUE PIC S9 COMP. 01 CARD. 05 CARD-DISP. 10 CARD-NDISP PIC Z9. 05 CARD-VALUE PIC 99. 01 PCARDS. 05 TOT-HAND PIC 99. 05 DCARD. 10 DCARD-DISP PIC XX. 10 DCARD-VALUE PIC 99. 05 PCARD-COUNT PIC 99. 05 PCARD-ARRAY. 10 PCARD1. 15 PCARD1-DISP PIC XX. 15 PCARD1-VALUE PIC 99. 10 PCARD2. 15 PCARD2-DISP PIC XX. 15 PCARD2-VALUE PIC 99. 01 RANDOM-NUMBER-STORAGE. 05 RANDOM-SEED PIC S9(9) COMP. 05 RANDOM-RETURN USAGE COMP-1. 05 RANDOM-VALUE PIC 99. 05 SYSTEM-TIME. 10 ST-HOURS PIC 99. 10 ST-MINUTES PIC 99. 10 ST-SECONDS PIC 99. 10 ST-HUNDREDTHS PIC 99. 01 SCORING-VALUES. * A check at the "local" casino shows each hand (at a full table) * takes about 50 seconds, so 72 deals per hour is about average 05 DEALS-PER-HOUR PIC 99 COMP VALUE 72. 05 USUAL-BET PIC 9(4) COMP. 05 HANDS-PLAYED PIC 9 COMP. 05 HANDS-PER-HOUR PIC 9(4) COMP. 05 WIN-PERCENTAGE PIC S9V999 COMP. 05 AMT-PER-HOUR PIC S9(7)V99 COMP. 05 AMT-OUT PIC $$,$$$,$$$.99. 05 PCT-OUT PIC ZZZZ.99. * * * DECISION TABLES * 01 HARD-STAND-TABLE. 05 HARD-STAND-DEFINED. * Stand if count >= value, HIT otherwise 10 HSTD-TWELVE-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 2. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 HSTD-THIRTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 HSTD-FOURTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE -7. 15 FILLER PIC S9 VALUE -6. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 HSTD-FIFTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -6. 15 FILLER PIC S9 VALUE -7. * Since -8 is almost -9, for most cases will work, change next line * if you are a perfectionist * 15 FILLER PIC S9 VALUE -8. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 2. 10 HSTD-SIXTEEN-VALUES. 15 FILLER PIC S9 VALUE 6. * Ditto * 15 FILLER PIC S9 VALUE -8. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 4. 15 FILLER PIC S9 VALUE 0. 05 HARD-STAND-ARRAY REDEFINES HARD-STAND-DEFINED. 10 HSTD-PLAYER OCCURS 5. 15 HSTD-DEALER OCCURS 10. 20 HSTD-VALUE PIC S9. 01 SPLIT-TABLE. 05 SPLIT-TABLE-DEFINED. 10 SPT-ACE-VALUES. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. * Ditto * 15 FILLER PIC S9 VALUE -8. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -7. 15 FILLER PIC S9 VALUE -7. 10 SPT-DUECE-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SPT-TREY-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SPT-FOUR-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE 0. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SPT-FIVE-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SPT-SIX-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SPT-SEVEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SPT-EIGHT-VALUES. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 10 SPT-NINE-VALUES. 15 FILLER PIC S9 VALUE 4. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -6. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE 4. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 10 SPT-TEN-VALUES. * Where it is permissable in certain cases (high count) to split tens, * it draws so much attention that it is discouraged for the serious player 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 05 SPLIT-TABLE-ARRAY REDEFINES SPLIT-TABLE-DEFINED. 10 SPT-PLAYER OCCURS 10. 15 SPT-DEALER OCCURS 10. 20 SPT-VALUE PIC S9. 01 SOFT-DOUBLE-TABLE. 05 SOFT-DOUBLE-DEFINED. 10 SDBT-THIRTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-FOURTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 0. 15 FILLER PIC S9 VALUE -3. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-FIFTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE -5. * Ditto * 15 FILLER PIC S9 VALUE -8. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-SIXTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE -6. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-SEVENTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-EIGHTEEN-VALUES. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE -6. 15 FILLER PIC S9 VALUE -7. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-NINETEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 7. 15 FILLER PIC S9 VALUE 4. 15 FILLER PIC S9 VALUE 2. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 SDBT-TWENTY-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 7. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 05 SOFT-DOUBLE-ARRAY REDEFINES SOFT-DOUBLE-DEFINED. 10 SDBT-PLAYER OCCURS 8. 15 SDBT-DEALER OCCURS 10. 20 SDBT-VALUE PIC S9. 01 HARD-DOUBLE-TABLE. 05 HARD-DOUBLE-DEFINED. 10 HDBT-EIGHT-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 HDBT-NINE-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE 0. 15 FILLER PIC S9 VALUE -2. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 10 HDBT-TEN-VALUES. 15 FILLER PIC S9 VALUE 3. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -6. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -1. 15 FILLER PIC S9 VALUE 4. 10 HDBT-ELEVEN-VALUES. 15 FILLER PIC S9 VALUE 0. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -9. 15 FILLER PIC S9 VALUE -7. 15 FILLER PIC S9 VALUE -5. 15 FILLER PIC S9 VALUE -4. 15 FILLER PIC S9 VALUE -3. 05 HARD-DOUBLE-ARRAY REDEFINES HARD-DOUBLE-DEFINED. 10 HDBT-PLAYER OCCURS 4. 15 HDBT-DEALER OCCURS 10. 20 HDBT-VALUE PIC S9. 01 SURRENDER-TABLE. 05 SURRENDER-DEFINED. 10 SURT-THIRTEEN-VALUES. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 6. 10 SURT-FOURTEEN-VALUES. 15 FILLER PIC S9 VALUE 6. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 5. 15 FILLER PIC S9 VALUE 2. 10 SURT-FIFTEEN-VALUES. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 6. 15 FILLER PIC S9 VALUE 2. 15 FILLER PIC S9 VALUE 0. 10 SURT-SIXTEEN-VALUES. 15 FILLER PIC S9 VALUE 0. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 9. 15 FILLER PIC S9 VALUE 4. 15 FILLER PIC S9 VALUE 1. 15 FILLER PIC S9 VALUE -1. 05 SURRENDER-ARRAY REDEFINES SURRENDER-DEFINED. 10 SURT-PLAYER OCCURS 4. 15 SURT-DEALER OCCURS 10. 20 SURT-VALUE PIC S9. 05 SURRENDER-VALUE PIC S9. PROCEDURE DIVISION. MAIN-PROGRAM SECTION. GET-BET-AMOUNT. DISPLAY "What is your usual bet per hand (dollars)? " WITH NO ADVANCING. ACCEPT USUAL-BET WITH CONVERSION AT END STOP RUN. IF USUAL-BET < 2 OR USUAL-BET > 100 DISPLAY "You really play for $" USUAL-BET WITH CONVERSION "a hand?" DISPLAY "This house only accepts bets in the range $2 to $100" GO TO GET-BET-AMOUNT. GET-HANDS-PLAYED. DISPLAY "How many hands do you play at a time?(1-4)<1>" WITH NO ADVANCING. ACCEPT HANDS-PLAYED WITH CONVERSION DEFAULT "1" AT END STOP RUN. IF HANDS-PLAYED < 1 OR HANDS-PLAYED > 4 GO TO GET-HANDS-PLAYED. * DISPLAY "BLACKJACK TRAINER Usual Bet: $" LINE 1 ERASE SCREEN USUAL-BET WITH CONVERSION COLUMN PLUS "*" COLUMN PLUS HANDS-PLAYED WITH CONVERSION COLUMN PLUS "Right:" COLUMN 44 "Wrong:" COLUMN 64. * ACCEPT SYSTEM-TIME FROM TIME. COMPUTE RANDOM-SEED = (ST-MINUTES + 1) * (ST-SECONDS + 1) * (ST-HUNDREDTHS + 1) * 4521. * DISPLAY LOW-VALUES LINE 3. DISPLAY "This program allows you to make decisions based on the first two cards dealt" DISPLAY "and the dealer's up card. The values used are based on numerical analysis" DISPLAY "of ""best choice"" in certain situations. " DISPLAY "Two versions are available - a beginners version for most of us who can't" DISPLAY """count"" cards, and an advanced version for those who can." DISPLAY "The count is based on the following table:" DISPLAY " A two through seven (except five) counts as +1" DISPLAY " A five counts as +2" DISPLAY " An eight counts as 0." DISPLAY " A nine and all tens (including face cards) count as -1." DISPLAY " An ace counts as -2." DISPLAY "Plus counts favor the player, minus counts favor the house -" DISPLAY " A new deck always starts with a count of 0." DISPLAY "For this simulation you will not be required to count, just make use of the " DISPLAY "count shown on the screen." DISPLAY "The tables shown are for use in playing with two decks, where doubling is". DISPLAY "allowed after splitting - while these values will work with four or ". DISPLAY "more decks, the best results will be obtained at two-deck tables.". DISPLAY " ". DISPLAY "Do you wish to play the advanced version?" WITH NO ADVANCING. ACCEPT CARD-COUNT-INPUT AT END STOP RUN. IF CARD-COUNT-INPUT = "y" MOVE "Y" TO CARD-COUNT-INPUT. * DISPLAY LOW-VALUES LINE 3 ERASE END SCREEN. IF CARD-COUNTER DISPLAY "Since you count cards, I will double the bet when the count is 2" DISPLAY " or better, and triple it if the count is 4 or better." DISPLAY LOW-VALUES. DISPLAY "This program also allows the following special situations:". DISPLAY " ". DISPLAY "Always draw a certain card (A)". DISPLAY "Always draw a pair (P)". DISPLAY "Dealer always has a certain card showing (D)". DISPLAY " ". DISPLAY "Special situation requested:" WITH NO ADVANCING. ACCEPT SPECIAL-CASE-INPUT AT END STOP RUN. CALL "STR$UPCASE" USING BY DESCRIPTOR SPECIAL-CASE-INPUT SPECIAL-CASE-INPUT . IF SPECIAL-CASE-INPUT = "A" OR "P" OR "D" NEXT SENTENCE ELSE MOVE SPACES TO SPECIAL-CASE-INPUT. * DISPLAY LOW-VALUES. DISPLAY "Does your casino allow SURRENDER?" WITH NO ADVANCING. ACCEPT SURRENDER-INPUT AT END STOP RUN. IF SURRENDER-INPUT = "y" MOVE "Y" TO SURRENDER-INPUT. * MOVE 0 TO LOGGING-FLAG REVIEWING-FLAG. DISPLAY "Do you want to maintain a log file of your mistakes?" WITH NO ADVANCING. ACCEPT LOG-FILE-INPUT AT END STOP RUN. IF LOG-FILE-INPUT = "Y" OR "y" OR SPACES MOVE 1 TO LOGGING-FLAG. * DISPLAY "Do you want to REVIEW an existing log file of your mistakes?" WITH NO ADVANCING. ACCEPT LOG-FILE-INPUT AT END STOP RUN. IF LOG-FILE-INPUT = "Y" OR "y" MOVE 1 TO REVIEWING-FLAG. * IF ALWAYS-PLAYER GO TO PLAYER-INPUT. IF NOT ALWAYS-DEALER GO TO START-THE-SHOW. DEALER-INPUT. DISPLAY "What card value do you want the dealer to have (1=ace):[1-10]" WITH NO ADVANCING. ACCEPT INPUT-CARD WITH CONVERSION AT END STOP RUN. IF INPUT-CARD < 1 OR INPUT-CARD > 10 DISPLAY "%Invalid value for dealer's card - please re-enter" GO TO DEALER-INPUT. MOVE INPUT-CARD TO CARD-NDISP CARD-VALUE. IF INPUT-CARD = 1 MOVE " A" TO CARD-DISP. MOVE CARD TO DCARD. GO TO START-THE-SHOW. PLAYER-INPUT. DISPLAY "What card value do you want to always have (1=ace):[1-10]" WITH NO ADVANCING. ACCEPT INPUT-CARD WITH CONVERSION AT END STOP RUN. IF INPUT-CARD < 1 OR INPUT-CARD > 10 DISPLAY "%Invalid value for card - please re-enter" GO TO PLAYER-INPUT. MOVE INPUT-CARD TO CARD-NDISP CARD-VALUE. IF INPUT-CARD = 1 MOVE " A" TO CARD-DISP. MOVE CARD TO PCARD1. * START-THE-SHOW. DISPLAY LOW-VALUES LINE 3 ERASE END SCREEN. IF REVIEWING-ON OPEN I-O LOG-FILE ELSE IF LOGGING-ON OPEN EXTEND LOG-FILE. * LOOP. IF REVIEWING-ON PERFORM READ-LOG-RECORD IF LDCARD NOT = "XX" GO TO DECISION-TIME ELSE IF NUM-WRONG = 0 CLOSE LOG-FILE OPEN OUTPUT LOG-FILE ELSE PERFORM COPY-LOG-FILE END-IF DISPLAY "LOG FILE REVIEWING COMPLETE" LINE 20 ERASE END SCREEN MOVE 0 TO REVIEWING-FLAG GO TO RET-TO-CONTINUE. * * Deal cards * IF NOT ALWAYS-PLAYER PERFORM GET-CARD MOVE CARD TO PCARD1. IF ALWAYS-PAIRS AND PCARD1-VALUE = 10 GO TO LOOP. * IF NOT ALWAYS-DEALER PERFORM GET-CARD MOVE CARD TO DCARD. * IF ALWAYS-PAIRS MOVE PCARD1 TO PCARD2 ELSE PERFORM GET-CARD MOVE CARD TO PCARD2. * IF CARD-COUNTER PERFORM VARY-COUNT. * * Set flags * MOVE 0 TO FLAGS-VALUE. ADD PCARD1-VALUE PCARD2-VALUE GIVING TOT-HAND. * IF PCARD2-DISP = PCARD1-DISP MOVE 1 TO SPLIT-POSSIBLE-FLAG. IF PCARD1-VALUE = 1 OR PCARD2-VALUE = 1 MOVE 1 TO SOFT-HAND-FLAG IF TOT-HAND > 2 MOVE 1 TO DOUBLE-DOWN-FLAG. * * Don't bother me with blackjacks - I KNOW what to do with them! IF SOFT-HAND AND (TOT-HAND = 11) GO TO LOOP. * IF TOT-HAND > 7 AND TOT-HAND < 12 MOVE 1 TO DOUBLE-DOWN-FLAG. IF SURRENDER-ALLOWED IF TOT-HAND > 12 AND TOT-HAND < 17 AND (DCARD-VALUE = 1 OR DCARD-VALUE > 7) MOVE 1 TO SURRENDER-FLAG MOVE SURT-VALUE(TOT-HAND - 12,DCARD-VALUE) TO SURRENDER-VALUE IF PCARD1-VALUE = PCARD2-VALUE IF PCARD1-VALUE = 8 AND DCARD-VALUE NOT = 10 MOVE 0 TO SURRENDER-FLAG ELSE IF PCARD1-VALUE = 7 IF DCARD-VALUE = 1 OR 9 MOVE 4 TO SURRENDER-VALUE ELSE IF DCARD-VALUE = 10 MOVE 0 TO SURRENDER-VALUE. * * Skip simple always hit situations * IF TOT-HAND < 8 AND FLAGS-VALUE = 0 GO TO LOOP. * * Determine basic stand, hit if not special case * MOVE 0 TO CORRECT-CHOICE. MOVE -9 TO STAND-VALUE. IF TOT-HAND < 12 MOVE 1 TO CORRECT-CHOICE MOVE 9 TO STAND-VALUE ELSE IF TOT-HAND < 17 MOVE HSTD-VALUE(TOT-HAND - 11,DCARD-VALUE) TO STAND-VALUE IF CURRENT-COUNT < STAND-VALUE MOVE 1 TO CORRECT-CHOICE. IF SOFT-HAND IF TOT-HAND > 8 OR (TOT-HAND = 8 AND (DCARD-VALUE = 7 OR 8)) MOVE 0 TO CORRECT-CHOICE MOVE -9 TO STAND-VALUE. * * Handle splits, doubles * IF SPLIT-POSSIBLE MOVE SPT-VALUE(PCARD1-VALUE,DCARD-VALUE) TO SPLIT-VALUE IF CURRENT-COUNT NOT < SPLIT-VALUE MOVE 3 TO CORRECT-CHOICE. IF DOUBLE-POSSIBLE IF SOFT-HAND MOVE SDBT-VALUE(TOT-HAND - 2,DCARD-VALUE) TO DOUBLE-VALUE ELSE MOVE HDBT-VALUE(TOT-HAND - 7,DCARD-VALUE) TO DOUBLE-VALUE END-IF IF CURRENT-COUNT NOT < DOUBLE-VALUE MOVE 2 TO CORRECT-CHOICE. IF SURRENDER-POSSIBLE IF CURRENT-COUNT NOT < SURRENDER-VALUE MOVE 4 TO CORRECT-CHOICE. * DECISION-TIME. * * Display cards dealt * PERFORM DISPLAY-CARDS-DEALT. * * Make choice * DISPLAY "Possible Choices: STAND(0), HIT(1), DOUBLE(2), SPLIT(3)" LINE 17 ERASE LINE. IF SURRENDER-ALLOWED DISPLAY ", SURRENDER(4)" COLUMN PLUS 0. DISPLAY "Your choice:<0>" LINE 19 ERASE END SCREEN. ACCEPT USER-CHOICE WITH CONVERSION COLUMN PLUS AT END STOP RUN. * IF USER-CHOICE NOT = CORRECT-CHOICE GO TO MISSED-IT. DISPLAY "Correct!" LINE 19 COLUMN 40. ADD 1 TO NUM-CORRECT SCORE-CORRECT. DISPLAY NUM-CORRECT WITH CONVERSION LINE 1 COLUMN 50. IF REVIEWING-ON PERFORM REMOVE-LOG-RECORD. IF CURRENT-COUNT > 4 ADD 2 TO SCORE-CORRECT ELSE IF CURRENT-COUNT > 2 ADD 1 TO SCORE-CORRECT. GO TO DISPLAY-TABLE. MISSED-IT. ADD 1 TO NUM-WRONG SCORE-WRONG. DISPLAY NUM-WRONG WITH CONVERSION LINE 1 COLUMN 70. DISPLAY "Wrong, the correct choice is" LINE 19 COLUMN 40 BELL CORRECT-CHOICE WITH CONVERSION COLUMN PLUS. IF LOGGING-ON AND NOT REVIEWING-ON PERFORM OUTPUT-LOG-RECORD. IF CURRENT-COUNT > 4 ADD 2 TO SCORE-WRONG ELSE IF CURRENT-COUNT > 2 ADD 1 TO SCORE-WRONG. * DISPLAY-TABLE. IF CORRECT-CHOICE < 2 IF STAND-VALUE = -9 DISPLAY "Always STAND" LINE 20 ELSE IF STAND-VALUE = 9 DISPLAY "Always HIT" LINE 20 ELSE DISPLAY "STAND if count is " LINE 20 STAND-VALUE WITH CONVERSION COLUMN PLUS " or greater, HIT otherwise" COLUMN PLUS. IF DOUBLE-POSSIBLE IF DOUBLE-VALUE = -9 DISPLAY "Always DOUBLE" LINE 21 ELSE IF DOUBLE-VALUE = 9 DISPLAY "Never DOUBLE" LINE 21 ELSE DISPLAY "DOUBLE if count is" LINE 21 DOUBLE-VALUE WITH CONVERSION COLUMN PLUS "or greater" COLUMN PLUS. IF SPLIT-POSSIBLE IF SPLIT-VALUE = -9 DISPLAY "Always SPLIT" LINE 22 ELSE IF SPLIT-VALUE = 9 DISPLAY "Never SPLIT" LINE 22 ELSE DISPLAY "SPLIT if count is" LINE 22 SPLIT-VALUE WITH CONVERSION COLUMN PLUS "or greater" COLUMN PLUS. IF SURRENDER-POSSIBLE IF SURRENDER-VALUE = -9 DISPLAY "Always SURRENDER" LINE 23 ELSE IF SURRENDER-VALUE = 9 DISPLAY "Never SURRENDER" LINE 23 ELSE DISPLAY "SURRENDER if count is" LINE 23 SURRENDER-VALUE WITH CONVERSION COLUMN PLUS "or greater" COLUMN PLUS. DISPLAY "with this hand against" COLUMN PLUS DCARD-DISP COLUMN PLUS. * RET-TO-CONTINUE. DISPLAY "Press return to continue (1=EXIT)" LINE 24. ACCEPT USER-CHOICE WITH CONVERSION COLUMN PLUS AT END STOP RUN. IF USER-CHOICE = 0 GO TO LOOP. * COMPUTE-WINS-AND-LOSSES. DISPLAY LOW-VALUES LINE 19 ERASE END SCREEN. IF SPECIAL-CASE-INPUT NOT = " " GO TO SPECIAL-END-PROGRAM. COMPUTE HANDS-PER-HOUR = DEALS-PER-HOUR * HANDS-PLAYED. COMPUTE WIN-PERCENTAGE ROUNDED = SCORE-CORRECT / (SCORE-CORRECT + SCORE-WRONG) - 0.97. IF CARD-COUNT-INPUT = "Y" ADD 0.03 TO WIN-PERCENTAGE. COMPUTE AMT-PER-HOUR ROUNDED = HANDS-PER-HOUR * USUAL-BET * WIN-PERCENTAGE. IF AMT-PER-HOUR < 0 MULTIPLY -1 BY AMT-PER-HOUR MOVE AMT-PER-HOUR TO AMT-OUT DISPLAY "Sorry, at your current playing level you will LOSE approximately" DISPLAY AMT-OUT " per hour of playing time - keep practicing!" ELSE MOVE AMT-PER-HOUR TO AMT-OUT DISPLAY "Congratulations! At your current playing level you will WIN about" DISPLAY AMT-OUT " per hour of playing time! - When do we leave?". * SPECIAL-END-PROGRAM. COMPUTE AMT-PER-HOUR ROUNDED = NUM-CORRECT * 100 / (NUM-CORRECT + NUM-WRONG). MOVE AMT-PER-HOUR TO PCT-OUT. DISPLAY " You got" PCT-OUT "% correct." IF CARD-COUNT-INPUT = "Y" COMPUTE AMT-PER-HOUR ROUNDED = SCORE-CORRECT * 100 / (SCORE-CORRECT + SCORE-WRONG). MOVE AMT-PER-HOUR TO PCT-OUT. DISPLAY " Your dollar win percentage was" PCT-OUT "% correct." STOP RUN. * SUBROUTINES SECTION. GET-CARD. CALL "MTH$RANDOM" USING RANDOM-SEED GIVING RANDOM-RETURN. COMPUTE RANDOM-VALUE ROUNDED = RANDOM-RETURN * 12 + 1. MOVE RANDOM-VALUE TO CARD-VALUE. MOVE CARD-VALUE TO CARD-NDISP. IF CARD-VALUE = 1 MOVE " A" TO CARD-DISP ELSE IF CARD-VALUE > 10 MOVE 10 TO CARD-VALUE IF RANDOM-VALUE = 11 MOVE " J" TO CARD-DISP ELSE IF RANDOM-VALUE = 12 MOVE " Q" TO CARD-DISP ELSE MOVE " K" TO CARD-DISP. * VARY-COUNT. CALL "MTH$RANDOM" USING RANDOM-SEED GIVING RANDOM-RETURN. COMPUTE CURRENT-COUNT ROUNDED = RANDOM-RETURN * 11 - 5. * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 * -5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5 * DISPLAY-CARDS-DEALT. DISPLAY "DEALER" LINE 5 DCARD-DISP COLUMN 15 "XX" COLUMN 25. DISPLAY "PLAYER" LINE 10 PCARD1-DISP COLUMN 15 PCARD2-DISP COLUMN 25. DISPLAY "Current count = " LINE 15 CURRENT-COUNT WITH CONVERSION COLUMN PLUS. * LOG-FILE-IO SECTION. OUTPUT-LOG-RECORD. MOVE CORRECT-CHOICE TO LCCHOICE. MOVE CURRENT-COUNT TO LCURCNT. MOVE STAND-VALUE TO LSTAND-VAL. MOVE SPLIT-VALUE TO LSPLIT-VAL. MOVE DOUBLE-VALUE TO LDOUBLE-VAL. MOVE SURRENDER-VALUE TO LSURR-VAL. MOVE FLAGS-VALUE TO LFLAGS-VAL. MOVE DCARD TO LDCARD. MOVE PCARD1 TO LPCARD1. MOVE PCARD2 TO LPCARD2. WRITE LOG-RECORD. READ-LOG-RECORD. READ LOG-FILE AT END MOVE SPACES TO DCARD MOVE "XX" TO LDCARD END-READ. IF LDCARD = SPACES GO TO READ-LOG-RECORD. IF LDCARD NOT = "XX" MOVE LCCHOICE TO CORRECT-CHOICE MOVE LCURCNT TO CURRENT-COUNT MOVE LSTAND-VAL TO STAND-VALUE MOVE LSPLIT-VAL TO SPLIT-VALUE MOVE LDOUBLE-VAL TO DOUBLE-VALUE MOVE LSURR-VAL TO SURRENDER-VALUE MOVE LFLAGS-VAL TO FLAGS-VALUE MOVE LDCARD TO DCARD MOVE LPCARD1 TO PCARD1 MOVE LPCARD2 TO PCARD2. REMOVE-LOG-RECORD. MOVE SPACES TO LDCARD. REWRITE LOG-RECORD. COPY-LOG-FILE. CLOSE LOG-FILE. OPEN INPUT LOG-FILE. OPEN OUTPUT LOG-FILE-2. PERFORM COPY-LOG-RECORD WITH TEST AFTER UNTIL LDCARD = "XX". CLOSE LOG-FILE LOG-FILE-2. CALL "LIB$DELETE_FILE" USING BY DESCRIPTOR "BJTRNR.LOG;-1". OPEN EXTEND LOG-FILE. COPY-LOG-RECORD. READ LOG-FILE AT END MOVE "XX" TO LDCARD. IF LDCARD NOT = "XX" AND LDCARD NOT = SPACES MOVE LOG-RECORD TO LOG2-RECORD WRITE LOG2-RECORD.