Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2d grid reachable destinations

Let's say I have a 2d grid. Pathfinding is a secondary step in my problem.

My thing is, lets say I have a unit in the middle of the grid. I want to be able to tell the user "These are all your available destinations.".

Based on how many squares the unit can walk, I want to show the user, "these are all the squares you can reach." and then pathfind the destination the user picks.

What's the best way to do the first search to show the reachable destinations?

The terrain can also have limits och bonuses depending on terrain.

I don't know what this is called so pointers on where to look or what to google would be greatly appreciated.

Cheers! :)

/E

like image 980
Einarsson Avatar asked Dec 10 '25 03:12

Einarsson


1 Answers

The best way would probably be depth first search (http://en.wikipedia.org/wiki/Depth_first_search) with a limit on how far away you can go.

like image 124
Elva Avatar answered Dec 13 '25 00:12

Elva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!