Pathfinding in turn-based strategy game
What you're trying to compute here is the cost of the unit to travel to each accessible square in the region. You do it by iterating over all squares in the region, computing a path to the destination square, and adding up the cost of getting there.

Suppose that this figure shows the cost of traversing each square, and you have a unit in the square marked A:

┌───┬───┬───┬───┐
│ 1 │ 2 │ 1 │ 1 │
├───┼───┼───┼───┤
│ 2 │ 2 │ 2 │ 1 │
├───┼───┼───┼───┤
│ 1 │ 3 │ 1 │ 1 │
├───┼───┼───┼───┤
│ 1 │ 2 │ 1 │ A │
└───┴───┴───┴───┘


Then your algorithm goes like this:

┌───┬───┬───┬───┐    ┌───┬───┬───┬───┐    ┌───┬───┬───┬───┐    ┌───┬───┬───┬───┐
│ * │ . │ . │ . │    │ . │ * │ . │ . │    │ . │ . │ * │ . │    │ . │ . │ . │ * │
├───┼───┼───┼───┤    ├───┼───┼───┼───┤    ├───┼───┼───┼───┤    ├───┼───┼───┼───┤
│ . │ * │ . │ . │    │ . │ * │ . │ . │    │ . │ . │ * │ . │    │ . │ . │ . │ * │
├───┼───┼───┼───┤    ├───┼───┼───┼───┤    ├───┼───┼───┼───┤    ├───┼───┼───┼───┤
│ . │ . │ * │ . │    │ . │ . │ * │ . │    │ . │ . │ * │ . │    │ . │ . │ . │ * │
├───┼───┼───┼───┤    ├───┼───┼───┼───┤    ├───┼───┼───┼───┤    ├───┼───┼───┼───┤
│ . │ . │ . │ A │    │ . │ . │ . │ A │    │ . │ . │ . │ A │    │ . │ . │ . │ A │
└───┴───┴───┴───┘    └───┴───┴───┴───┘    └───┴───┴───┴───┘    └───┴───┴───┴───┘
1 + 2 + 1 = 4        1 + 2 + 2 = 5        1 + 2 + 1 = 4        1 + 1 + 1 = 3


and so on. There is wasted work here, because each path starts again from scratch instead of making use of previously computed information. The point is that after computing the first path above, we already know the following costs:

┌───┬───┬───┬───┐
│ 4 │ . │ . │ . │
├───┼───┼───┼───┤
│ . │ 3 │ . │ . │
├───┼───┼───┼───┤
│ . │ . │ 1 │ . │
├───┼───┼───┼───┤
│ . │ . │ . │ A │
└───┴───┴───┴───┘


and so to compute the second path we can start from the square marked "3" instead of having to start all the way back at A.

If you make this idea into an algorithm then you get Dijkstra's algorithm.

But you may be able to do better than that. If the cost of moving over a square of terrain never changes during the game, then the cost of moving along a path never changes either. So you could pre-compute the cost of all paths (using the Floyd–Warshall algorithm) and remember them.