change size and obstacle coordinate in A star path finding python

Viewed 11

I have A* path planning with python program, and now i want to change the size of map from this:

g = [[0 for i in range(10)] for j in range(10)] 

to:

g = [[0 for i in range(7)] for j in range(14)]

and obstacle coordinate (marked with 3) from:

for i in range(2, 10):
g[4][i] = 3
for i in range(0, 9):
g[7][i] = 3

to:

(1,2), (1,4), (1,6), (4,2), (4,4), (4,6), (7,2), (7,4), (7,6), (10,2), (10,4), (10,6), (13,2), (13,4), (13,6)

at first i use this syntax:

obstacle = [(1,2), (1,4), (1,6), (4,2), (4,4), (4,6), (7,2), (7,4), (7,6), (10,2), (10,4), (10,6), (13,2), (13,4), (13,6)]
for obs in obstacle:
g[obs[0]][obs[1]] = 3

I managed to create the map as I wanted, but in the A* calculation, there was an error.. The error is "list index out of range(line 91)"

this is the complete code i used:

https://github.com/rijaljenius/A-algorithm/blob/main/program.py

can someone help me to solve this code??

0 Answers
Related