A
$ git clone https://github.com/pwildenhain/blackjack.git
$ cd blackjack
$ pipenv install
$ python -m blackjack
Play :spades: blackjack :spades: in the terminal
License: MIT License
Attributes:
Deck()
Dealer()
list
of Player()
instancesMethods:
Blackjack.play_game()
: see rules below
blackjack/__main__.py
while
loop to continue playing until done, asking players if they want to cash out, add more money, or continueBlackjack.take_bets()
: Take bets from Blackjack.players
. Store info about bets in respective Player()
classes
Blackjack.deal()
: Deal one card to each player.hand
and then a facedown card to dealer.hand
Blackjack.play_round()
: Play a single round of blackjack. Call the Blackjack.players.player.play()
Blackjack.dealer.play()
methods
Need to add hidden
attribute and design for planning + printing hidden card
See here for strategy: https://stackoverflow.com/questions/5850268/how-to-test-or-mock-if-name-main-contents
Do this before implementing player and dealer classes
✔️ Make sure there are tests before proceeding
Dealer.play(deck: Deck)
method
Dealer.hand
Dealer.hit(card: Card)
until Dealer.total >= 17
Attributes:
bank
: The amount of 💰 player has leftbet
: Amount player bet on a hand moves
: {0: "hit", 1: "stay"}
for now, maybe add more laterself.choose_move(self)
:
self.play(self, deck: Deck)
:
keep_playing =
self.choose_move() == "hit"
and self.total < 21
while keep_playing
self.hit(card=deck.pop())
if self.total >= 21: break
keep_playing = self.choose_move() == "hit"
Need to add a reshuffle method into Blackjack
that gets automatically called in between rounds (if necessary)
This way the Player()
and Dealer()
instances can be created before any cards are dealt. Needs to be the case if the players are going to make bets before getting dealt cards.
♻️ The Role.hand
attribute needs to become a property with the @property.setter
method that recalculates the Role.total
each time a card is added.
♻️ Take the self.set_ace_value()
out of Role.__init__()
This is will a chance to bring code coverage back to 💯 and maybe even improve the test suite after reading my cool 😎 new ✨ pytest
book 📖
A lot of logic in Blackjack.play_round()
right now, especially with who wins the round -- consider moving this to a separate method Blackjack.determine_winner
or something like that.
Boolean property (or attribute?) that determines whether or not the Role.hand >= 21
Ask for inputs like
Returns
Blackjack
instance ready to have Blackjack.play_game()
calledA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.