From 11091a194a879833f28764e6f7537e7dabe431ae Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 23 Apr 2019 05:05:30 -0400 Subject: [PATCH] More carefulness about integer division. --- sst.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sst.py b/sst.py index 3eb972a..a598e43 100755 --- a/sst.py +++ b/sst.py @@ -518,8 +518,8 @@ def welcoming(iq): def tryexit(enemy, look, irun): "A bad guy attempts to bug out." iq = Coord() - iq.i = game.quadrant.i+(look.i+(QUADSIZE-1))/QUADSIZE - 1 - iq.j = game.quadrant.j+(look.j+(QUADSIZE-1))/QUADSIZE - 1 + iq.i = game.quadrant.i+(look.i+(QUADSIZE-1))//QUADSIZE - 1 + iq.j = game.quadrant.j+(look.j+(QUADSIZE-1))//QUADSIZE - 1 if not welcoming(iq): return False if enemy.type == 'R': @@ -604,7 +604,7 @@ def movebaddy(enemy): irun = False # This should probably be just (game.quadrant in game.state.kcmdr) + (game.state.kscmdr==game.quadrant) if game.skill >= SKILL_EXPERT: - nbaddys = (((game.quadrant in game.state.kcmdr)*2 + (game.state.kscmdr==game.quadrant)*2+game.klhere*1.23+game.irhere*1.5)/2.0) + nbaddys = int(((game.quadrant in game.state.kcmdr)*2 + (game.state.kscmdr==game.quadrant)*2+game.klhere*1.23+game.irhere*1.5)/2.0) else: nbaddys = (game.quadrant in game.state.kcmdr) + (game.state.kscmdr==game.quadrant) old_dist = enemy.kdist @@ -1211,7 +1211,7 @@ def collision(rammed, enemy): # In the pre-SST2K version, all devices got equiprobably damaged, # which was silly. Instead, pick up to half the devices at # random according to our weighting table, - ncrits = rnd.randrange(NDEVICES/2) + ncrits = rnd.randrange(NDEVICES//2) while ncrits > 0: ncrits -= 1 dev = randdevice() -- 2.31.1