chaos monkey

This commit is contained in:
Philip Sargent 2020-07-02 16:26:05 +01:00
parent 9a514e7d3f
commit e54436e818

View File

@ -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: