-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolo_driver.py
55 lines (45 loc) · 1.2 KB
/
solo_driver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# module imports - all other imports done there
import dealer
import attendant
# library imports
import warnings
# silence misc warnings
warnings.filterwarnings(action='ignore', category=RuntimeWarning)
# initialize deck
deck = dealer.generate_deck_distribution()
shuffled_deck = dealer.shuffle_deck(deck)
shoe = dealer.draw_shoe(shuffled_deck)
# base wager as a decimal float
balance = 1000.00
wager = 10.00
# keep track
wins = 0
losses = 0
draws = 0
games = 100
# strategy/agent to run
name = "bb"
# play some games of blackjack
for game in range(games):
# play game
[winning_hand, wager_outcome, status] = attendant.basic_game(shoe, wager, name)
balance += wager_outcome
# loss
if status == 4:
losses += 1
# win
elif status == 5:
wins += 1
# draw
else:
draws += 1
# calculate win likelihood
win_likelhood = (2 * wins + draws) / (2 * games)
# final results per bulk game run
print("End results for {} agent:\n".format(name))
print("Games: {}".format(games))
print("Wins: {}".format(wins))
print("Losses: {}".format(losses))
print("Draws: {}".format(draws))
print("Final win likelihood: {}".format(win_likelhood))
print("Final balance: {}".format(balance))