forked from expo/troggle
chaos monkey
This commit is contained in:
parent
9a514e7d3f
commit
e54436e818
8
utils.py
8
utils.py
@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import random
|
||||
import re
|
||||
import logging
|
||||
@ -6,6 +7,13 @@ from django.conf import settings
|
||||
from django.shortcuts import render
|
||||
from troggle.core.models_caves import CaveDescription
|
||||
|
||||
def ChaosMonkey(n):
|
||||
# returns True once every n calls - randomly
|
||||
if random.randrange(0,n) != 0:
|
||||
return False
|
||||
# print("CHAOS strikes !", file=sys.stderr)
|
||||
return True
|
||||
|
||||
def weighted_choice(lst):
|
||||
n = random.uniform(0,1)
|
||||
for item, weight in lst:
|
||||
|
Loading…
Reference in New Issue
Block a user