Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I'm in the process of developing a simple 2d grid based sim game and have fully functional pathfinding.

I used the answer found in my previous question as my basis for implementing A* pathfinding. (Pathfinding 2D Java game?).

To show you really what I'm asking, I need to show you this video screen capture that I made. I was just testing to see how the person would move to a location and back again, and this was the result...

http://www.screenjelly.com/watch/Bd7d7pObyFo

A different choice of path depending on the direction, an unexpected result. Any ideas?

1 Answer

0 votes
by (108k points)

The reason why is actually really simple: the path will always try to have the lowest heuristic possible because it searches in a greedy manner. Going closer to the goal is an optimal path. If you allowed diagonal movement, this wouldn't happen.

For the algorithm, you can refer the following link:https://www.redblobgames.com/pathfinding/a-star/introduction.html

If you want to Learn Java then visit this Java Programming Tutorial.

Browse Categories

...