projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replay works now, at least in plain-tty mode
[super-star-trek.git]
/
src
/
sst.py
diff --git
a/src/sst.py
b/src/sst.py
index 09c25f3113eaeb4e18bd4a66f5b6237562086768..eb440297d091e5b190d6dfa8d598b9c26c716c3f 100644
(file)
--- a/
src/sst.py
+++ b/
src/sst.py
@@
-575,12
+575,12
@@
import traceback
def withprob(p):
v = random.random()
def withprob(p):
v = random.random()
-
logfp.write("# withprob(%s) -> %f (%s) at %s\n" % (p, v, v<p, traceback.extract_stack()[1
][1:]))
+
#logfp.write("# withprob(%s) -> %f (%s) at %s\n" % (p, v, v<p, traceback.extract_stack()[-2
][1:]))
return v < p
def randrange(*args):
v = random.randrange(*args)
return v < p
def randrange(*args):
v = random.randrange(*args)
-
logfp.write("# randrange%s -> %s at %s\n" % (args, v, traceback.extract_stack()[1
][1:]))
+
#logfp.write("# randrange%s -> %s at %s\n" % (args, v, traceback.extract_stack()[-2
][1:]))
return v
def randreal(*args):
return v
def randreal(*args):
@@
-589,7
+589,7
@@
def randreal(*args):
v *= args[0] # returns from [0, a1)
elif len(args) == 2:
v = args[0] + v*args[1] # returns from [a1, a2)
v *= args[0] # returns from [0, a1)
elif len(args) == 2:
v = args[0] + v*args[1] # returns from [a1, a2)
-
logfp.write("# randreal%s -> %s at %s\n" % (args, v, traceback.extract_stack()[1
][1:]))
+
#logfp.write("# randreal%s -> %s at %s\n" % (args, v, traceback.extract_stack()[-2
][1:]))
return v
# Code from ai.c begins here
return v
# Code from ai.c begins here
@@
-6266,8
+6266,8
@@
def newqad(shutup):
(game.skill > SKILL_GOOD and withprob(0.08)):
game.tholian = coord()
while True:
(game.skill > SKILL_GOOD and withprob(0.08)):
game.tholian = coord()
while True:
- game.tholian.x = withprob(0.5) *
QUADSIZE
- game.tholian.y = withprob(0.5) *
QUADSIZE
+ game.tholian.x = withprob(0.5) *
(QUADSIZE-1)
+ game.tholian.y = withprob(0.5) *
(QUADSIZE-1)
if game.quad[game.tholian.x][game.tholian.y] == IHDOT:
break
game.quad[game.tholian.x][game.tholian.y] = IHT
if game.quad[game.tholian.x][game.tholian.y] == IHDOT:
break
game.quad[game.tholian.x][game.tholian.y] = IHT
@@
-6842,7
+6842,7
@@
if __name__ == '__main__':
# game.options |= OPTION_CURSES | OPTION_SHOWME
# else:
game.options |= OPTION_TTY
# game.options |= OPTION_CURSES | OPTION_SHOWME
# else:
game.options |= OPTION_TTY
- seed =
time.time(
)
+ seed =
int(time.time()
)
(options, arguments) = getopt.getopt(sys.argv[1:], "r:tx")
for (switch, val) in options:
if switch == '-r':
(options, arguments) = getopt.getopt(sys.argv[1:], "r:tx")
for (switch, val) in options:
if switch == '-r':
@@
-6850,12
+6850,12
@@
if __name__ == '__main__':
replayfp = open(val, "r")
except IOError:
sys.stderr.write("sst: can't open replay file %s\n" % val)
replayfp = open(val, "r")
except IOError:
sys.stderr.write("sst: can't open replay file %s\n" % val)
- raise SysExit, 1
+ raise Sys
tem
Exit, 1
line = replayfp.readline().strip()
try:
(leader, key, seed) = line.split()
line = replayfp.readline().strip()
try:
(leader, key, seed) = line.split()
- seed =
int
(seed)
- sys.stderr.write("sst2k: seed set to %
d
\n" % seed)
+ seed =
eval
(seed)
+ sys.stderr.write("sst2k: seed set to %
s
\n" % seed)
except ValueError:
sys.stderr.write("sst: replay file %s is ill-formed\n"% val)
os.exit(1)
except ValueError:
sys.stderr.write("sst: replay file %s is ill-formed\n"% val)
os.exit(1)
@@
-6875,8
+6875,7
@@
if __name__ == '__main__':
except IOError:
sys.stderr.write("sst: warning, can't open logfile\n")
if logfp:
except IOError:
sys.stderr.write("sst: warning, can't open logfile\n")
if logfp:
- #setlinebuf(logfp)
- logfp.write("# seed %d\n" % (seed))
+ logfp.write("# seed %s\n" % seed)
random.seed(seed)
iostart()
if arguments:
random.seed(seed)
iostart()
if arguments:
@@
-6907,4
+6906,4
@@
if __name__ == '__main__':
break
skip(1)
prout(_("May the Great Bird of the Galaxy roost upon your home planet."))
break
skip(1)
prout(_("May the Great Bird of the Galaxy roost upon your home planet."))
- raise SysExit, 0
+ raise Sys
tem
Exit, 0