Jump to content
  • Advertisement

Recommended Posts

Hi Volks

I'm stuck since weeks with my Gameproject because the Path Calculation. (programming in C)

The Game is 4096x4096 divided by tiles of 64x64. How can I find the shortest Path from green point to red point (attachment Image)

 

matrix64x64_path_calculation.png

Share this post


Link to post
Share on other sites
Advertisement

what exactly is the problem?

I mean, the trivial thing would be to just create a recursive function, that would mark the current position and call itself for the 4 neighbours. when you reach the goal, you'd check if the current step count is lower than the currently shortest path and then store the way you've walked.

I assume, you have problems with some implementation detail? or are you trying to get some particular algorithm to work? in that case, where exactly are you stuck? Or is the 64x64 grid of 64x64 grids the problem?

Share this post


Link to post
Share on other sites
Posted (edited)
7 hours ago, ProfL said:

what exactly is the problem?

I mean, the trivial thing would be to just create a recursive function, that would mark the current position and call itself for the 4 neighbours. when you reach the goal, you'd check if the current step count is lower than the currently shortest path and then store the way you've walked.

I assume, you have problems with some implementation detail? or are you trying to get some particular algorithm to work? in that case, where exactly are you stuck? Or is the 64x64 grid of 64x64 grids the problem?

I did something like this. but I need to find out the shortest path without walking into all the dead ends or walking back. but sometimes I have to walk back if I get the wrong way. I need something like a algorythm scheme.

 

6 hours ago, Brain said:

You could look into a proven pathfinding algorithm such as A*. Make sure to cache the resulting path information though as A* can be rather expensive.

See: https://dev.to/jansonsa/a-star-a-path-finding-c-4a4h

Hope this helps!

Thanks, will check it out 😀

Edited by Swiss Cheese

Share this post


Link to post
Share on other sites

BFS is the easiest algorithm to implement which finds an optimal path.  Even though A* is typically recommended for pathfinding, BFS is much easier to implement correctly and works great for mazes in particular.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!