From: Eric S. Raymond Date: Mon, 13 Sep 2010 22:19:19 +0000 (+0000) Subject: Add sanity check. X-Git-Tag: 2.0~40 X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=commitdiff_plain;h=88f1367a7d32b1f5248e88117562781b0c14dc0b;ds=inline Add sanity check. --- 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