Add docstring for Map.large_neighbourhood
This commit is contained in:
parent
c8b07b3bf5
commit
d3c14a48ee
|
@ -182,6 +182,10 @@ class Map:
|
||||||
self.add_entity(dictclasses[entisave["type"]](**entisave))
|
self.add_entity(dictclasses[entisave["type"]](**entisave))
|
||||||
|
|
||||||
def large_neighbourhood(self, y, x):
|
def large_neighbourhood(self, y, x):
|
||||||
|
"""
|
||||||
|
Returns up to 8 nearby coordinates, in a 3x3 square around the input coordinate.
|
||||||
|
Does not return coordinates if they are out of bounds.
|
||||||
|
"""
|
||||||
neighbours = []
|
neighbours = []
|
||||||
for dy, dx in product([-1, 0, 1], [-1, 0, 1]):
|
for dy, dx in product([-1, 0, 1], [-1, 0, 1]):
|
||||||
if 0 < y+dy < self.height and 0 < x+dx < self.width:
|
if 0 < y+dy < self.height and 0 < x+dx < self.width:
|
||||||
|
|
Loading…
Reference in New Issue