From 88f1367a7d32b1f5248e88117562781b0c14dc0b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 13 Sep 2010 22:19:19 +0000 Subject: [PATCH] Add sanity check. --- src/sst.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sst.py b/src/sst.py index 143ca53..0a8a786 100644 --- a/src/sst.py +++ b/src/sst.py @@ -970,11 +970,12 @@ def randdevice(): 15, # DCOMPTR: computer 1.5% 20, # NAVCOMP: navigation system 2.0% 75, # DTRANSP: transporter 7.5% - 20, # DSHCTRL: high-speed shield controller 2.0% + 20, # DSHCTRL: high-speed shield controller 2.0% 10, # DDRAY: death ray 1.0% 30, # DDSP: deep-space probes 3.0% ) - idx = randrange(1000) # weights must sum to 1000 + assert(sum(weights) == 1000) + idx = randrange(1000) sum = 0 for (i, w) in enumerate(weights): sum += w -- 2.31.1