I am currently planning a game, but it is difficult for me to determine the algorithm for finding the path, and I was wondering if a generous soul could help me with this.
Here is the scenario, I need an algorithm that calculates whether it would be better to bypass the obstacle or destroy them. I gave "difficulty" to every tile of my game. For example, the base tile is 1, and the obstacle may be between 5-100.
Here are some examples. I have to move from Red Square to Blue Square. If I put an obstacle in the way, I should get something like this:

Explanation: The left or right path is only 3 difficulties, and the obstacle is 5. Therefore, it is better to walk.
Second example:

Explanation: The algorithm as the 3rd choice is to break an obstacle or walk left or right because it has the same difficulty level.
Last example:

Explanation: The algorithm must be able to find a "weak spot" and be able to go to it and destroy it.
I will continue to work on this. Hope you can give me some advice.
source
share