From df04e4fe24932108b9728a9638e648d74648efc6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 16 Aug 2023 14:11:48 -0400 Subject: [PATCH] Complete repair of Thingy code. --- sst | 26 +++++++++++++++------ test/test28.chk | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ test/test28.log | 11 +++++++++ 3 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 test/test28.chk create mode 100644 test/test28.log 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: diff --git a/test/test28.chk b/test/test28.chk new file mode 100644 index 0000000..9d64557 --- /dev/null +++ b/test/test28.chk @@ -0,0 +1,60 @@ + + +-SUPER- STAR TREK + + + +It is stardate 4827. The Federation is being attacked by +a deadly Klingon invasion force. As captain of the United +Starship U.S.S. Enterprise, it is your mission to seek out +and destroy this invasion force of 10 battle cruisers. +You have an initial allotment of 14 stardates to complete +your mission. As you proceed you may be given more time. + +You will have 5 supporting starbases. +Starbase locations- f1 g6 e2 a1 a8 + +The Enterprise is currently in Quadrant d6 Sector h8 + +Good Luck! +COMMAND> # SST2K version 2.7 +# Encounter and destroy Space Thingy +# recorded by esr@snark.thyrsus.com on Wed Aug 16 08:28:50 2023 +m a e8 + +COMMAND> m a a1 + +COMMAND> m a c2 j10 + +Ensign Chekov- "Course laid in, Captain." + +Entering Quadrant c2. + +Mr. Spock- "Captain, this is most unusual. + Please examine your short-range scan." +COMMAND> sr + Short-range scan + 1 2 3 4 5 6 7 8 9 10 +a . . . . . . . . . . +b . . . . . . . . . . +c . . . . . . . . . . +d ? . . . . . . . . * +e . . . . . . . . . +f . . . . . . . . . . +g . . . . . . . . . +h . . . * . . . . . . +i . . P . . . . . . . +j . . . * . . . . . E +COMMAND> torp 1 d1 + +Torpedo track- i9 i8 h7 +g6 g5 f4 e3 d2 +d1 + +AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!! + HACK! HACK! HACK! *CHOKE!* +Mr. Spock- "Fascinating!" +***Stranger at Sector d1 destroyed. +COMMAND> quit + +May the Great Bird of the Galaxy roost upon your home planet. diff --git a/test/test28.log b/test/test28.log new file mode 100644 index 0000000..d13a79f --- /dev/null +++ b/test/test28.log @@ -0,0 +1,11 @@ +# seed 1692187822 +# arguments regular medium novice fancy +# SST2K version 2.7 +# Encounter and destroy Space Thingy +# recorded by esr@snark.thyrsus.com on Wed Aug 16 08:28:50 2023 +m a e8 +m a a1 +m a c2 j10 +sr +torp 1 d1 +quit -- 2.31.1