remove pointless check, tabify
This commit is contained in:
parent
4cea8b4043
commit
ba924fc41c
|
@ -9,6 +9,7 @@ accszExk
|
||||||
acctuvwj
|
acctuvwj
|
||||||
abdefghi'''.strip().split('\n')
|
abdefghi'''.strip().split('\n')
|
||||||
|
|
||||||
|
|
||||||
def make_heightmap(lines: list[str]) -> tuple[ArrayLike, ArrayLike, ArrayLike]:
|
def make_heightmap(lines: list[str]) -> tuple[ArrayLike, ArrayLike, ArrayLike]:
|
||||||
heightmap = np.zeros((len(lines[0]), len(lines)), dtype=dtype)
|
heightmap = np.zeros((len(lines[0]), len(lines)), dtype=dtype)
|
||||||
for y, line in enumerate(lines):
|
for y, line in enumerate(lines):
|
||||||
|
@ -23,26 +24,6 @@ def make_heightmap(lines: list[str]) -> tuple[ArrayLike, ArrayLike, ArrayLike]:
|
||||||
heightmap[x,y] = ord(c) - ord('a')
|
heightmap[x,y] = ord(c) - ord('a')
|
||||||
return heightmap, start, end
|
return heightmap, start, end
|
||||||
|
|
||||||
# def make_cell_costs(position, heightmap):
|
|
||||||
# init_val = 9_999_999
|
|
||||||
# costs = np.full_like(heightmap, init_val)
|
|
||||||
# pos_t = tuple(position)
|
|
||||||
# costs[pos_t] = 0
|
|
||||||
# curr_positions = {pos_t}
|
|
||||||
# while (costs == init_val).any() and len(curr_positions) > 0:
|
|
||||||
# next_positions = set()
|
|
||||||
# for pos_t in curr_positions:
|
|
||||||
# n_h_limit = heightmap[pos_t] + 1
|
|
||||||
# n_cost = costs[pos_t] + 1
|
|
||||||
# for d in directions_array:
|
|
||||||
# next_t = (pos_t[0] + d[0], pos_t[1] + d[1])
|
|
||||||
# if (0 <= next_t[0] < heightmap.shape[0]) and (0 <= next_t[1] < heightmap.shape[1]):
|
|
||||||
# hn = heightmap[next_t]
|
|
||||||
# if n_h_limit >= hn and costs[next_t] > n_cost:
|
|
||||||
# costs[next_t] = n_cost
|
|
||||||
# next_positions.add(next_t)
|
|
||||||
# curr_positions = next_positions
|
|
||||||
# return costs
|
|
||||||
|
|
||||||
def make_reversed_cell_costs(position, heightmap):
|
def make_reversed_cell_costs(position, heightmap):
|
||||||
init_val = 9_999_999
|
init_val = 9_999_999
|
||||||
|
@ -50,7 +31,7 @@ def make_reversed_cell_costs(position, heightmap):
|
||||||
pos_t = tuple(position)
|
pos_t = tuple(position)
|
||||||
costs[pos_t] = 0
|
costs[pos_t] = 0
|
||||||
curr_positions = {pos_t}
|
curr_positions = {pos_t}
|
||||||
while (costs == init_val).any() and len(curr_positions) > 0:
|
while len(curr_positions) > 0:
|
||||||
next_positions = set()
|
next_positions = set()
|
||||||
for pos_t in curr_positions:
|
for pos_t in curr_positions:
|
||||||
n_h_limit = heightmap[pos_t] - 1
|
n_h_limit = heightmap[pos_t] - 1
|
||||||
|
|
Loading…
Reference in New Issue