# HG changeset patch # User Neil Muller # Date 1259356698 0 # Node ID 452cde9af2a2b540b92a851a3e87e1f21c4f9005 # Parent c1f14fa35d301cf67e8e8f4bc8d89ba8eabd5816 Fix order of checks to avoid unneeded work diff -r c1f14fa35d30 -r 452cde9af2a2 gamelib/animal.py --- a/gamelib/animal.py Fri Nov 27 21:13:43 2009 +0000 +++ b/gamelib/animal.py Fri Nov 27 21:18:18 2009 +0000 @@ -526,11 +526,11 @@ # We try heading up return Position(self.pos.x, self.pos.y, self.pos.z + 1) cur_dist = self.target.dist(self.pos) - best, min_cost = self._find_min_cost_neighbour(self.target) if cur_dist < 2: # We're right ontop of our target, so just go there return self.target # Find the cheapest spot close to us that moves us closer to the target + best, min_cost = self._find_min_cost_neighbour(self.target) if min_cost < 20 or not self.gameboard.in_bounds(self.pos) \ or not self.gameboard.in_bounds(best): # If we're not on the gameboard yet, there's no point in looking