reformat
This commit is contained in:
parent
f5544299da
commit
798e8c3faa
@ -176,7 +176,7 @@ class Grid:
|
|||||||
def isWithinBoundaries(self, pos: Coordinate) -> bool:
|
def isWithinBoundaries(self, pos: Coordinate) -> bool:
|
||||||
if self.mode3D:
|
if self.mode3D:
|
||||||
return self.minX <= pos.x <= self.maxX and self.minY <= pos.y <= self.maxY \
|
return self.minX <= pos.x <= self.maxX and self.minY <= pos.y <= self.maxY \
|
||||||
and self.minZ <= pos.z <= self.maxZ
|
and self.minZ <= pos.z <= self.maxZ
|
||||||
else:
|
else:
|
||||||
return self.minX <= pos.x <= self.maxX and self.minY <= pos.y <= self.maxY
|
return self.minX <= pos.x <= self.maxX and self.minY <= pos.y <= self.maxY
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ class Grid:
|
|||||||
return list(self.__grid.keys())
|
return list(self.__grid.keys())
|
||||||
|
|
||||||
def getActiveRegion(self, start: Coordinate, includeDiagonal: bool = False, ignore: List[Coordinate] = None) \
|
def getActiveRegion(self, start: Coordinate, includeDiagonal: bool = False, ignore: List[Coordinate] = None) \
|
||||||
-> List[Coordinate]:
|
-> List[Coordinate]:
|
||||||
if not self.get(start):
|
if not self.get(start):
|
||||||
return []
|
return []
|
||||||
if ignore is None:
|
if ignore is None:
|
||||||
@ -298,7 +298,8 @@ class Grid:
|
|||||||
while queue:
|
while queue:
|
||||||
current = queue.popleft()
|
current = queue.popleft()
|
||||||
found_end = False
|
found_end = False
|
||||||
for c in self.getNeighboursOf(current, includeDiagonal=includeDiagonal, includeDefault=self.__default not in walls):
|
for c in self.getNeighboursOf(current, includeDiagonal=includeDiagonal,
|
||||||
|
includeDefault=self.__default not in walls):
|
||||||
if c in came_from and self.get(c) in walls:
|
if c in came_from and self.get(c) in walls:
|
||||||
continue
|
continue
|
||||||
came_from[c] = current
|
came_from[c] = current
|
||||||
@ -411,7 +412,9 @@ class Grid:
|
|||||||
print()
|
print()
|
||||||
|
|
||||||
def get_aoc_ocr_string(self, x_shift: int = 0, y_shift: int = 0):
|
def get_aoc_ocr_string(self, x_shift: int = 0, y_shift: int = 0):
|
||||||
return convert_array_6([['#' if self.get(Coordinate(x + x_shift, y + y_shift)) else '.' for x in self.rangeX()] for y in self.rangeY()])
|
return convert_array_6(
|
||||||
|
[['#' if self.get(Coordinate(x + x_shift, y + y_shift)) else '.' for x in self.rangeX()] for y in
|
||||||
|
self.rangeY()])
|
||||||
|
|
||||||
def __str__(self, true_char: str = '#', false_char: str = "."):
|
def __str__(self, true_char: str = '#', false_char: str = "."):
|
||||||
return "/".join(
|
return "/".join(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user