8.5 KiB
8.5 KiB
# !git clone https://github.com/hamidshojaee/BlackJackSim.git
from BlackJackSim.BlackJack import *
table = Table()
table.players.append(Player())
for i in range(0, 5):
table.playRound()
print(table.printVerboseResults())
table.reset()
Dealer FaceCard = 10, Total = 17, BJ = False, Bust = False, Cards = [10, 2, 5], Player 1, Hand 1, Total = 20, BJ = False, Bust = False, Cards = [10, 10], Actions = [<PlayOptions.STAY: 1>], HandResults.WIN Dealer FaceCard = 10, Total = 15, BJ = False, Bust = False, Cards = [10, 5], Player 1, Hand 1, Total = 25, BJ = False, Bust = True, Cards = [2, 1, 10, 2, 10], Actions = [<PlayOptions.HIT: 2>, <PlayOptions.HIT: 2>, <PlayOptions.HIT: 2>, <PlayOptions.STAY: 1>], HandResults.LOST Dealer FaceCard = 7, Total = 19, BJ = False, Bust = False, Cards = [7, 7, 5], Player 1, Hand 1, Total = 19, BJ = False, Bust = False, Cards = [3, 2, 10, 4], Actions = [<PlayOptions.HIT: 2>, <PlayOptions.HIT: 2>, <PlayOptions.STAY: 1>], HandResults.PUSH Dealer FaceCard = 2, Total = 17, BJ = False, Bust = False, Cards = [2, 10, 4, 1], Player 1, Hand 1, Total = 20, BJ = False, Bust = False, Cards = [10, 10], Actions = [<PlayOptions.STAY: 1>], HandResults.WIN Dealer FaceCard = 1, Total = 18, BJ = False, Bust = False, Cards = [1, 3, 4], Player 1, Hand 1, Total = 16, BJ = False, Bust = False, Cards = [9, 2, 5], Actions = [<PlayOptions.DOUBLE: 3>], HandResults.DOUBLELOSS
table = Table()
table.players.append(Player())
for i in range(0, 1): # Simulates 1,000 rounds of BlackJack
table.playRound()
dealer_face_card, dealer_total, dealer_is_blackjack, dealer_is_bust, dealer_cards, players = table.getVerboseResults()
player_id, hands = players
hand_id, player_total, player_is_blackjack, player_is_bust, player_cards, player_actions, hand_result = hands
print(dealer_face_card, dealer_total, dealer_is_blackjack, dealer_is_bust, dealer_cards, player_id, hand_id, player_total, player_is_blackjack, player_is_bust, player_cards, player_actions, hand_result)
# Fix incorrect player action if player is busted
if player_is_bust:
player_actions = player_actions[:-1]
if str(player_actions[-1])[12:] == 'STAY':
print(sum(player_cards))
print(player_cards)
if str(player_actions[-1])[12:] == 'HIT' or str(player_actions[-1])[12:] == 'DOUBLE':
print(sum(player_cards[:-1]))
print(player_cards[:-1])
# if len(player_cards) == 2:
# print(player_cards)
# if len(player_cards) > 2:
# print(player_cards[:-1])
if len(player_actions) > 0:
print(str(player_actions[-1])[12:])
print(str(hand_result)[12:])
# for player_id, hands in players:
# for hand_id, player_total, player_is_blackjack, player_is_bust, player_cards, player_actions, hand_result in hands:
# print(dealer_face_card, dealer_total, dealer_is_blackjack, dealer_is_bust, dealer_cards, player_id, hand_id, player_total, player_is_blackjack, player_is_bust, player_cards, player_actions, hand_result)
table.reset()
1 21 True False [1, 10] 1 1 15 False False [1, 4] [] HandResults.LOST
[1;31m---------------------------------------------------------------------------[0m [1;31mIndexError[0m Traceback (most recent call last) [1;32md:\studia\blackjack-fuzzy\stats.ipynb Cell 4[0m in [0;36m<cell line: 3>[1;34m()[0m [0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=11'>12</a>[0m [39mif[39;00m player_is_bust: [0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=12'>13</a>[0m player_actions [39m=[39m player_actions[:[39m-[39m[39m1[39m] [1;32m---> <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=14'>15</a>[0m [39mif[39;00m [39mstr[39m(player_actions[[39m-[39;49m[39m1[39;49m])[[39m12[39m:] [39m==[39m [39m'[39m[39mSTAY[39m[39m'[39m: [0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=15'>16</a>[0m [39mprint[39m([39msum[39m(player_cards)) [0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=16'>17</a>[0m [39mprint[39m(player_cards) [1;31mIndexError[0m: list index out of range
[dealer_face_card, dealer_total, dealer_is_blackjack, dealer_is_bust, [dealer_cards], [player_id, [hand_id, player_total, player_is_blackjack, player_is_bust, [player_cards], [player_actions], hand_result]]]
[1;31m---------------------------------------------------------------------------[0m [1;31mNameError[0m Traceback (most recent call last) [1;32md:\studia\blackjack-fuzzy\stats.ipynb Cell 7[0m in [0;36m<cell line: 1>[1;34m()[0m [1;32m----> <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=0'>1</a>[0m [dealer_face_card, dealer_total, dealer_is_blackjack, dealer_is_bust, [dealer_cards], [player_id, [hand_id, player_total, player_is_blackjack, player_is_bust, [player_cards], [player_actions], hand_result]]] [1;31mNameError[0m: name 'dealer_face_card' is not defined
table = Table()
table.players.append(Player())
for i in range(0, 1): # Simulates 1,000 rounds of BlackJack
table.playRound()
# print(str(i) + ", " + table.printShortResults())
print(table.printShortResults())
table.reset()
7, 2, 1, 13, True, False, False, PlayOptions.HIT, HandResults.WIN, 1.0
# 4 tabele