Created
March 9, 2015 23:32
-
-
Save mjdarby/94c955b4b87a6bf13323 to your computer and use it in GitHub Desktop.
Blackjack.py: Quickly generate a CSV file for use in Anki from the tables on http://wizardofodds.com/games/blackjack/strategy/calculator/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just copy paste the tables from http://wizardofodds.com/games/blackjack/strategy/calculator/ into | |
# the hard, soft, and split variables. Very quick, and VERY dirty. | |
hard = """Hard 2 3 4 5 6 7 8 9 10 A | |
5 H H H H H H H H H H | |
6 H H H H H H H H H H | |
7 H H H H H H H H H H | |
8 H H H H H H H H H H | |
9 H Dh Dh Dh Dh H H H H H | |
10 Dh Dh Dh Dh Dh Dh Dh Dh H H | |
11 Dh Dh Dh Dh Dh Dh Dh Dh H H | |
12 H H S S S H H H H H | |
13 S S S S S H H H H H | |
14 S S S S S H H H H H | |
15 S S S S S H H H H H | |
16 S S S S S H H H H H | |
17 S S S S S S S S S S | |
18 S S S S S S S S S S | |
19 S S S S S S S S S S | |
20 S S S S S S S S S S | |
21 S S S S S S S S S S""" | |
soft = """Soft 2 3 4 5 6 7 8 9 10 A | |
13 H H H Dh Dh H H H H H | |
14 H H H Dh Dh H H H H H | |
15 H H Dh Dh Dh H H H H H | |
16 H H Dh Dh Dh H H H H H | |
17 H Dh Dh Dh Dh H H H H H | |
18 S Ds Ds Ds Ds S S H H H | |
19 S S S S S S S S S S | |
20 S S S S S S S S S S | |
21 S S S S S S S S S S""" | |
split = """Pair 2 3 4 5 6 7 8 9 10 A | |
2+2 P P P P P P H H H H | |
3+3 P P P P P P H H H H | |
4+4 H H H P P H H H H H | |
5+5 Dh Dh Dh Dh Dh Dh Dh Dh H H | |
6+6 P P P P P H H H H H | |
7+7 P P P P P P H H H H | |
8+8 P P P P P P P P H H | |
9+9 P P P P P S P P S S | |
10+10 S S S S S S S S S S | |
A+A P P P P P P P P P H""" | |
mything = [x.split() for x in hard.splitlines()] | |
header = mything[0][1:] | |
rows = mything[1:] | |
mymap = {row[0]: row[1:] for row in rows} | |
for i, x in enumerate(header): | |
for key in mymap: | |
print("Hard", key, " Dealer shows", x, ",", mymap[key][i]) | |
mything = [x.split() for x in soft.splitlines()] | |
header = mything[0][1:] | |
rows = mything[1:] | |
mymap = {row[0]: row[1:] for row in rows} | |
for i, x in enumerate(header): | |
for key in mymap: | |
print("Soft", key, " Dealer shows", x, ",", mymap[key][i]) | |
mything = [x.split() for x in split.splitlines()] | |
header = mything[0][1:] | |
rows = mything[1:] | |
mymap = {row[0]: row[1:] for row in rows} | |
for i, x in enumerate(header): | |
for key in mymap: | |
print("Pair", key, " Dealer shows", x, ",", mymap[key][i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, check out all that code duplication. As I said, very quick and very dirty.