Large neighbourhood shouldn't return the central cell
This commit is contained in:
parent
20cbf546f9
commit
8475e5228e
|
@ -202,9 +202,13 @@ class Map:
|
||||||
"""
|
"""
|
||||||
height, width = len(grid), len(grid[0])
|
height, width = len(grid), len(grid[0])
|
||||||
neighbours = []
|
neighbours = []
|
||||||
dyxs = product([-1, 0, 1], [-1, 0, 1]) if large else [[0, -1], [0, 1], [-1, 0], [1, 0]]
|
if large:
|
||||||
|
dyxs = product([-1, 0, 1], [-1, 0, 1])
|
||||||
|
dyxs = dyxs[:5] + dyxs[6:]
|
||||||
|
else:
|
||||||
|
dyxs = [[0, -1], [0, 1], [-1, 0], [1, 0]]
|
||||||
for dy, dx in dyxs:
|
for dy, dx in dyxs:
|
||||||
if 0 < y+dy < height and 0 < x+dx < width:
|
if 0 <= y+dy < height and 0 <= x+dx < width:
|
||||||
neighbours.append([y+dy, x+dx])
|
neighbours.append([y+dy, x+dx])
|
||||||
return neighbours
|
return neighbours
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue