Tilebased game movement calculation

I need some tips on how i should get forward. I have done everything to make a tilebased game. But the problem i have is how to calculate the spaces the unit can move in.

So lets say the unit can move in 10 steps. Then before the player move him. I need something to calculate what tiles he can move in and then highlight them. The problem i have is how to figure out the way the recursive function should work.

Any tips on how it should work is welcome (how it should move step by step). I do not need help on how to highlight the tile or anything like that.

The unit is suppose to be able to move in 4 directions (up, down, left and right) But how should it check the spaces it can walk in until the steps is 0

Thanks for any tips. (code snipped or maybe links on something i can read up on)

Typically you’d use a [edit xxxdepthxxx] breadth-first search (the same thing A* uses.)

A brute-force way, number the player square with a 0. Then loop 10 times. On step N, find all the squares marked with an N (use a giant nested loop to look at all squares within 10) Mark all the unmarked neighbors with N+1. The queue in a real breath-first search is just a faster way to find all the squares you can “grow.”