Skip to content

Instantly share code, notes, and snippets.

@mapehe
Created October 22, 2023 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapehe/691bd360e1fa06045e22c7fc1b72be63 to your computer and use it in GitHub Desktop.
Save mapehe/691bd360e1fa06045e22c7fc1b72be63 to your computer and use it in GitHub Desktop.
asd
"""
Consider an n-player game, where each player x has influence i_x.
At each round, each pair of players x, y flip a fair coin, and the
winner gains i_x * i_y influence from the other player.
The formula ensures that stakes are proportional to influence:
Player x puts a greater stake towards a player y than player z
when i_y > i_z.
"""
import numpy as np
from random import random
def play(influence):
for i in range(n):
for j in range(i):
stake = influence[i] * influence[j]
x = random() - 0.5
s = x / np.abs(x)
influence[i] += s * stake
influence[j] -= s * stake
"""
Initialize n players with equal influence:
"""
n = 100
influence = np.array([1 / n for _ in range(n)])
for _ in range(1000):
play(influence)
"""
After some time, almost all influence is concentrated to a single player.
"""
print(influence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment