home
·
contact
·
privacy
projects
/
plomrogue2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't recalculate directions all the time, unnecessarily.
[plomrogue2]
/
plomrogue
/
mapping.py
diff --git
a/plomrogue/mapping.py
b/plomrogue/mapping.py
index e806ef70f8c721386bf9cdeada5733fc57eea176..53e9d29fed1267d51e68dd2c19c2aa5626be6688 100644
(file)
--- a/
plomrogue/mapping.py
+++ b/
plomrogue/mapping.py
@@
-21,6
+21,7
@@
class MapGeometry():
def __init__(self, size):
self.size = size
self.neighbors_i = {}
def __init__(self, size):
self.size = size
self.neighbors_i = {}
+ self.directions = self.get_directions()
def get_directions(self):
directions = []
def get_directions(self):
directions = []
@@
-32,13
+33,13
@@
class MapGeometry():
def get_neighbors_yxyx(self, yxyx):
neighbors = {}
def get_neighbors_yxyx(self, yxyx):
neighbors = {}
- for direction in self.
get_directions()
:
+ for direction in self.
directions
:
neighbors[direction] = self.move_yxyx(yxyx, direction)
return neighbors
def get_neighbors_yx(self, pos):
neighbors = {}
neighbors[direction] = self.move_yxyx(yxyx, direction)
return neighbors
def get_neighbors_yx(self, pos):
neighbors = {}
- for direction in self.
get_directions()
:
+ for direction in self.
directions
:
neighbors[direction] = self.move_yx(pos, direction)
return neighbors
neighbors[direction] = self.move_yx(pos, direction)
return neighbors