print a graph
This commit is contained in:
parent
6ccecba442
commit
6f3b00d266
22
index.html
22
index.html
@ -29,13 +29,18 @@
|
||||
<br>
|
||||
<div id="outputDiv2" class="font-mono"></div>
|
||||
<div id="outputDiv3" class="font-mono"></div>
|
||||
<center>
|
||||
<div id="hist"></div>
|
||||
</center>
|
||||
<py-config>
|
||||
packages = [
|
||||
"pyroulette",
|
||||
"matplotlib"
|
||||
]
|
||||
</py-config>
|
||||
<py-script>
|
||||
<py-script output="hist">
|
||||
import pyroulette as pr
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# seed(59)
|
||||
from random import randint
|
||||
@ -53,11 +58,20 @@ for _ in range(1, 20):
|
||||
|
||||
players = pr.play_roulette(players, games=100)
|
||||
|
||||
for p in sorted(players, reverse=True):
|
||||
print(p, "\n<br>")
|
||||
# get the wallet values for all players as a list
|
||||
wallets = [player.wallet for player in players]
|
||||
# plot the wallet values as a histogram
|
||||
fig, ax = plt.subplots()
|
||||
ax.hist(wallets, bins=50)
|
||||
ax.set_yscale("log")
|
||||
fig
|
||||
|
||||
|
||||
</py-script>
|
||||
|
||||
<py-script>
|
||||
for p in sorted(players, reverse=True):
|
||||
print(p, "\n<br>")
|
||||
</py-script>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user