diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index 3567ea0..50ebb2e 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -5,6 +5,7 @@ from enum import Enum, auto from math import sqrt from random import choice, randint from typing import List, Optional +from itertools import product from .display.texturepack import TexturePack from .translations import gettext as _ @@ -180,6 +181,13 @@ class Map: for entisave in d["entities"]: self.add_entity(dictclasses[entisave["type"]](**entisave)) + def large_neighbourhood(self, y, x): + neighbours = [] + for dy, dx in product([-1, 0, 1], [-1, 0, 1]): + if 0 < y+dy < self.height and 0 < x+dx < self.width: + neighbours.append([y+dy, x+dx]) + return neighbours + class Tile(Enum): """