Author Topic: Blackjack  (Read 56306 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #240 on: July 09, 2020, 12:04:31 pm »
Quote
That makes sense. I do not think macOS can handle CHR$(0) at end–of–line. Internally only requires a linefeed character which I believe is CHR$(13).

Oh that's interesting, they end strings with... well CHR$(13) is Carriage Return, Line Feed is CHR$(10).

Is that true, is it a missing LF or CR? instead of CHR$(0) (always looking for the easy answer first!)

(About the macOS problems with UDT and/or variable length strings.)
« Last Edit: July 09, 2020, 12:07:35 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #241 on: July 09, 2020, 06:27:28 pm »
Dang! 10019 Rounds on 200 chips, everyone else out before 3000
 
Johnno doing good again.PNG


 
Johnno 10019 rounds!.PNG

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #242 on: July 10, 2020, 02:11:59 pm »
OK I found a way to stop the drain of chips. Maybe you can figure it out from this screen shot, each player started with 200 chips and bet 2 each round unless they Doubled Down. After 1000 rounds:
 
1 little rule change!.PNG


Now I am chipper!
« Last Edit: July 10, 2020, 02:14:17 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #243 on: July 11, 2020, 07:27:39 pm »
According to results found here in Multi-Tester #3 I am modifying the Blackjack Game for more fun!

Code: QB64: [Select]
  1. ' Started from code not using card images so:
  2. '            No suits shown for cards A is Ace, J, Q, K are Jack, Queen, King, X is for 10
  3. ' 2020-07-05 Fix hit (it wasn't broken), delete line chose$ = INKEY$ before loop
  4. '            force dealer to hit on 16 stay 17, ties are push, bring in double down option.
  5. '            Fix if dealer has Blackjack should tell also fix exposing 2nd card. Work this
  6. '            towards converting to multiple AI players, then all players stats are located
  7. '            in PlayerType and displayed with ShowPlayer (player) SUB.
  8. ' 2020-07-06 Installed AI and mods for it
  9. ' 2020-07-06 new Compact Tester with 2nd AI
  10. ' 2020-07-06 start Blackjack Multi AI Tester off of Compact Tester, add in allot of code worked
  11. '            out in Blackjack with Bots 2019-06-07.
  12. '            Yes, major overhaul of last year bot code which was/is neat!
  13. '            Thanks Johnno and Steve for some interesting AI ideas to try!
  14. ' 2020-07-07 For Blackjack Multi AI Tester #2, I hope to do something kind of interesting with
  15. '            displaying many players at one time.
  16. '            Yes Mouse over a player you want to check on but try and stay out of way of updating.
  17. ' 2020-07-08 BJ Multi AI Tester #3
  18. '            No overlapping players, sucks, get rid of timer stuff, removed.
  19. '            Screen Size depends on how many players go against Dealer from 1 to 6 maximum.
  20. '            1 row of players with screen width < 1024, Dealer at top.
  21. '            Added more items to Player type to display status solely from it's array contents.
  22. '            Also forbid player to double down if es chips can't cover loss.
  23. '            Display round number in Title Bar.
  24. ' 2020-07-08 added some basic stay strategies
  25. ' 2020-07-09 Some more fixes to Tester #3: Stop dealing cards to players without chips.
  26. '            Forbid DD if don't have chips to cover loss. Need Round number when run out of chips.
  27. '            First Johnno AI went over 10,000 rounds on 200 chips!
  28. ' 2020-07-10 I give up trying to find a strategy to stop draining a player of chips, so one
  29. '            little change in rules. ;-))  Something that Casinos would never do...
  30. ' 2020-07-11 Final adjustments to Tester #3
  31.  
  32. ' >>>>>>>>>>>  GOTO LINE #272 to adjust speed of play  uncomment _DELAY line
  33. ' >>>>>>>>>>> set to 1 or 2 to watch game play, .01 for fast round and watch chips
  34.  
  35. '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  36.  
  37. '  CAUTION: IN THE INTEREST OF HAVING FUN PLAYING THIS GAME, WE HAVE DEVIATED FROM CASINO RULES.
  38.  
  39. '   NEVER THINK YOUR EXPERIENCE PLAYING THIS GAME HERE WOULD BE LIKE PLAYING IN A REAL CASINO!
  40.  
  41. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  42.  
  43. ' Blackjack Multi-Tester Notes: (removed from screening at start)
  44.  
  45. '                              *** Blackjack Multi AI Tester #3 ***
  46. '
  47. '                     Each AI bot starts with 200 chips and bets 2 each round.
  48. '                                Dealer must hit on 16 or less.
  49. '                                 Blackjack pays 1.5 X the bet.
  50. '                       Double down option available when you get 2 cards.
  51. '                         It Doubles the bet and you get one more card.
  52. '
  53. '=================================================================================================
  54.  
  55. DEFINT A-Z
  56.  
  57. CONST nPlayers = 7 '            2 to 7 only! Dealer counts as the last player
  58. CONST rank$ = "A23456789XJQK" ' for building deck and figuring Totals
  59. CONST bH = 12, bW = 20 '        box height and box width in rows and columns
  60.  
  61. TYPE PlayerType '         Goal: Put everything in PlayerType that showPlayer needs for display
  62.     ID AS STRING '        name of bot including dealer bot
  63.     Col AS INTEGER '      left corner column for player box
  64.     Row AS INTEGER '      top row for player box
  65.     FC AS _UNSIGNED LONG 'player colors are assigned in init FC are alternating Black and White
  66.     BC AS _UNSIGNED LONG 'random light and dark opposite print FC
  67.     Hand AS STRING '      cards are 1 char strings 10 is X
  68.     Ace AS INTEGER '      flag ace for totaling hand
  69.     Bust AS INTEGER '     flag for final reckoning
  70.     BJ AS INTEGER '       flag for final reckoning
  71.     Tot AS INTEGER '      card total of hand
  72.     Chips AS _INTEGER64 ' players status
  73.     SetBet AS _INTEGER64 'regular bet amount if enough chips to cover
  74.     Bet AS _INTEGER64 '   players bet each round maybe updated by DD
  75.     Tell AS STRING '      Hit, Stay Double or Win Push Loss Amt
  76.     RunOut AS DOUBLE '    Round player runs out of chips
  77.  
  78. DIM SHARED p(1 TO nPlayers) AS PlayerType '        contains player data for processing and display
  79. DIM SHARED xmax '              Screen size _WIDTH is adjusted to number of players and stored here
  80. DIM SHARED deck$(1 TO 52), deckIndex '                         cards are just string * 1 see rank$
  81. DIM SHARED round AS LONG, allOut, plr, blockDealer, session
  82. DIM results(1 TO 6)
  83.  
  84. DIM i, chose$
  85. initGame
  86. FOR session = 1 TO 20
  87.     DO 'start a round
  88.         startRound 'clears screen too and shuffles deck
  89.  
  90.         FOR i = 1 TO 2
  91.             FOR plr = 1 TO nPlayers 'each Player is dealt 2 cards
  92.                 IF plr <> nPlayers THEN
  93.                     IF p(plr).Chips > 0 THEN
  94.                         allOut = 0 'signal everyone is out of chips is false
  95.                         PlayerAddCard plr
  96.                     END IF
  97.                 ELSE
  98.                     IF allOut THEN
  99.                         showPlayer nPlayers 'final chip count = 0 ? when all is said and done
  100.                         EXIT DO
  101.                     ELSE
  102.                         PlayerAddCard plr
  103.                     END IF
  104.                 END IF
  105.             NEXT
  106.         NEXT
  107.  
  108.         IF p(nPlayers).BJ = 0 THEN 'dealer does not have BJ
  109.             FOR plr = 1 TO nPlayers - 1
  110.                 IF p(plr).Chips > 0 THEN 'make sure player still can bet
  111.                     showPlayer plr
  112.                     WHILE p(plr).Tot < 21
  113.                         SELECT CASE plr ' this has to be coded for exactly all nPlayers - 1
  114.  
  115.                             'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV Insert AI subs here !!!!!!!
  116.                             CASE 1: chose$ = bplusAI$(plr)
  117.                             CASE 2: chose$ = bplusAI2$(plr)
  118.                             CASE 3: chose$ = bplusAI3$(plr)
  119.                             CASE 4: chose$ = stay18$(plr)
  120.                             CASE 5: chose$ = stay17$(plr)
  121.                             CASE 6: chose$ = Johnno2$(plr) 'no more than 6 bots
  122.  
  123.                         END SELECT
  124.                         IF chose$ = "h" THEN p(plr).Tell = "Hit"
  125.                         IF chose$ = "d" THEN p(plr).Tell = "Double Down"
  126.                         IF chose$ <> "h" AND chose$ <> "d" THEN p(plr).Tell = "Stay"
  127.                         showPlayer plr
  128.                         IF chose$ = "h" THEN
  129.                             PlayerAddCard plr
  130.                         ELSEIF chose$ = "d" AND LEN(p(plr).Hand) = 2 THEN
  131.                             IF p(plr).Chips >= 2 * p(plr).Bet THEN '  chips to cover a DD?
  132.                                 p(plr).Bet = 2 * p(plr).Bet
  133.                                 PlayerAddCard plr
  134.                                 EXIT WHILE
  135.                             ELSE 'if not play it like a hit
  136.                                 PlayerAddCard plr
  137.                             END IF
  138.                         ELSE 'stayed
  139.                             EXIT WHILE
  140.                         END IF
  141.                     WEND
  142.                 END IF
  143.             NEXT
  144.         END IF
  145.  
  146.         blockDealer = 0
  147.         showPlayer nPlayers '                 nPlayers is Dealer player number
  148.         WHILE p(nPlayers).Tot < 17
  149.             p(nPlayers).Tell = "Dealer hits"
  150.             showPlayer nPlayers
  151.             PlayerAddCard nPlayers
  152.         WEND
  153.         p(nPlayers).Tell = "Reckoning"
  154.         showPlayer nPlayers
  155.  
  156.         '    final Reckoning
  157.         FOR plr = 1 TO nPlayers - 1
  158.             IF p(plr).Chips > 0 THEN
  159.                 showPlayer plr
  160.                 IF (p(plr).BJ AND p(nPlayers).BJ) OR (p(plr).Bust AND p(nPlayers).Bust) THEN
  161.                     p(plr).Tell = "Push"
  162.                 ELSEIF p(plr).Tot > 21 OR (p(plr).Tot < p(nPlayers).Tot AND p(nPlayers).Tot < 22) THEN
  163.                     p(plr).Tell = "Lost" + STR$(p(plr).Bet)
  164.                     p(plr).Chips = p(plr).Chips - p(plr).Bet
  165.                     p(nPlayers).Chips = p(nPlayers).Chips + p(plr).Bet
  166.                 ELSEIF p(plr).Tot = p(nPlayers).Tot AND p(plr).BJ = 0 THEN
  167.                     p(plr).Tell = "Push"
  168.                 ELSE
  169.                     IF p(plr).BJ THEN
  170.                         p(plr).Tell = "Win!" + STR$(p(plr).Bet + .5 * p(plr).Bet)
  171.                         p(plr).Chips = p(plr).Chips + p(plr).Bet + .5 * p(plr).Bet
  172.                         p(nPlayers).Chips = p(nPlayers).Chips - p(plr).Bet - .5 * p(plr).Bet
  173.                     ELSE
  174.                         p(plr).Tell = "Win!" + STR$(p(plr).Bet)
  175.                         p(plr).Chips = p(plr).Chips + p(plr).Bet
  176.                         p(nPlayers).Chips = p(nPlayers).Chips - p(plr).Bet
  177.                     END IF
  178.                 END IF
  179.                 showPlayer plr
  180.                 IF p(plr).Chips = 0 THEN
  181.                     p(plr).RunOut = round
  182.                     p(plr).Tell = "Out of chips!"
  183.                     showPlayer plr
  184.                 END IF
  185.             END IF
  186.         NEXT
  187.     LOOP UNTIL allOut OR round = 1000 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Control # rounds !!!!!!!!!!!!
  188.     round = 0
  189.     COLOR &HFFCCCCFF, &HFF008822: CLS: _DISPLAY
  190.     FOR plr = 1 TO 6
  191.         LOCATE plr + 3, 5: PRINT p(plr).ID
  192.     NEXT
  193.     FOR plr = 1 TO 6
  194.         results(plr) = results(plr) + p(plr).Chips - 200 'the chips started with
  195.         LOCATE plr + 3, 17: PRINT results(plr)
  196.         p(plr).Chips = 200 'reset chips to start amount
  197.     NEXT
  198.     _DISPLAY
  199.  
  200. SUB startRound
  201.     DIM i
  202.     round = round + 1: allOut = -1
  203.     FOR i = 1 TO nPlayers
  204.         p(i).Hand = ""
  205.         p(i).Ace = 0
  206.         p(i).Tot = 0
  207.         p(i).BJ = 0
  208.         p(i).Bust = 0
  209.         p(i).Tell = ""
  210.         'because of DD option I have to reset bet during play and set it back at each new round
  211.         'make sure we aren't betting more than our chips count at least to start
  212.         IF p(i).Chips < p(i).SetBet THEN p(i).Bet = p(i).Chips ELSE p(i).Bet = p(i).SetBet
  213.     NEXT
  214.     FOR i = 52 TO 2 STEP -1 'shuffle
  215.         SWAP deck$(INT(RND * i) + 1), deck$(i)
  216.     NEXT
  217.     'deck$(7) = "A": deck$(14) = "J"  'check immediate show of Blackjack for dealer
  218.     deckIndex = 0: blockDealer = -1
  219.     _TITLE "BJ AI Tester #3 - Session:" + STR$(session) + "  Round:" + STR$(round)
  220.  
  221. SUB PlayerAddCard (rec) 'updates player's hand and total
  222.     DIM i AS INTEGER, cv AS INTEGER
  223.     deckIndex = deckIndex + 1
  224.     p(rec).Hand = p(rec).Hand + deck$(deckIndex)
  225.     IF deck$(deckIndex) = "A" THEN p(rec).Ace = -1
  226.     p(rec).Tot = 0
  227.     FOR i = 1 TO LEN(p(rec).Hand)
  228.         IF INSTR(rank$, MID$(p(rec).Hand, i, 1)) > 10 THEN
  229.             cv = 10
  230.         ELSE
  231.             cv = INSTR(rank$, MID$(p(rec).Hand, i, 1))
  232.         END IF
  233.         p(rec).Tot = p(rec).Tot + cv
  234.     NEXT
  235.     IF p(rec).Tot < 12 AND p(rec).Ace THEN p(rec).Tot = p(rec).Tot + 10
  236.     IF LEN(p(rec).Hand) = 2 AND p(rec).Tot = 21 THEN p(rec).BJ = -1
  237.     IF p(rec).Tot > 21 THEN p(rec).Bust = -1
  238.     showPlayer rec 'when ever add card show update
  239.  
  240. SUB showPlayer (nP) '
  241.     DIM i AS INTEGER, S$
  242.     COLOR p(nP).FC, p(nP).BC
  243.     FOR i = 0 TO bH - 1 'clear our block
  244.         LOCATE p(nP).Row + i, p(nP).Col: PRINT SPACE$(bW);
  245.     NEXT
  246.     cp nP, 1, p(nP).ID
  247.     cp nP, 3, "Chips:" + STR$(p(nP).Chips)
  248.     IF nP <> nPlayers THEN cp nP, 4, "Bet:" + STR$(p(nP).Bet)
  249.     FOR i = 1 TO LEN(p(nP).Hand)
  250.         S$ = S$ + MID$(p(nP).Hand, i, 1) + " "
  251.     NEXT
  252.     IF nP = nPlayers AND LEN(p(nP).Hand) = 2 AND p(nP).Tot <> 21 AND blockDealer THEN
  253.         S$ = LEFT$(S$, 2) + "?"
  254.         cp nP, 6, S$
  255.         cp nP, 7, "Total: ??"
  256.     ELSE
  257.         cp nP, 6, S$
  258.         cp nP, 7, "Total:" + STR$(p(nP).Tot)
  259.     END IF
  260.     IF p(nP).Bust THEN cp nP, 8, "Busted"
  261.     IF p(nP).BJ THEN cp nP, 8, "Blackjack"
  262.     IF p(nP).RunOut THEN cp nP, 9, "Round" + STR$(p(nP).RunOut)
  263.     cp nP, 10, p(nP).Tell ' last action of player or dealer or final win lost push
  264.     _DISPLAY
  265.    272 '_DELAY 1 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< modify this line for speed !!!!!!!!
  266.  
  267. SUB initGame 'the stuff that never changes
  268.     CONST startChips = 200
  269.     DIM i
  270.     ' 1+13*2 rows = 27*16 = 432 ymax
  271.     xmax = ((nPlayers - 1) * 21 + 1) * 8
  272.     SCREEN _NEWIMAGE(xmax, 432, 32)
  273.     _DELAY .25
  274.  
  275.     'dealer on top row then max 2 rows of 5 players
  276.     FOR i = 1 TO nPlayers
  277.         IF i <> nPlayers THEN
  278.             SELECT CASE i 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV  plug in ai names here !!!!!!!!
  279.                 CASE 1: p(i).ID = "b1 s17 dd1"
  280.                 CASE 2: p(i).ID = "b2 s17 dd2"
  281.                 CASE 3: p(i).ID = "b3 s17 dd3"
  282.                 CASE 4: p(i).ID = "s18"
  283.                 CASE 5: p(i).ID = "s17"
  284.                 CASE 6: p(i).ID = "johnno 2"
  285.             END SELECT
  286.             p(i).Col = 2 + (i - 1) * 21
  287.             p(i).Row = 15
  288.             p(i).Chips = startChips
  289.             p(i).SetBet = 2
  290.             IF i MOD 2 THEN
  291.                 p(i).BC = _RGB32(RND * 128, RND * 60, RND * 128)
  292.             ELSE
  293.                 p(i).BC = _RGB32(RND * 128 + 127, 255 - RND * 95, RND * 128 + 127)
  294.             END IF
  295.             IF i MOD 2 THEN p(i).FC = &HFFFFFFFF ELSE p(i).FC = &HFF000000
  296.         ELSE
  297.             p(i).ID = "Dealer"
  298.             p(i).Col = (xmax \ 8 - 20) \ 2 + 1
  299.             p(i).Row = 2
  300.             p(i).Chips = -startChips * (nPlayers - 1)
  301.             p(i).BC = &HFF000000
  302.             p(i).FC = &HFFFFFFFF
  303.         END IF
  304.     NEXT
  305.     FOR i = 1 TO 52 'get deck ready
  306.         deck$(i) = MID$(rank$ + rank$ + rank$ + rank$, i, 1)
  307.     NEXT
  308.     COLOR &HFFCCCCFF, &HFF008822: CLS
  309.  
  310. SUB cp (nPlayer, row, s AS STRING) 'center print a string on the given row
  311.     IF nPlayer THEN
  312.         COLOR p(nPlayer).FC, p(nPlayer).BC
  313.         LOCATE p(nPlayer).Row + row, p(nPlayer).Col + (bW - LEN(s)) / 2: PRINT s;
  314.     END IF
  315.  
  316. ' ===========  AI storage Area #51   stay 16 or 17 are contenders  various DD options
  317.  
  318. ' After looking at Dealer stats I like Stay 16 though test runs like Stay 17 same as dealer.
  319. ' So I am tryig Stay 16 with 3 different DD options only when Dealer is showing
  320. ' card below 10 and no Ace!
  321.  
  322. ' Dang Stay 17 Domimates! Changed all to Stay 17, much better!
  323.  
  324. FUNCTION bplusAI$ (pn) ' mod after looking at stats, Stay 16 DD1
  325.     DIM m
  326.     SELECT CASE p(pn).Tot
  327.         CASE 11 ' won't bust but could be a pretty low card to gamble on
  328.             IF LEN(p(pn).Hand) = 2 THEN
  329.                 m = INSTR(rank$, LEFT$(p(nPlayers).Hand, 1))
  330.                 IF m <> 1 AND m < 7 THEN bplusAI$ = "d" ELSE bplusAI$ = "h"
  331.             ELSE
  332.                 bplusAI$ = "h"
  333.             END IF
  334.         CASE IS < 17
  335.             bplusAI$ = "h"
  336.     END SELECT
  337.  
  338. FUNCTION bplusAI2$ (pN) 'after trying some stats DD very restricted, Stay 16
  339.     DIM m
  340.     SELECT CASE p(pN).Tot
  341.         CASE 10, 11 'double down unless dealer showing an Ace or 10's
  342.             IF LEN(p(pN).Hand) = 2 THEN
  343.                 m = INSTR(rank$, LEFT$(p(nPlayers).Hand, 1))
  344.                 IF m <> 1 AND m < 7 THEN bplusAI2$ = "d" ELSE bplusAI2$ = "h"
  345.             ELSE
  346.                 bplusAI2$ = "h"
  347.             END IF
  348.         CASE IS < 17: bplusAI2$ = "h"
  349.     END SELECT
  350.  
  351. FUNCTION bplusAI3$ (pn) ' first try modified to stay 16 plus dd on 11 only
  352.     DIM m
  353.     SELECT CASE p(pn).Tot 'try 9 instead of 12 for 3rd DD card
  354.         CASE 10, 11, 12 'double down unless dealer showing an Ace or high #'s
  355.             IF LEN(p(pn).Hand) = 2 THEN
  356.                 m = INSTR(rank$, LEFT$(p(nPlayers).Hand, 1))
  357.                 IF m <> 1 AND m < 7 THEN bplusAI3$ = "d" ELSE bplusAI3$ = "h"
  358.             ELSE
  359.                 bplusAI3$ = "h"
  360.             END IF
  361.         CASE IS < 17: bplusAI3$ = "h"
  362.     END SELECT
  363.  
  364. FUNCTION Johnno$ (pN) ' this was doing well before the Bust Rule changed but not now
  365.     IF p(pN).Tot = 10 OR p(pN).Tot = 11 AND LEN(p(pN).Hand) = 2 THEN
  366.         Johnno$ = "d"
  367.     ELSEIF p(pN).Tot = 10 OR p(pN).Tot = 11 AND LEN(p(pN).Hand) <> 2 THEN
  368.         Johnno$ = "h"
  369.     ELSEIF 12 <= p(pN).Tot AND p(pN).Tot <= 15 THEN
  370.         SELECT CASE LEFT$(p(nPlayers).Hand, 1)
  371.             CASE "A", "K", "Q", "J", "X", "9": Johnno$ = "h"
  372.             CASE "7", "8": IF RND < .5 THEN Johnno$ = "h"
  373.             CASE ELSE: Johnno$ = "Hope to Bust em"
  374.         END SELECT
  375.     ELSEIF p(pN).Tot < 12 THEN
  376.         Johnno$ = "h"
  377.     ELSE
  378.         Johnno$ = "Stay"
  379.     END IF
  380.  
  381. FUNCTION Johnno2$ (pN) ' DD2 stay 13 depends 14-16
  382.     IF p(pN).Tot = 10 OR p(pN).Tot = 11 AND LEN(p(pN).Hand) = 2 THEN
  383.         Johnno2$ = "d"
  384.     ELSEIF p(pN).Tot = 10 OR p(pN).Tot = 11 AND LEN(p(pN).Hand) <> 2 THEN
  385.         Johnno2$ = "h"
  386.     ELSEIF 14 <= p(pN).Tot AND p(pN).Tot <= 16 THEN
  387.         SELECT CASE LEFT$(p(nPlayers).Hand, 1)
  388.             CASE "A", "K", "Q", "J", "X", "9": Johnno2$ = "h"
  389.             CASE "7", "8": IF RND < .5 THEN Johnno2$ = "h"
  390.             CASE ELSE: Johnno2$ = "Hope to Bust em"
  391.         END SELECT
  392.     ELSEIF p(pN).Tot < 14 THEN
  393.         Johnno2$ = "h"
  394.     ELSE
  395.         Johnno2$ = "Stay"
  396.     END IF
  397.  
  398. ' =================================  pure Stay Strategies no DD options
  399.  
  400. 'not a contender
  401. FUNCTION stay12$ (pN) 'how simple is this! never bust make dealer work for it
  402.     IF p(pN).Tot < 12 THEN stay12$ = "h"
  403.  
  404. FUNCTION stay16$ (pN) 'definite contender, no longer! try 18 instead
  405.     IF p(pN).Tot < 16 THEN stay16$ = "h"
  406. FUNCTION stay17$ (pN) 'definite contender really does well
  407.     IF p(pN).Tot < 17 THEN stay17$ = "h"
  408.  
  409. FUNCTION stay18$ (pN) 'was not a contender before changed player Bust Rule
  410.     IF p(pN).Tot < 18 THEN stay18$ = "h"
  411.  
« Last Edit: July 11, 2020, 07:29:52 pm by bplus »

Marked as best answer by bplus on July 15, 2020, 11:36:09 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #244 on: July 15, 2020, 03:25:02 pm »
I have modified the B&J Blackjack Game collaboration with Johnno with that one little rule change that casino's would never do.

"If both you and the dealer bust then it is a push."  That's all I changed, so now if you both get Blackjack or if you both bust, it is a push.

Now if you have a decent strategy of Blackjack play you can hold your own against the dealer.

* BJ v2020-07-11.zip (Filesize: 4.13 MB, Downloads: 339)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Blackjack
« Reply #245 on: July 15, 2020, 07:03:43 pm »
Cool... But, my biggest problem, is holding on to my chips! Hey. My AI counterpart plays better than I can. Maybe it can create tutorials on how to play? lol  Nice job!
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #246 on: July 15, 2020, 08:09:57 pm »
Hi @johnno56

Try this: always hit on less than 17, Double Down if you have 10 or 11 and Dealer has less than 8. That won't work in a casino but should be more than OK with latest version.

Always bet the same amount, never think you will get lucky or are due to. If you DD you will have to click back you regular amount bet otherwise just keep clicking your regular bet. Have a pot of coffee ready because it sometimes takes a while for the math to kick in. I hit a streak where the Dealer was getting Blackjack every other hand! 5 BJ's in 10 rounds! I thought God was trying to tell me something ;-)) then I got 2 in a row, what a night then maybe 10 rounds later 4 BJs in a row Dealer got 3 I got 1, crazy!
« Last Edit: July 15, 2020, 08:14:05 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Blackjack
« Reply #247 on: July 16, 2020, 12:46:50 pm »
This is an INCREDIBLE game! Very professional. I like the sounds the most. But I do have a question, how long can it play for? When do you win or lose the whole game? Maybe I didn't see my total correctly but it had me playing even in negative numbers.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #248 on: July 16, 2020, 01:03:30 pm »
You can play forever Ken!

The game tracks the chips you have under the name you are playing.

You will win Jackpot Blackjack every 170 rounds or so (RND average), it is 50 X's whatever you are betting at that moment.

« Last Edit: July 16, 2020, 01:05:38 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Blackjack
« Reply #249 on: July 16, 2020, 01:46:10 pm »
Edit:
Great game!
I just deleted my idea from here because you guys have worked so hard on this, I don't want to add to your frustration.
« Last Edit: July 16, 2020, 04:06:21 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Blackjack
« Reply #250 on: July 16, 2020, 01:52:05 pm »
Don't get me wrong though, this is still fun to play!

Note: I just deleted my idea from the above post. I don't want to add to your frustration. Must have taken a very long time to get this far on such a good game.
« Last Edit: July 16, 2020, 04:08:15 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Blackjack
« Reply #251 on: July 16, 2020, 02:27:29 pm »
I also like how you used an icon for Windows. I need to try that someday. :)

FellippeHeitor

  • Guest
Re: Blackjack
« Reply #252 on: July 16, 2020, 02:39:01 pm »
You guys have done a great job with this one. Kudos to all involved!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Blackjack
« Reply #253 on: July 16, 2020, 11:11:52 pm »
Playing great! (the game, not me).  Enjoyable game.  Ya'll did a great job.

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Blackjack
« Reply #254 on: January 12, 2021, 11:30:59 am »
This is nice bplus :)

Is there any chance in making a Special Black Jack version that Tests Card counting Methods,Best Strategies,Etc. ?



How To Count Cards...
https://www.blackjackapprenticeship.com/how-to-count-cards

My interest in this started a long,long time ago probably the same time I got interested in Chess,and getting Computers to play better than Humans at various games.
And the one person that got me interested in Black Jack was Edward O. Thorp and his Beat the Dealer: A Winning Strategy for the Game of Twenty-One...

https://www.powells.com/book/beat-the-dealer-9780394703107
https://en.wikipedia.org/wiki/Edward_O._Thorp

A.R.B :)


Thanks A.R.B.

Sure it's possible to simulate Blackjack as it's played in Vegas or somewhere else just code the rules of the game you want to simulate.

Please do not mistake this game here as anything like the real thing. This game is way too generous with rules and of course the Blackjack Jackpot! Also different, 1 deck that is shuffled before each round and it is only you against the house dealer.

If are seriously considering playing in real games, it is a good idea to practice with simulations as real as possible.

When I was coding this, I skipped the Split Option because it seemed a nightmare lot of work for the one option of play.