Created
October 22, 2023 08:49
-
-
Save mapehe/691bd360e1fa06045e22c7fc1b72be63 to your computer and use it in GitHub Desktop.
asd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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