Created
December 7, 2012 01:19
-
-
Save pfn/4229962 to your computer and use it in GitHub Desktop.
slightly revised elo simulation.
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
#!/usr/bin/python | |
import random | |
def simulate(): | |
start = 1200 | |
elo = start | |
elo40 = elo | |
elo100 = elo | |
elo500 = elo | |
k = 80 | |
r = random.Random() | |
wins = 0 | |
# moderately lucky at starting matches | |
winrate = 55 | |
def delta(): return k / 2 | |
def wr(): return 100 - winrate | |
for i in range(0,1000): | |
wl = 1 if (r.randint(1, 100) > wr()) else 0 | |
wins = wins + wl | |
if i > 100: k = 20 | |
elif i > 50: k = 25 | |
elif i > 20: k = 30 | |
if i > 20: | |
# anything in elo hell is a gamble, your edge contributes 1% | |
if elo < 1000: winrate = 51 | |
if elo > 1200: winrate = 55 | |
if elo > 1600: winrate = 50 | |
if elo > 2000: winrate = 40 | |
if i == 40: elo40 = elo | |
if i == 100: elo100 = elo | |
if i == 500: elo500 = elo | |
# lets say the player does well dramatically after the first 30 matches | |
# for 10 matches | |
if i in range(30,40): | |
winrate = 75 | |
elo = elo + (delta() if wl == 1 else (-1 * delta())) | |
if elo40 < 1000: | |
print "%d: %4d => %4d => %4d => %4d" % (wins,elo40,elo100,elo500,elo) | |
for i in range(0,1000): simulate() | |
""" | |
[pfnguyen@galactica0 ~]$ ./elo.py | |
527: 995 => 908 => 1050 => 1550 | |
529: 905 => 1106 => 1348 => 1608 | |
530: 955 => 958 => 1016 => 1636 | |
497: 975 => 1104 => 1066 => 946 | |
523: 995 => 1112 => 1610 => 1510 | |
534: 965 => 1046 => 1188 => 1708 | |
522: 995 => 968 => 930 => 1450 | |
529: 935 => 1058 => 1220 => 1600 | |
537: 985 => 976 => 1354 => 1774 | |
536: 995 => 1058 => 1620 => 1740 | |
505: 995 => 1046 => 824 => 1124 | |
500: 915 => 864 => 1046 => 946 | |
507: 965 => 1034 => 1012 => 1172 | |
541: 995 => 1124 => 1522 => 1862 | |
534: 935 => 1010 => 1448 => 1688 | |
484: 975 => 786 => 664 => 704 | |
531: 905 => 896 => 1138 => 1598 | |
491: 965 => 854 => 772 => 792 | |
499: 965 => 1088 => 1030 => 1010 | |
491: 965 => 704 => 426 => 766 | |
496: 985 => 1096 => 894 => 974 | |
497: 895 => 796 => 1014 => 934 | |
478: 915 => 936 => 794 => 514 | |
524: 985 => 1168 => 1530 => 1570 | |
514: 775 => 862 => 824 => 1184 | |
534: 965 => 1058 => 1196 => 1716 | |
493: 865 => 886 => 944 => 764 | |
488: 935 => 1034 => 576 => 776 | |
528: 965 => 926 => 1428 => 1548 | |
484: 945 => 960 => 842 => 642 | |
529: 955 => 1126 => 1468 => 1648 | |
496: 935 => 788 => 686 => 886 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment