Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 5 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/usr/bin/python3
  2. # plays the wizard's ace-five count
  3. # <http://wizardofodds.com/games/blackjack/appendix/17/>
  4. # with the simple strategy at
  5. # <http://wizardofodds.com/games/blackjack/appendix/21/>
  6. #
  7. #
  8. # Player's hand Dealer's upcard
  9. #
  10. # -- hard --------------------------------
  11. # 2 to 6 7 to A
  12. # 4 to 8 H H
  13. # 9 D H
  14. # 10 or 11 D with more than dealer
  15. # 12 to 16 S H
  16. # 17 to 21 S S
  17. #
  18. # -- soft --------------------------------
  19. # 2 to 6 7 to A
  20. # 13 to 15 H H
  21. # 16 to 18 D H
  22. # 19 to 21 S S
  23. #
  24. # -- split -------------------------------
  25. # 2 to 6 7 to A
  26. # 22,33,66,77,99 Y N
  27. # 88,AA Y Y
  28. # 44,55,TT N N
  29. #
  30. # Plus:
  31. # 1. surrender 16 vs 10
  32. # 2. never take insurance
  33. # 3. if not allowed to double, stand with soft 18
  34. #
  35. import sys
  36. max_bet = 32
  37. n_player_cards = 0
  38. count = 0
  39. bet = 1
  40. import fileinput
  41. for linenl in fileinput.input():
  42. line = linenl.rstrip()
  43. #print("<- %s" % line, file = sys.stderr)
  44. if line == "bye":
  45. sys.exit(0)
  46. elif line == "shuffling":
  47. count = 0
  48. bet = 1
  49. elif line[:8] == "new_hand":
  50. n_player_cards = 0
  51. elif line == "insurance?":
  52. print("no", flush = True)
  53. elif line == "bet?":
  54. #if count <= 1:
  55. #bet = 1
  56. #elif bet < max_bet:
  57. #bet *= 2
  58. #print(bet, flush = True)
  59. print("1", flush = True)
  60. elif line[:15] == "player_split_ok":
  61. n_player_cards = 1
  62. elif line[:5] == "card_":
  63. tokens = line.split()
  64. if (len(tokens) > 1):
  65. card = tokens[1][0]
  66. else:
  67. card = ""
  68. # count aces and fives
  69. if card == "A":
  70. count -= 1
  71. elif card == "5":
  72. count += 1
  73. if line[:11] == "card_player":
  74. n_player_cards += 1
  75. if n_player_cards == 1:
  76. card_player_first = card
  77. elif n_player_cards == 2:
  78. card_player_second = card
  79. elif line[:5] == "play?":
  80. tokens = line.split()
  81. player = int(tokens[1])
  82. dealer = abs(int(tokens[2]))
  83. action = "quit"
  84. #print("player_cards %d" % n_player_cards, file = sys.stderr)
  85. #print("card_player_first %s" % card_player_first, file = sys.stderr)
  86. #print("card_player_second %s" % card_player_second, file = sys.stderr)
  87. if n_player_cards == 2 and card_player_first == card_player_second and \
  88. ((card_player_first == "8" or card_player_first == "A") or \
  89. (dealer < 7 and \
  90. (card_player_first == "2" or \
  91. card_player_first == "3" or \
  92. card_player_first == "6" or \
  93. card_player_first == "7" or \
  94. card_player_first == "9"))): # --- split------------------------------------
  95. action = "split" # always split aces and 8s but 2,3,6,7 & 9 only against 6 or less
  96. else:
  97. if player > 0: # --- hard ------------------------------------
  98. if player < 9:
  99. action = "hit" # hit 4 to 8 against anything
  100. elif player == 9:
  101. if dealer < 7:
  102. if n_player_cards == 2:
  103. action = "double" # double 9 against 2 to 6
  104. else:
  105. action = "hit" # else hit
  106. else:
  107. action = "hit" # hit 9 against 7 to A
  108. elif player < 12:
  109. if player > dealer:
  110. if n_player_cards == 2:
  111. action = "double" # double with 10 or 11 and more than dealer
  112. else:
  113. action = "hit"
  114. else:
  115. action = "hit" # otherwise hit
  116. elif player < 17:
  117. if dealer < 7:
  118. action = "stand" # stand with 12 to 16 against 2 to 6
  119. else:
  120. action = "hit" # hit with 12 to 16 against 7 to A
  121. else:
  122. action = "stand" # stand with hard 17 or more
  123. else:
  124. # soft
  125. player = abs(player)
  126. if player < 16:
  127. action = "hit" # hit every soft hand less than 16
  128. elif player < 19:
  129. if dealer < 7:
  130. if n_player_cards == 2:
  131. action = "double" # double soft 16 to 18 againt 2 to 6
  132. elif player == 18:
  133. action = "stand" # stand with soft 18
  134. else:
  135. action = "hit" # hit soft 17
  136. else:
  137. action = "hit" # hit soft 16 to 18 against 7 to A
  138. else:
  139. action = "stand" # stand with soft 19 or more
  140. print(action, flush = True)
  141. #print("-> %s" % action, file = sys.stderr)
  142. elif line == "invalid_command":
  143. print("I sent an invalid command!", file = sys.stderr)