-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
84 lines (78 loc) · 2.5 KB
/
main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from blackjack import *
import sqlite3
import matplotlib.pyplot as plt
import numpy as np
sqlconnection = sqlite3.connect('blackjackdata.db')
cur = sqlconnection.cursor()
winnerslist = []
tieslist = []
loserslist = []
bankrolldatarandom = []
bankrolldatabasic = []
bankrolldatacounter = []
gamer = Game(8, 1, 'random')
for k in range(100):
for j in range(12):
for i in range(30):
gamer.initialdeal()
gamer.moves()
winners, ties, losers = gamer.tallyscore()
bankrolldatarandom.append(gamer.players['Alex'].bankroll)
if winners:
winnerslist.append(winners)
if ties:
tieslist.append(ties)
if losers:
loserslist.append(losers)
gamer.endround()
gamer.endsession()
gameb = Game(8, 1, 'basic')
for k in range(100):
for j in range(12):
for i in range(30):
gameb.initialdeal()
gameb.moves()
winners, ties, losers = gameb.tallyscore()
bankrolldatabasic.append(gameb.players['Alex'].bankroll)
if winners:
winnerslist.append(winners)
if ties:
tieslist.append(ties)
if losers:
loserslist.append(losers)
gameb.endround()
gameb.endsession()
gamec = Game(8, 1, 'counter')
for k in range(100):
for j in range(12):
for i in range(30):
gamec.initialdeal()
gamec.moves()
winners, ties, losers = gamec.tallyscore()
bankrolldatacounter.append(gamec.players['Alex'].bankroll)
if winners:
winnerslist.append(winners)
if ties:
tieslist.append(ties)
if losers:
loserslist.append(losers)
gamec.endround()
gamec.endsession()
#plot bankroll over time
plt.plot(bankrolldatarandom)
plt.title('Bankroll over time, random strategy, random betting (100 sessions)')
plt.ylabel('Dollars')
plt.xlabel('Hands Played')
plt.show()
#plot bankroll over time
plt.plot(bankrolldatabasic)
plt.title('Bankroll over time, basic strategy, minimum betting (100 sessions)')
plt.ylabel('Dollars')
plt.xlabel('Hands Played')
plt.show()
#plot bankroll over time
plt.plot(bankrolldatacounter)
plt.title('Bankroll over time, basic strategy, with bet spread (100 sessions)')
plt.ylabel('Dollars')
plt.xlabel('Hands Played')
plt.show()