projects
/
super-star-trek.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f98eed0
)
Refactor: isolate RNG stuff in one spot.
author
Eric S. Raymond
<esr@thyrsus.com>
Mon, 22 Apr 2019 18:27:24 +0000
(14:27 -0400)
committer
Eric S. Raymond
<esr@thyrsus.com>
Mon, 22 Apr 2019 18:27:24 +0000
(14:27 -0400)
sst.py
patch
|
blob
|
history
diff --git
a/sst.py
b/sst.py
index f281d12d5230408c91299b9092825ce76246cbc5..8e2f4979d606d411fd0333717d6628ff884ff5f8 100755
(executable)
--- a/
sst.py
+++ b/
sst.py
@@
-483,6
+483,9
@@
def randreal(*args):
v = args[0] + v*(args[1]-args[0]) # from [args[0], args[1])
return v
v = args[0] + v*(args[1]-args[0]) # from [args[0], args[1])
return v
+def randseed(n):
+ random.seed(n)
+
# Code from ai.c begins here
def welcoming(iq):
# Code from ai.c begins here
def welcoming(iq):
@@
-5888,9
+5891,9
@@
def choose():
scanner.chew()
continue # We don't want a blank entry
game.tourn = int(round(scanner.real))
scanner.chew()
continue # We don't want a blank entry
game.tourn = int(round(scanner.real))
- rand
om.
seed(scanner.real)
+ randseed(scanner.real)
if logfp:
if logfp:
- logfp.write("# rand
om.
seed(%d)\n" % scanner.real)
+ logfp.write("# randseed(%d)\n" % scanner.real)
break
if scanner.sees("saved") or scanner.sees("frozen"):
if thaw():
break
if scanner.sees("saved") or scanner.sees("frozen"):
if thaw():
@@
-6657,6
+6660,7
@@
if __name__ == '__main__':
game = None
thing = Thingy()
game = Gamestate()
game = None
thing = Thingy()
game = Gamestate()
+ logfp = None
game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_PLAIN | OPTION_ALMY)
if os.getenv("TERM"):
game.options |= OPTION_CURSES
game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_PLAIN | OPTION_ALMY)
if os.getenv("TERM"):
game.options |= OPTION_CURSES
@@
-6716,7
+6720,7
@@
if __name__ == '__main__':
logfp.write("# SST2K version %s\n" % version)
logfp.write("# recorded by %s@%s on %s\n" % \
(getpass.getuser(),socket.gethostname(),time.ctime()))
logfp.write("# SST2K version %s\n" % version)
logfp.write("# recorded by %s@%s on %s\n" % \
(getpass.getuser(),socket.gethostname(),time.ctime()))
- rand
om.
seed(seed)
+ randseed(seed)
scanner = sstscanner()
for arg in arguments:
scanner.append(arg)
scanner = sstscanner()
for arg in arguments:
scanner.append(arg)