X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst;h=d34a396759aaed7ca6b677c2f8b9a839f7b066cb;hp=32299535f3ada075a1f758e73bfa3b195098a444;hb=df04e4fe24932108b9728a9638e648d74648efc6;hpb=f3b8af6f2feee3044021ab00e334a7be7606a846 diff --git a/sst b/sst index 3229953..d34a396 100755 --- a/sst +++ b/sst @@ -88,6 +88,14 @@ class randomizer: # logfp.write("#seed(%d)\n" % n) game.lcg_x = n % randomizer.LCG_M + @staticmethod + def getrngstate(): + return game.lcg_x + + @staticmethod + def setrngstate(n): + game.lcg_x = n + GALSIZE = 8 # Galaxy size in quadrants NINHAB = (GALSIZE * GALSIZE // 2) # Number of inhabited worlds MAXUNINHAB = 10 # Maximum uninhabited worlds @@ -5930,13 +5938,17 @@ def setup(): # Place thing (in tournament game, we don't want one!) # New in SST2K: never place the Thing near a starbase. # This makes sense and avoids a special case in the old code. - #global thing - #if game.tourn is None: - # while True: - # thing.location = randplace(GALSIZE) - # # Put it somewhere a starbase is not - # if thing.location not in game.state.baseq: - # break + if game.tourn is None: + # Avoid distrubing the RNG chain. This code + # was a late fix and we don't want to mess up + # all the regression tests. + state = randomizer.getrngstate() + while True: + thing.location = randplace(GALSIZE) + # Put it somewhere a starbase is not + if thing.location not in game.state.baseq: + break + randomizer.setrngstate(state) skip(2) game.state.snap = False if game.skill == SKILL_NOVICE: