Sim update
This commit is contained in:
parent
5b44348bfa
commit
8a4c81f988
207
stats.ipynb
Normal file
207
stats.ipynb
Normal file
@ -0,0 +1,207 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# !git clone https://github.com/hamidshojaee/BlackJackSim.git"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from BlackJackSim.BlackJack import * "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 135,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"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\n",
|
||||
"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\n",
|
||||
"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\n",
|
||||
"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\n",
|
||||
"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\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"table = Table()\n",
|
||||
"table.players.append(Player())\n",
|
||||
"for i in range(0, 5):\n",
|
||||
" table.playRound()\n",
|
||||
" print(table.printVerboseResults())\n",
|
||||
" table.reset()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 142,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1 21 True False [1, 10] 1 1 15 False False [1, 4] [] HandResults.LOST\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "IndexError",
|
||||
"evalue": "list index out of range",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[1;32md:\\studia\\blackjack-fuzzy\\stats.ipynb Cell 4\u001b[0m in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=11'>12</a>\u001b[0m \u001b[39mif\u001b[39;00m player_is_bust:\n\u001b[0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=12'>13</a>\u001b[0m player_actions \u001b[39m=\u001b[39m player_actions[:\u001b[39m-\u001b[39m\u001b[39m1\u001b[39m]\n\u001b[1;32m---> <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=14'>15</a>\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mstr\u001b[39m(player_actions[\u001b[39m-\u001b[39;49m\u001b[39m1\u001b[39;49m])[\u001b[39m12\u001b[39m:] \u001b[39m==\u001b[39m \u001b[39m'\u001b[39m\u001b[39mSTAY\u001b[39m\u001b[39m'\u001b[39m:\n\u001b[0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=15'>16</a>\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39msum\u001b[39m(player_cards))\n\u001b[0;32m <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=16'>17</a>\u001b[0m \u001b[39mprint\u001b[39m(player_cards)\n",
|
||||
"\u001b[1;31mIndexError\u001b[0m: list index out of range"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"table = Table()\n",
|
||||
"table.players.append(Player())\n",
|
||||
"for i in range(0, 1): # Simulates 1,000 rounds of BlackJack\n",
|
||||
" table.playRound()\n",
|
||||
" dealer_face_card, dealer_total, dealer_is_blackjack, dealer_is_bust, dealer_cards, players = table.getVerboseResults()\n",
|
||||
" player_id, hands = players\n",
|
||||
" hand_id, player_total, player_is_blackjack, player_is_bust, player_cards, player_actions, hand_result = hands\n",
|
||||
"\n",
|
||||
" 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)\n",
|
||||
"\n",
|
||||
" # Fix incorrect player action if player is busted\n",
|
||||
" if player_is_bust:\n",
|
||||
" player_actions = player_actions[:-1]\n",
|
||||
"\n",
|
||||
" if str(player_actions[-1])[12:] == 'STAY':\n",
|
||||
" print(sum(player_cards))\n",
|
||||
" print(player_cards)\n",
|
||||
"\n",
|
||||
" if str(player_actions[-1])[12:] == 'HIT' or str(player_actions[-1])[12:] == 'DOUBLE':\n",
|
||||
" print(sum(player_cards[:-1]))\n",
|
||||
" print(player_cards[:-1])\n",
|
||||
"\n",
|
||||
" # if len(player_cards) == 2:\n",
|
||||
" # print(player_cards)\n",
|
||||
" \n",
|
||||
" # if len(player_cards) > 2:\n",
|
||||
" # print(player_cards[:-1])\n",
|
||||
"\n",
|
||||
" if len(player_actions) > 0:\n",
|
||||
" print(str(player_actions[-1])[12:])\n",
|
||||
"\n",
|
||||
" print(str(hand_result)[12:])\n",
|
||||
"\n",
|
||||
" # for player_id, hands in players:\n",
|
||||
" # for hand_id, player_total, player_is_blackjack, player_is_bust, player_cards, player_actions, hand_result in hands:\n",
|
||||
" # 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)\n",
|
||||
"\n",
|
||||
" table.reset()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "NameError",
|
||||
"evalue": "name 'dealer_face_card' is not defined",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[1;32md:\\studia\\blackjack-fuzzy\\stats.ipynb Cell 7\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/d%3A/studia/blackjack-fuzzy/stats.ipynb#W6sZmlsZQ%3D%3D?line=0'>1</a>\u001b[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]]]\n",
|
||||
"\u001b[1;31mNameError\u001b[0m: name 'dealer_face_card' is not defined"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[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]]]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"7, 2, 1, 13, True, False, False, PlayOptions.HIT, HandResults.WIN, 1.0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"table = Table()\n",
|
||||
"table.players.append(Player())\n",
|
||||
"for i in range(0, 1): # Simulates 1,000 rounds of BlackJack\n",
|
||||
" table.playRound()\n",
|
||||
" # print(str(i) + \", \" + table.printShortResults())\n",
|
||||
" print(table.printShortResults())\n",
|
||||
" table.reset()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 4 tabele"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.2"
|
||||
},
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "b239acf2821489c398a9848859e84ce39b99d30cc4031fb37cc7461da3883639"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Loading…
Reference in New Issue
Block a user