Skip to content

Commit

Permalink
Fix paths using nyduses having one extra point with wrong data
Browse files Browse the repository at this point in the history
  • Loading branch information
spudde123 committed Mar 17, 2021
1 parent 266eea9 commit 029033b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Binary file modified MapAnalyzer/cext/mapanalyzerext.so
Binary file not shown.
4 changes: 2 additions & 2 deletions MapAnalyzer/cext/src/ma_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,13 +1335,13 @@ static PyObject* astar_with_nydus(PyObject *self, PyObject *args)
}
PyList_SetItem(return_val, 0, PyArray_Return(path1));

npy_intp dims2[2] = {path_length - nydus_index + 1, 2};
npy_intp dims2[2] = {path_length - (nydus_index + 1), 2};
PyArrayObject *path2 = (PyArrayObject*) PyArray_SimpleNew(2, dims2, NPY_INT32);
npy_int32 *path2_data = (npy_int32*)path2->data;

for (npy_intp i = nydus_index + 1; i < path_length; ++i)
{
int index_to_set = i - nydus_index + 1;
int index_to_set = i - (nydus_index + 1);
path2_data[2*index_to_set] = complete_path->items[i] / w;
path2_data[2*index_to_set + 1] = complete_path->items[i] % w;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_c_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_c_extension():
paths_nydus = astar_path_with_nyduses(influenced_grid, (3, 3), (33, 38), nydus_positions, False, False)

assert (paths_nydus is not None and len(paths_nydus) == 2
and len(paths_nydus[0]) + len(paths_nydus[1]) == 10)
and len(paths_nydus[0]) + len(paths_nydus[1]) == 8)

height_map = np.where(walkable_grid == 0, 24, 8).astype(np.uint8)

Expand Down

0 comments on commit 029033b

Please sign in to comment.