diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..be72b42
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..4646aab
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+blackjack
\ No newline at end of file
diff --git a/.idea/blackjack.iml b/.idea/blackjack.iml
new file mode 100644
index 0000000..ec65220
--- /dev/null
+++ b/.idea/blackjack.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..da36f54
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..23b3126
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..fd010cc
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,406 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1439748272711
+
+ 1439748272711
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.ipynb_checkpoints/BlackJack-checkpoint.ipynb b/.ipynb_checkpoints/BlackJack-checkpoint.ipynb
new file mode 100644
index 0000000..a675822
--- /dev/null
+++ b/.ipynb_checkpoints/BlackJack-checkpoint.ipynb
@@ -0,0 +1,210 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "import random"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Deck:\n",
+ " def __init__(self, deck):\n",
+ " self.deck = deck"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Player:\n",
+ " def __init__(self, deck):\n",
+ " self.hand = []\n",
+ " self.money = 100\n",
+ " self.deck = deck\n",
+ " \n",
+ " def draw_card(self):\n",
+ " self.hand.append(random.choice(self.deck.deck))\n",
+ "\n",
+ " def hand_value(self):\n",
+ " if 1 in self.hand:\n",
+ " if 7 <= sum(self.hand) <= 11:\n",
+ " return sum(self.hand) + 10\n",
+ " return sum(self.hand)\n",
+ "\n",
+ " def dealer_hit_or_stay(self):\n",
+ " for _ in range(10):\n",
+ " if self.hand_value() < 17:\n",
+ " self.draw_card()\n",
+ "\n",
+ " def player_hit_or_stay(self):\n",
+ " choice = input(\"Enter 'h' to Hit or just 'Enter' to Stay. \").lower()\n",
+ " if choice == 'h':\n",
+ " self.draw_card()\n",
+ " self.player_hit_or_stay()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Game:\n",
+ " def __init__(self, player1, player2):\n",
+ " self.player1 = player1\n",
+ " self.player2 = player2\n",
+ " \n",
+ " def __str__(self):\n",
+ " pass\n",
+ "\n",
+ " def begin_game(self):\n",
+ " print(\"Player funds = ${}\".format(player1.money))\n",
+ " print(\"Dealing cards\")\n",
+ " for _ in range(2):\n",
+ " player1.draw_card()\n",
+ " player2.draw_card()\n",
+ " if player1.hand_value() == 21:\n",
+ " if player2.hand_value() == 21:\n",
+ " print(\"Player and Dealer have BlackJack!\")\n",
+ " print(\"Game is a tie\")\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Player wins with BlackJack!\")\n",
+ " player1.money += 10\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " elif player2.hand_value() == 21:\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Dealer wins with BlackJack!\")\n",
+ " player1.money -= 10\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " else:\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer shows\", player2.hand[0])\n",
+ " game.game_continue()\n",
+ " \n",
+ " def game_continue(self):\n",
+ " player1.dealer_hit_or_stay()\n",
+ " player2.dealer_hit_or_stay()\n",
+ " game.winner()\n",
+ "\n",
+ " \n",
+ " def play_again(self):\n",
+ " play_choice = input(\"Play again? Enter 'Y'es or just Enter to quit\").lower()\n",
+ " print(\"___________________________________________________________\")\n",
+ " if play_choice == 'y':\n",
+ " player1.hand = []\n",
+ " player2.hand = []\n",
+ " game.begin_game()\n",
+ " else:\n",
+ " return(\"Your final dollar amount is ${}\".format(player1.money))\n",
+ " enter(\"Press Enter to exit\")\n",
+ " #os.system(\"clear\")\n",
+ "\n",
+ " def winner(self):\n",
+ " if player1.hand_value() > 21:\n",
+ " if player2.hand_value() > 21:\n",
+ " print(\"Player and Dealer have both gone bust\")\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " player1.money -= 10\n",
+ " print(\"Player has gone bust. Dealer wins\")\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " elif player2.hand_value() > 21:\n",
+ " player1.money += 10\n",
+ " print(\"Dealer has gone bust. Player wins\")\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " elif player1.hand_value() > player2.hand_value():\n",
+ " player1.money += 10\n",
+ " print(\"Player is the winner with a score of {}.\".format(self.player1.hand_value()))\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " elif player2.hand_value() > player1.hand_value():\n",
+ " player1.money -= 10\n",
+ " print(\"Dealer is the winner with a score of {}.\".format(self.player2.hand_value()))\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " else:\n",
+ " print(\"It's a tie. Player {} / Dealer {}\".format(self.player1.hand_value(), self.player2.hand_value()))\n",
+ " game.show_cards()\n",
+ "\n",
+ " def show_cards(self):\n",
+ " print(\"Player hand was\", player1.hand, \"with a total score of\", player1.hand_value())\n",
+ " print(\"Dealer hand was\", player2.hand, \"with a total score of\", player2.hand_value())\n",
+ " game.play_again()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "\n",
+ "deck = Deck(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10])\n",
+ "player1 = Player(deck)\n",
+ "player2 = Player(deck)\n",
+ "game = Game(player1, player2)\n",
+ "game.begin_game()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "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.4.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/.ipynb_checkpoints/ClassJack-checkpoint.ipynb b/.ipynb_checkpoints/ClassJack-checkpoint.ipynb
new file mode 100644
index 0000000..7b411be
--- /dev/null
+++ b/.ipynb_checkpoints/ClassJack-checkpoint.ipynb
@@ -0,0 +1,368 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "import random"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Deck:\n",
+ " def __init__(self, deck):\n",
+ " self.deck = deck"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Player:\n",
+ " def __init__(self, deck):\n",
+ " self.hand = []\n",
+ " self.money = 100\n",
+ " self.deck = deck\n",
+ " \n",
+ " def draw_card(self):\n",
+ " self.hand.append(random.choice(self.deck.deck))\n",
+ "\n",
+ " def hand_value(self):\n",
+ " if 1 in self.hand:\n",
+ " if 7 <= sum(self.hand) <= 11:\n",
+ " return sum(self.hand) + 10\n",
+ " return sum(self.hand)\n",
+ "\n",
+ " def dealer_hit_or_stay(self):\n",
+ " for _ in range(10):\n",
+ " if self.hand_value() < 17:\n",
+ " self.draw_card()\n",
+ "\n",
+ " def player_hit_or_stay(self):\n",
+ " choice = input(\"Enter 'h' to Hit or just 'Enter' to Stay. \").lower()\n",
+ " if choice == 'h':\n",
+ " self.draw_card()\n",
+ " self.player_hit_or_stay()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Game:\n",
+ " def __init__(self, player1, player2):\n",
+ " self.player1 = player1\n",
+ " self.player2 = player2\n",
+ " \n",
+ " def __str__(self):\n",
+ " pass\n",
+ "\n",
+ " def begin_game(self):\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " print(\"Dealing cards\")\n",
+ " for _ in range(2):\n",
+ " player1.draw_card()\n",
+ " player2.draw_card()\n",
+ " if player1.hand_value() == 21:\n",
+ " if player2.hand_value() == 21:\n",
+ " print(\"Player and Dealer have BlackJack!\")\n",
+ " print(\"Game is a tie\")\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " print(\"Player wins with BlackJack!\")\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " player1.money += 10\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " elif player2.hand_value() == 21:\n",
+ " print(\"Dealer wins with BlackJack!\")\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " player1.money -= 10\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " else:\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer shows\", player2.hand[0])\n",
+ " \n",
+ " def play_again(self):\n",
+ " play_choice = input(\"Play again? Enter 'Y'es or just Enter to quit\").lower()\n",
+ " if play_choice == y:\n",
+ " player1.hand = []\n",
+ " player2.hand = []\n",
+ " self.begin_game()\n",
+ " else:\n",
+ " return(\"Your final dollar amount is ${}\".format(player.money))\n",
+ " enter(\"Press Enter to exit\")\n",
+ " os.system(\"clear\")\n",
+ "\n",
+ " def winner(self):\n",
+ " if player1.hand_value() > 21:\n",
+ " if player2.hand_value() > 21:\n",
+ " return \"Player and Dealer have both busted\"\n",
+ " player1.money -= 10\n",
+ " return \"Player has gone bust. Dealer wins\"\n",
+ " elif self.player2.hand_value() > 21:\n",
+ " player1.money += 10\n",
+ " return \"Dealer has gone bust. Player wins\"\n",
+ " elif self.player1.hand > self.player2.hand:\n",
+ " player1.money += 10\n",
+ " return(\"Player is the winner with a score of {}.\".format(self.player1.hand_value()))\n",
+ " elif self.player2.hand > self.player1.hand:\n",
+ " player1.money -= 10\n",
+ " return(\"Dealer is the winner with a score of {}.\".format(self.player2.hand_value()))\n",
+ " else:\n",
+ " return(\"It's a tie. Player {} / Dealer {}\".format(self.player1.hand_value(), self.player2.hand_value()))\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Player funds = $ 100\n",
+ "Dealing cards\n",
+ "Player hand [1, 2]\n",
+ "Dealer shows 10\n",
+ "Player has $100\n"
+ ]
+ }
+ ],
+ "source": [
+ "deck = Deck(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10])\n",
+ "player1 = Player(deck)\n",
+ "player2 = Player(deck)\n",
+ "game = Game(player1, player2)\n",
+ "game.begin_game()\n",
+ "player1.dealer_hit_or_stay()\n",
+ "player2.dealer_hit_or_stay()\n",
+ "game.winner()\n",
+ "print(\"Player has ${}\".format(player1.money))\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "player1.player_hit_or_stay()\n",
+ "print(player1.hand_value())\n",
+ "print(player1.hand)\n",
+ "player1.player_hit_or_stay()\n",
+ "print(player1.hand_value())\n",
+ "print(player1.hand)\n",
+ "player1.player_hit_or_stay()\n",
+ "print(player1.hand_value())\n",
+ "print(player1.hand)\n",
+ "player1.player_hit_or_stay()\n",
+ "print(player1.hand_value())\n",
+ "print(player1.hand)\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "player1.draw_card()\n",
+ "player1.dealer_hit_or_stay()\n",
+ "player1.dealer_hit_or_stay()\n",
+ "player1.dealer_hit_or_stay()\n",
+ "player1.dealer_hit_or_stay()\n",
+ "print(player1.hand)\n",
+ "print(player1.hand_value())\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "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.4.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/.ipynb_checkpoints/Joel assistance-checkpoint.ipynb b/.ipynb_checkpoints/Joel assistance-checkpoint.ipynb
new file mode 100644
index 0000000..4d52a11
--- /dev/null
+++ b/.ipynb_checkpoints/Joel assistance-checkpoint.ipynb
@@ -0,0 +1,141 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 182,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "ename": "TypeError",
+ "evalue": "object of type 'NoneType' has no len()",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mdeck\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshuffle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdeck\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 19\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/random.py\u001b[0m in \u001b[0;36mshuffle\u001b[0;34m(self, x, random)\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mrandom\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 268\u001b[0m \u001b[0mrandbelow\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_randbelow\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 269\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mreversed\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 270\u001b[0m \u001b[0;31m# pick an element in x[:i+1] with which to exchange x[i]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 271\u001b[0m \u001b[0mj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrandbelow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mTypeError\u001b[0m: object of type 'NoneType' has no len()"
+ ]
+ }
+ ],
+ "source": [
+ "# Cards includes a list of 52 regular cards with no Jokers\n",
+ "import random\n",
+ "\n",
+ "whole_deck = ['A of clubs', 'K of clubs', 'Q of clubs', 'J of clubs', '10 of clubs',\n",
+ " '9 of clubs', '8 of clubs', '7 of clubs', '6 of clubs', '5 of clubs',\n",
+ " '4 of clubs', '3 of clubs', '2 of clubs', 'A of hearts', 'K of hearts',\n",
+ " 'Q of hearts', 'J of hearts', '10 of hearts', '9 of hearts', '8 of hearts',\n",
+ " '7 of hearts', '6 of hearts', '5 of hearts', '4 of hearts', '3 of hearts',\n",
+ " '2 of hearts', 'A of diamonds', 'K of diamonds', 'Q of diamonds',\n",
+ " 'J of diamonds', '10 of diamonds', '9 of diamonds', '8 of diamonds',\n",
+ " '7 of diamonds', '6 of diamonds', '5 of diamonds', '4 of diamonds',\n",
+ " '3 of diamonds', '2 of diamonds', 'A of spades', 'K of spades',\n",
+ " 'Q of spades', 'J of spades', '10 of spades', '9 of spades', '8 of spades',\n",
+ " '7 of spades', '6 of spades', '5 of spades', '4 of spades', '3 of spades',\n",
+ " '2 of spades']\n",
+ "\n",
+ "\n",
+ "deck = whole_deck\n",
+ "\n",
+ "\n",
+ "# played_cards = []\n",
+ "\n",
+ "live_card = deck.pop()\n",
+ "\n",
+ "\n",
+ "random.shuffle(lst)\n",
+ "\n",
+ "random.shuffle(deck)\n",
+ "print(deck)\n",
+ "print(live_card)\n",
+ " \n",
+ " \n",
+ "live_card not in deck == True"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "ename": "KeyboardInterrupt",
+ "evalue": "",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/site-packages/IPython/kernel/zmq/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 675\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 676\u001b[0;31m \u001b[0mident\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreply\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msession\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstdin_socket\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 677\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/site-packages/IPython/kernel/zmq/session.py\u001b[0m in \u001b[0;36mrecv\u001b[0;34m(self, socket, mode, content, copy)\u001b[0m\n\u001b[1;32m 718\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 719\u001b[0;31m \u001b[0mmsg_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msocket\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv_multipart\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 720\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mzmq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mZMQError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/site-packages/zmq/sugar/socket.py\u001b[0m in \u001b[0;36mrecv_multipart\u001b[0;34m(self, flags, copy, track)\u001b[0m\n\u001b[1;32m 339\u001b[0m \"\"\"\n\u001b[0;32m--> 340\u001b[0;31m \u001b[0mparts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mflags\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrack\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtrack\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 341\u001b[0m \u001b[0;31m# have first part already, only loop while more to receive\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:5785)\u001b[0;34m()\u001b[0m\n",
+ "\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:5585)\u001b[0;34m()\u001b[0m\n",
+ "\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket._recv_copy (zmq/backend/cython/socket.c:1738)\u001b[0;34m()\u001b[0m\n",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/site-packages/zmq/backend/cython/checkrc.pxd\u001b[0m in \u001b[0;36mzmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:6035)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mcdef\u001b[0m \u001b[0mint\u001b[0m \u001b[0merrno\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mzmq_errno\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mPyErr_CheckSignals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 12\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mrc\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: ",
+ "\nDuring handling of the above exception, another exception occurred:\n",
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0ma_string\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 16\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Word? \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 17\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/site-packages/IPython/kernel/zmq/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 649\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 650\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 651\u001b[0;31m \u001b[0mpassword\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 652\u001b[0m )\n\u001b[1;32m 653\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;32m/Users/jeffreyhacker/Documents/Python/Iron_Yard/homework/blackjack/.direnv/python-3.4.3/lib/python3.4/site-packages/IPython/kernel/zmq/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 679\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 680\u001b[0m \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 681\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 682\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 683\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
+ ]
+ }
+ ],
+ "source": [
+ "\n",
+ "''''''class Decide:\n",
+ " def is_empty(self, word):\n",
+ " if len(word) == 0:\n",
+ " return True\n",
+ " else:\n",
+ " return\n",
+ "\n",
+ "def a_func(a_string):\n",
+ " decision = Decide()\n",
+ " if decision.is_empty(a_string):\n",
+ " return(\"\")\n",
+ " else:\n",
+ " return a_string[0]\n",
+ "\n",
+ "print(a_func(input(\"Word? \")))''\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "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.4.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/BlackJack.ipynb b/BlackJack.ipynb
new file mode 100644
index 0000000..a675822
--- /dev/null
+++ b/BlackJack.ipynb
@@ -0,0 +1,210 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "import random"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Deck:\n",
+ " def __init__(self, deck):\n",
+ " self.deck = deck"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Player:\n",
+ " def __init__(self, deck):\n",
+ " self.hand = []\n",
+ " self.money = 100\n",
+ " self.deck = deck\n",
+ " \n",
+ " def draw_card(self):\n",
+ " self.hand.append(random.choice(self.deck.deck))\n",
+ "\n",
+ " def hand_value(self):\n",
+ " if 1 in self.hand:\n",
+ " if 7 <= sum(self.hand) <= 11:\n",
+ " return sum(self.hand) + 10\n",
+ " return sum(self.hand)\n",
+ "\n",
+ " def dealer_hit_or_stay(self):\n",
+ " for _ in range(10):\n",
+ " if self.hand_value() < 17:\n",
+ " self.draw_card()\n",
+ "\n",
+ " def player_hit_or_stay(self):\n",
+ " choice = input(\"Enter 'h' to Hit or just 'Enter' to Stay. \").lower()\n",
+ " if choice == 'h':\n",
+ " self.draw_card()\n",
+ " self.player_hit_or_stay()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "class Game:\n",
+ " def __init__(self, player1, player2):\n",
+ " self.player1 = player1\n",
+ " self.player2 = player2\n",
+ " \n",
+ " def __str__(self):\n",
+ " pass\n",
+ "\n",
+ " def begin_game(self):\n",
+ " print(\"Player funds = ${}\".format(player1.money))\n",
+ " print(\"Dealing cards\")\n",
+ " for _ in range(2):\n",
+ " player1.draw_card()\n",
+ " player2.draw_card()\n",
+ " if player1.hand_value() == 21:\n",
+ " if player2.hand_value() == 21:\n",
+ " print(\"Player and Dealer have BlackJack!\")\n",
+ " print(\"Game is a tie\")\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Player wins with BlackJack!\")\n",
+ " player1.money += 10\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " elif player2.hand_value() == 21:\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer hand \", player2.hand)\n",
+ " print(\"Dealer wins with BlackJack!\")\n",
+ " player1.money -= 10\n",
+ " print(\"Player funds = $\", player1.money)\n",
+ " self.play_again()\n",
+ " else:\n",
+ " print(\"Player hand \", player1.hand)\n",
+ " print(\"Dealer shows\", player2.hand[0])\n",
+ " game.game_continue()\n",
+ " \n",
+ " def game_continue(self):\n",
+ " player1.dealer_hit_or_stay()\n",
+ " player2.dealer_hit_or_stay()\n",
+ " game.winner()\n",
+ "\n",
+ " \n",
+ " def play_again(self):\n",
+ " play_choice = input(\"Play again? Enter 'Y'es or just Enter to quit\").lower()\n",
+ " print(\"___________________________________________________________\")\n",
+ " if play_choice == 'y':\n",
+ " player1.hand = []\n",
+ " player2.hand = []\n",
+ " game.begin_game()\n",
+ " else:\n",
+ " return(\"Your final dollar amount is ${}\".format(player1.money))\n",
+ " enter(\"Press Enter to exit\")\n",
+ " #os.system(\"clear\")\n",
+ "\n",
+ " def winner(self):\n",
+ " if player1.hand_value() > 21:\n",
+ " if player2.hand_value() > 21:\n",
+ " print(\"Player and Dealer have both gone bust\")\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " player1.money -= 10\n",
+ " print(\"Player has gone bust. Dealer wins\")\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " elif player2.hand_value() > 21:\n",
+ " player1.money += 10\n",
+ " print(\"Dealer has gone bust. Player wins\")\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " elif player1.hand_value() > player2.hand_value():\n",
+ " player1.money += 10\n",
+ " print(\"Player is the winner with a score of {}.\".format(self.player1.hand_value()))\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " elif player2.hand_value() > player1.hand_value():\n",
+ " player1.money -= 10\n",
+ " print(\"Dealer is the winner with a score of {}.\".format(self.player2.hand_value()))\n",
+ " print(\"Player has ${}\".format(player1.money))\n",
+ " game.show_cards()\n",
+ " else:\n",
+ " print(\"It's a tie. Player {} / Dealer {}\".format(self.player1.hand_value(), self.player2.hand_value()))\n",
+ " game.show_cards()\n",
+ "\n",
+ " def show_cards(self):\n",
+ " print(\"Player hand was\", player1.hand, \"with a total score of\", player1.hand_value())\n",
+ " print(\"Dealer hand was\", player2.hand, \"with a total score of\", player2.hand_value())\n",
+ " game.play_again()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "\n",
+ "deck = Deck(deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10])\n",
+ "player1 = Player(deck)\n",
+ "player2 = Player(deck)\n",
+ "game = Game(player1, player2)\n",
+ "game.begin_game()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "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.4.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/BlackJackLogic.numbers b/BlackJackLogic.numbers
new file mode 100644
index 0000000..5fbfe20
Binary files /dev/null and b/BlackJackLogic.numbers differ
diff --git a/README.md b/README.md
index e5d7b00..36b9d10 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
# Blackjack
-* [Part 1](README_1.md)
-* [Part 2](README_2.md)
\ No newline at end of file
+## blackjack.ipynb: An Ipython Notebook version of BlackJack
+## blackjack.py: A self-playing version of BlackJack. Run with Python3
diff --git a/README_1.md b/README_1.md
deleted file mode 100644
index 3d3e96d..0000000
--- a/README_1.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# Blackjack, Part I
-
-## Description
-
-Plan how to create a game of blackjack.
-
-## Objectives
-
-### Learning Objectives
-
-After completing this assignment, you should understand:
-
-* Object-oriented design.
-
-### Performance Objectives
-
-After completing this assignment, you should be able to:
-
-* Design a system using responsibilities and collaborators.
-* Turn your design into objects.
-
-## Details
-
-### Deliverables
-
-* A Git repo called blackjack containing at least:
- * a `README.md` file explaining your design.
- * a `blackjack` directory with a file for each of your classes, with
- their responsibilities and collaborators described in a comment
- * a completed Card and Deck class
- * tests for Cards and Decks
-
-### Requirements
-
-* Passing unit tests
-* No PEP8 or Pyflakes warnings or errors
-* Use the project layout from _The Hacker's Guide to Python_
-
-## Normal Mode
-
-Read through [the rules of blackjack](https://en.wikipedia.org/wiki/Blackjack)
-carefully. After reading through them, write out the steps to run the game in
-outline format. (See the additional resources for more on the rules of
-blackjack.)
-
-After that, go through your steps and find all the actors -- that is, nouns
-that take actions. Create class-responsibility-collaborator (CRC) cards for
-each and then create empty classes for each of them with the responsibilities
-and collaborators at the top as a comment. Here is an example that you might
-find in `blackjack/card.py`:
-
-```py
-class Card:
- """A playing card.
-
- Responsibilities:
-
- * Has a rank and a suit.
- * Has a point value. Aces point values depend on the Hand.
-
- Collaborators:
-
- * Collected into a Deck.
- * Collected into a Hand for each player and a Hand for the dealer.
- """
-```
-
-Lastly, implement the `Card` and `Deck` classes.
-
-## Additional Resources
-
-* Other Blackjack rule summaries:
- * http://www.pagat.com/banking/blackjack.html
- * http://wizardofodds.com/games/blackjack/basics/#toc-Rules
-* [Portland Pattern Repository page on CRC cards](http://c2.com/cgi/wiki?CrcCard)
-* [A Brief Tour of Responsibility-Driven Design](http://www.wirfs-brock.com/PDFs/A_Brief-Tour-of-RDD.pdf)
diff --git a/README_2.md b/README_2.md
deleted file mode 100644
index 1e6c0bb..0000000
--- a/README_2.md
+++ /dev/null
@@ -1,77 +0,0 @@
-# Blackjack
-
-## Description
-
-Implement the game of Blackjack.
-
-## Objectives
-
-### Learning Objectives
-
-After completing this assignment, you should understand:
-
-* how to track state by using objects
-
-### Performance Objectives
-
-After completing this assignment, you should be able to:
-
-* Build an interactive game
-* Test an object-oriented program
-
-## Details
-
-### Deliverables
-
-* A Git repo called blackjack containing at least:
- * `README.rst` file explaining how to run your project
- * a `requirements.txt` file
- * a full suite of tests for your project
-
-### Requirements
-
-* Passing unit tests
-* No PEP8 or Pyflakes warnings or errors
-
-## Normal Mode
-
-Take your notes and code from [the previous project](README_1.md). Using those,
-create a game of Blackjack that one person plays on the command line against a
-computer dealer, with the following rules:
-
-* The game should start the player with $100 and bets are $10.
-* The only valid moves are hit and stand.
-* Allow the player to keep playing as long as they have money.
-* The dealer uses one deck in their shoe and reshuffles after each round.
-
-## Hard Mode
-
-In addition to the requirements from **Normal Mode**:
-
-* The dealer uses a shoe of six decks. With a shoe, the dealer uses something called a _cut card_. A plastic card is inserted somewhere near the bottom of the shoe. Once it is hit, the shoe is reshuffled at the end of the round. You can simulate this by reshuffling after there are 26 or less cards left in the shoe.
-* The player can choose how much they want to bet before each round.
-* Add doubling-down.
-* Add surrender (early surrender as opposed to late surrender.)
-* Add [insurance](https://en.wikipedia.org/wiki/Blackjack#Insurance).
-* Add splitting hands.
-
-## Nightmare Mode
-
-In addition to the requirements from **Hard Mode**:
-
-* Add the ability to choose rulesets, like:
- * No surrender/early surrender/late surrender.
- * Dealer hits soft 17 vs dealer stands of soft 17.
- * Number of decks used in the shoe.
-
-Each choice should be able to be made separately.
-
-## Notes
-
-This is again an assignment with a text-based interface, which can be very hard
-to test. You will do best at this assignment by building all the logic for each
-piece and testing it well before then adding the interface on top of it.
-
-## Additional Resources
-
-* [Building Skills in Object-Oriented Design](http://www.itmaybeahack.com/book/oodesign-python-2.1/html/index.html)
diff --git a/blackjack.py b/blackjack.py
new file mode 100644
index 0000000..8b42504
--- /dev/null
+++ b/blackjack.py
@@ -0,0 +1,137 @@
+import random
+import os
+
+
+class Deck:
+ def __init__(self, deck):
+ self.deck = deck
+
+
+class Player:
+ def __init__(self, deck):
+ self.hand = []
+ self.money = 100
+ self.deck = deck
+
+ def draw_card(self):
+ self.hand.append(random.choice(self.deck.deck))
+
+ def hand_value(self):
+ if 1 in self.hand:
+ if 7 <= sum(self.hand) <= 11:
+ return sum(self.hand) + 10
+ return sum(self.hand)
+
+ def dealer_hit_or_stay(self):
+ for _ in range(10):
+ if self.hand_value() < 17:
+ self.draw_card()
+
+ def player_hit_or_stay(self):
+ choice = input("Enter 'h' to Hit or just 'Enter' to Stay. ").lower()
+ if choice == 'h':
+ self.draw_card()
+ self.player_hit_or_stay()
+
+
+class Game:
+ def __init__(self, player1, player2):
+ self.player1 = player1
+ self.player2 = player2
+
+
+ def begin_game(self):
+ import os
+ os.system("clear")
+ print ("Player has ${} to play with:".format(player1.money))
+ print("Dealing cards...")
+ for _ in range(2):
+ player1.draw_card()
+ player2.draw_card()
+ if player1.hand_value() == 21:
+ if player2.hand_value() == 21:
+ print("Player and Dealer have BlackJack!")
+ print("Game is a tie")
+ print("Player hand ", player1.hand)
+ print("Dealer hand ", player2.hand)
+ print("Player funds = $", player1.money)
+ self.play_again()
+ print("Player wins with BlackJack!")
+ print("Player hand ", player1.hand)
+ print("Dealer hand ", player2.hand)
+ player1.money += 10
+ print("Player funds = $", player1.money)
+ self.play_again()
+ elif player2.hand_value() == 21:
+ print("Dealer wins with BlackJack!")
+ print("Player hand ", player1.hand)
+ print("Dealer hand ", player2.hand)
+ player1.money -= 10
+ print("Player funds = $", player1.money)
+ self.play_again()
+ else:
+ print("Player hand ", player1.hand)
+ print("Dealer is showing a [{}]".format(player2.hand[0]))
+ game.game_continue()
+
+ def game_continue(self):
+ player1.dealer_hit_or_stay()
+ player2.dealer_hit_or_stay()
+ game.winner()
+
+ def play_again(self):
+ play_choice = input("Play again? Enter 'Y'es or just Enter to quit").lower()
+ if play_choice == 'y':
+ player1.hand = []
+ player2.hand = []
+ game.begin_game()
+ else:
+ print("Your final dollar amount is ${}".format(player1.money))
+ #return
+
+
+ def winner(self):
+ if player1.hand_value() > 21:
+ player1.money -= 10
+ print("Player has gone bust")
+ if player2.hand_value() > 21:
+ print("Dealer has also gone bust")
+ player1.money += 10
+ print("Player has ${}".format(player1.money))
+ game.show_cards()
+ return
+ print("Player has ${}".format(player1.money))
+ game.show_cards()
+ elif player2.hand_value() > 21:
+ player1.money += 10
+ print("Dealer has gone bust. Player wins")
+ print("Player has ${}".format(player1.money))
+ game.show_cards()
+ elif player1.hand_value() > player2.hand_value():
+ player1.money += 10
+ print("Player is the winner with a score of {}.".format(self.player1.hand_value()))
+ print("Player has ${}".format(player1.money))
+ game.show_cards()
+ elif player2.hand_value() > player1.hand_value():
+ player1.money -= 10
+ print("Dealer is the winner with a score of {}.".format(self.player2.hand_value()))
+ print("Player has ${}".format(player1.money))
+ game.show_cards()
+ else:
+ print("It's a tie. Player {} / Dealer {}".format(self.player1.hand_value(), self.player2.hand_value()))
+ game.show_cards()
+
+ def show_cards(self):
+ print("Player hand ", player1.hand, "total score", player1.hand_value())
+ print("Dealer hand ", player2.hand, "total score", player2.hand_value())
+ if player1.money == 0:
+ print("Sorry, you are out of money. You'll have to start the game again.")
+ return
+ else:
+ game.play_again()
+
+deck = Deck(deck=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10])
+player1 = Player(deck)
+player2 = Player(deck)
+game = Game(player1, player2)
+game.begin_game()
diff --git a/blackjack/.DS_Store b/blackjack/.DS_Store
new file mode 100644
index 0000000..bdd9633
Binary files /dev/null and b/blackjack/.DS_Store differ
diff --git a/docs/.gitkeep b/docs/.gitkeep
deleted file mode 100644
index e69de29..0000000