From b767b94fbe1d5de146ab3d264966c357fbf05991 Mon Sep 17 00:00:00 2001 From: Vitalik Buterin Date: Wed, 29 Oct 2014 07:16:25 -0400 Subject: [PATCH] Added slasher v2 sim --- slasher_v2_sim.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 slasher_v2_sim.py diff --git a/slasher_v2_sim.py b/slasher_v2_sim.py new file mode 100644 index 0000000..734b045 --- /dev/null +++ b/slasher_v2_sim.py @@ -0,0 +1,23 @@ +NUMSIGNERS = 15 +ATTACKER_SHARE = 0.495 +CHANCE_OF_SUCCESS = 0.049 +SCORE_DIFFERENTIAL = 10 +ATTACKER_VOTE = 0.95 +import random + +def sim(): + d = -SCORE_DIFFERENTIAL * 15 + while d < 0 and d > -(SCORE_DIFFERENTIAL * 15)-1000: + if random.random() < ATTACKER_SHARE: + for i in range(NUMSIGNERS): + if random.random() < ATTACKER_SHARE: + d += ATTACKER_VOTE + else: + d += min(CHANCE_OF_SUCCESS, 0.95) + else: + for i in range(NUMSIGNERS): + if random.random() < ATTACKER_SHARE: + pass + else: + d -= min(1 - CHANCE_OF_SUCCESS, 0.95) + return 1 if d >= 0 else 0