From 3b1b3eca4148d472e7c5a4f1d76caf80d7b60f7c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 11 Oct 2006 21:22:07 +0000 Subject: [PATCH] Fix the probe bug. --- src/sst.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sst.py b/src/sst.py index bb1e6f9..a83d6ca 100644 --- a/src/sst.py +++ b/src/sst.py @@ -252,7 +252,9 @@ class coord: return coord(self.i/other, self.j/other) def __rdiv__(self, other): return coord(self.i/other, self.j/other) - def snaptogrid(self): + def roundtogrid(self): + return coord(int(round(self.i)), int(round(self.j))) + def trunctogrid(self): return coord(int(round(self.i)), int(round(self.j))) def distance(self, other=None): if not other: other = coord(0, 0) @@ -1277,7 +1279,7 @@ def torpedo(origin, course, dispersion, number, nburst): # Loop to move a single torpedo for step in range(1, QUADSIZE*2): ungridded += delta - w = ungridded.snaptogrid() + w = ungridded.roundtogrid() if not VALID_SECTOR(w.i, w.j): break iquad=game.quad[w.i][w.j] @@ -2454,7 +2456,7 @@ def events(): supercommander() elif evcode == FDSPROB: # Move deep space probe schedule(FDSPROB, 0.01) - if game.probe.next(): + if game.probe.nextquad(): if not VALID_QUADRANT(game.probe.loc.i, game.probe.loc.j) or \ game.state.galaxy[game.probe.loc.i][game.probe.loc.j].supernova: # Left galaxy or ran into supernova @@ -3950,10 +3952,10 @@ class course: return self.distance*(self.warp**3)*(game.shldup+1) def time(self): return 10.0*self.distance/self.warp**2 - def next(self): - "Next location on course, currently only at quadrant granularity." + def nextquad(self): + "Next location on course, at quadrant granularity." self.location += self.increment - newloc = (self.location / float(QUADSIZE)).snaptogrid() + newloc = (self.location / float(QUADSIZE)).trunctogrid() if not newloc == self.loc: self.loc = newloc return True -- 2.31.1