description cleanup and web example
This commit is contained in:
parent
250649d439
commit
857338ba5f
48
README.md
48
README.md
@ -23,27 +23,41 @@ pip install pyroulette
|
|||||||
from pyroulette import generate_players, play_roulette
|
from pyroulette import generate_players, play_roulette
|
||||||
|
|
||||||
players = generate_players(
|
players = generate_players(
|
||||||
number_of_players=10,
|
num_players=50,
|
||||||
minimum_number_of_games=10,
|
min_num_games=min_games,
|
||||||
budget=100,
|
total_budget=100
|
||||||
)
|
)
|
||||||
|
|
||||||
for player in results:
|
players = play_roulette(
|
||||||
print(player)
|
|
||||||
|
|
||||||
results = play_roulette(
|
|
||||||
players=players,
|
players=players,
|
||||||
number_of_games=1000,
|
games=1000,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print("Results:")
|
||||||
|
for p in sorted(players, reverse=True):
|
||||||
|
print("\n", p)
|
||||||
|
|
||||||
|
print("Statistics")
|
||||||
|
# get the wallet values for all players as a list
|
||||||
|
wallets = [player.wallet for player in players]
|
||||||
|
|
||||||
|
# calculate some statistics
|
||||||
|
avg_wallet = sum(wallets) / len(wallets)
|
||||||
|
median_wallet = sorted(wallets)[len(wallets) // 2]
|
||||||
|
|
||||||
|
# calculate winnings
|
||||||
|
winnings = [p.wallet - p.budget for p in players]
|
||||||
|
|
||||||
|
num_losers = len([w for w in winnings if w <= 0])
|
||||||
|
num_winners = len([w for w in winnings if w > 0])
|
||||||
|
num_bankrupt = len([l for l in wallets if l == 0])
|
||||||
|
|
||||||
|
# print the results
|
||||||
|
print(f"Average wallet value: {avg_wallet}\n")
|
||||||
|
print(f"Median wallet value: {median_wallet}\n")
|
||||||
|
print(f"Number of players who lost money: {num_losers}, proportion: {num_losers / len(players):.2f}")
|
||||||
|
print(f"Number of players who went bankrupt: {num_bankrupt}, proportion: {num_bankrupt / len(players):.2f}")
|
||||||
|
print()
|
||||||
|
print(f"Number of players who won more than they started with: {num_winners}, proportion: {num_winners / len(players):.2f}")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# uploading to pypi
|
|
||||||
|
|
||||||
```
|
|
||||||
pip install build
|
|
||||||
python -m build --sdist --wheel -n
|
|
||||||
twine upload dist/*
|
|
||||||
```
|
|
||||||
|
@ -59,18 +59,17 @@ players = pr.play_roulette(players, games=100)
|
|||||||
|
|
||||||
# get the wallet values for all players as a list
|
# get the wallet values for all players as a list
|
||||||
wallets = [player.wallet for player in players]
|
wallets = [player.wallet for player in players]
|
||||||
# calculate the average wallet value
|
# calculate some statistics
|
||||||
avg_wallet = sum(wallets) / len(wallets)
|
avg_wallet = sum(wallets) / len(wallets)
|
||||||
median_wallet = sorted(wallets)[len(wallets) // 2]
|
median_wallet = sorted(wallets)[len(wallets) // 2]
|
||||||
|
|
||||||
# calculate winnings
|
# calculate winnings
|
||||||
winnings = [p.wallet - p.budget for p in players]
|
winnings = [p.wallet - p.budget for p in players]
|
||||||
|
|
||||||
# calculate the number of players who lost all their money
|
|
||||||
num_losers = len([w for w in winnings if w <= 0])
|
num_losers = len([w for w in winnings if w <= 0])
|
||||||
num_winners = len([w for w in winnings if w > 0])
|
num_winners = len([w for w in winnings if w > 0])
|
||||||
num_bankrupt = len([l for l in wallets if l == 0])
|
num_bankrupt = len([l for l in wallets if l == 0])
|
||||||
# calculate the number of players who won more than they started with
|
|
||||||
# print the results
|
# print the results
|
||||||
print(f"Average wallet value: {avg_wallet}\n")
|
print(f"Average wallet value: {avg_wallet}\n")
|
||||||
print(f"Median wallet value: {median_wallet}\n")
|
print(f"Median wallet value: {median_wallet}\n")
|
||||||
|
2
setup.py
2
setup.py
@ -10,7 +10,7 @@ with open(BASEDIR.joinpath("README.md"), "r") as fp:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyroulette",
|
name="pyroulette",
|
||||||
version="0.0.4",
|
version="0.0.5",
|
||||||
description="A package for exploring roulette strategies.",
|
description="A package for exploring roulette strategies.",
|
||||||
long_description=LONG_DESCRIPTION,
|
long_description=LONG_DESCRIPTION,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
Loading…
Reference in New Issue
Block a user