Progress on drawing more complex simulation with new people joining.
This commit is contained in:
parent
e3c68947c5
commit
9491d44759
73
econ-demo.py
73
econ-demo.py
@ -170,7 +170,7 @@ def calc_total_supply(df):
|
||||
total.append(sum(data))
|
||||
return total
|
||||
|
||||
def draw_specific_chart1(terms=50, linear_label="? (linear)"):
|
||||
def draw_apy_inflation(terms=50, linear_label="? (linear)"):
|
||||
participants = ["Alice", "Bob", "Charlie"]
|
||||
balances = [100,40,20]
|
||||
|
||||
@ -194,6 +194,9 @@ def draw_specific_chart1(terms=50, linear_label="? (linear)"):
|
||||
exit()
|
||||
|
||||
plt.style.use('dark_background')
|
||||
plt.plot(
|
||||
x, total_supply_ubi, color="cyan", label="dividend = 10"
|
||||
)
|
||||
plt.plot(
|
||||
x, total_supply_si, color="red", label="apy = 0.05"
|
||||
)
|
||||
@ -223,7 +226,7 @@ def draw_specific_chart1(terms=50, linear_label="? (linear)"):
|
||||
plt.close()
|
||||
# plt.show()
|
||||
|
||||
def draw_specific_chart2(terms=50):
|
||||
def draw_3ubi_3apy(terms=50):
|
||||
participants = ["Alice", "Bob", "Charlie"]
|
||||
balances = [100,40,20]
|
||||
|
||||
@ -345,14 +348,7 @@ def visualize_wealth_dist(df, title="Wealth Distribution", filename="wealth-dist
|
||||
plt.savefig(filename)
|
||||
plt.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
illustrate_share_of_wealth()
|
||||
visualize_ubi(terms=50)
|
||||
draw_specific_chart1(terms=75)
|
||||
draw_specific_chart1(terms=75, linear_label="dividend = 10")
|
||||
draw_specific_chart2(terms=75)
|
||||
|
||||
def draw_simple_mining_demo():
|
||||
participants = ["Alice", "Bob", "Charlie"]
|
||||
balances = [100,40,20]
|
||||
m = get_balances_over_time(
|
||||
@ -364,3 +360,60 @@ if __name__ == "__main__":
|
||||
visualize_inflation(m, title="Inflation Given block_reward = 10 and Halving Every Term", filename="inflation-pow.png")
|
||||
# print(m.iloc[:,:5].to_markdown())
|
||||
visualize_wealth_dist(m, filename="wealth-distribution-pow.png")
|
||||
|
||||
class Sim:
|
||||
def __init__(self, players, balances, terms=50):
|
||||
self.players = players
|
||||
self.balances = balances
|
||||
self.terms = terms
|
||||
|
||||
self.events = []
|
||||
pass
|
||||
|
||||
def add_player(self, name="Danny", balance=50):
|
||||
self.players.append(name)
|
||||
self.balances.apend(balance)
|
||||
assert(len(self.players) == len(self.balances))
|
||||
|
||||
def run(self, update, trade = None):
|
||||
i = 0
|
||||
ADD_NEW_PPL_EVERY = 3
|
||||
current_balances = self.balance
|
||||
result = list()
|
||||
while i <= self.terms:
|
||||
# add new player?
|
||||
if ADD_NEW_PPL_EVERY > 0 and i % ADD_NEW_PPL_EVERY == 0:
|
||||
pass
|
||||
new_bal = []
|
||||
# make players trade if an
|
||||
if trade:
|
||||
current_balances = trade(current_balances)
|
||||
for balance in current_balances:
|
||||
b = update(balance)
|
||||
new_bal.append(b)
|
||||
result.append(new_bal)
|
||||
current_balances = new_bal
|
||||
return result
|
||||
|
||||
def visualize(self):
|
||||
pass
|
||||
|
||||
def mini_apy(balance, rate=0.05):
|
||||
return balance + (balance * rate)
|
||||
|
||||
def mini_ubi(balance, dividend = 10):
|
||||
return balance + dividend
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
illustrate_share_of_wealth()
|
||||
visualize_ubi(terms=50)
|
||||
draw_apy_inflation(terms=75)
|
||||
draw_apy_inflation(terms=75, linear_label="dividend = 10")
|
||||
draw_3ubi_3apy(terms=75)
|
||||
|
||||
draw_simple_mining_demo()
|
||||
|
||||
participants = ["Alice", "Bob", "Charlie"]
|
||||
balances = [100,40,20]
|
||||
s = Sim(participants, balances)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user