theonlysam / blackjack

MIT License
0 stars 0 forks source link

How to handle Ace? #4

Open bbelderbos opened 1 year ago

bbelderbos commented 1 year ago
          Checked Ben's repo quickly and he has this:
    def card_value(self):
        if self.rank in "J Q K".split():
            return 10
        elif self.rank == "A":
            return (1, 11)
        else:
            return int(self.rank)

And then he has some magic around setting ace, because it can be 1 or 11 "depending on which value is more advantageous" - maybe we table this in an issue?

_Originally posted by @bbelderbos in https://github.com/theonlysam/blackjack/pull/3#discussion_r1224182713_

bbelderbos commented 1 year ago

Got this feedback from Ben, interesting!

on ace handling, when doing manual testing, I kept running into scenario where would have high score and land an ace and bust so decided to implement score check first before deciding on value - if score plus 11 causes a bust then go with one.