diff --git a/game.py b/game.py index 7e2e2fc..6ccf0ca 100644 --- a/game.py +++ b/game.py @@ -224,8 +224,8 @@ class Game: solution = path.Pathfinder(self.g.chunks).astar(utils.pint(self.g.pos), utils.pint(self.g.goal)) if solution: solution = list(solution) - self.g.path = solution - self.g.job.state = self.g.job.stop + #self.g.path = solution + #self.g.job.state = self.g.job.stop print(len(solution)) print(solution) print(round(time.time() - start, 3), 'seconds') @@ -550,6 +550,7 @@ class Game: if entry.value.item_id in items.GAPPLE_ID: self.g.chat.send('gapple found: ' + str(current_chest)[1:-1]) + print('gapple found:', str(current_chest)[1:-1]) def handle_spawn_living(self, packet): diff --git a/path.py b/path.py index d9dde08..5fa23a5 100644 --- a/path.py +++ b/path.py @@ -1,7 +1,7 @@ import importlib import functools import time -from math import hypot +from math import hypot, sqrt from astar import AStar @@ -117,21 +117,6 @@ HALF_PARKOUR = { (-2, 0, 0): (-1, 0, 0), } -HYPOT_LUT = { - (0, -1): 1.0, - (0, 1): 1.0, - (1, 0): 1.0, - (-1, 0): 1.0, - (1, -1): 1.414, - (-1, -1): 1.414, - (1, 1): 1.414, - (-1, 1): 1.414, - (0, 2): 2.0, - (-2, 0): 2.0, - (2, 0): 2.0, - (0, -2): 2.0, -} - # larger started being slower BLOCK_CACHE_SIZE = 2**14 @@ -300,9 +285,9 @@ class Pathfinder(AStar): def distance_between(self, n1, n2): (x1, y1, z1) = n1 (x2, y2, z2) = n2 - return HYPOT_LUT[x2 - x1, z2 - z1] + return hypot(x2-x1, y2-y1, z2-z1) def heuristic_cost_estimate(self, n1, n2): (x1, y1, z1) = n1 (x2, y2, z2) = n2 - return hypot(x2 - x1, z2 - z1) + return abs(x2-x1) + abs(y2-y1) + abs(z2-z1) diff --git a/protocol/managers.py b/protocol/managers.py index 6c3282f..8e3d21e 100644 --- a/protocol/managers.py +++ b/protocol/managers.py @@ -126,22 +126,14 @@ class ChunksManager: return True def unload_chunks(self, position): - start = time.time() x, y, z = utils.pint(position) player_chunk = (x//16, 0, z//16) - loaded_chunks = list(self.chunks.keys()) - count = 0 for chunk in loaded_chunks: check = (chunk[0], 0, chunk[2]) - if utils.phyp_king(player_chunk, check) > 16: + if utils.phyp_king(player_chunk, check) > 20: del self.chunks[chunk] - count += 1 - - if count: - print('unloaded', count, 'chunks in', time.time()-start, 's') - class ChunkNotLoadedException(Exception):