Add docstring for Map.large_neighbourhood

This commit is contained in:
Charles Peyrat 2020-12-11 17:46:49 +01:00
parent c8b07b3bf5
commit d3c14a48ee
1 changed files with 4 additions and 0 deletions

View File

@ -182,6 +182,10 @@ class Map:
self.add_entity(dictclasses[entisave["type"]](**entisave))
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 = []
for dy, dx in product([-1, 0, 1], [-1, 0, 1]):
if 0 < y+dy < self.height and 0 < x+dx < self.width: