Pathfinding for free units

From Unknown Horizons

Jump to: navigation, search

Contents

Summary

We need to have a list of walkable tiles for units, that are not bound to e.g. streets or farms such as wild animals or soldiers.

Points to Fulfill

  • Unit must not walk on water
  • Unit must not walk over buildings, but can walk over streets
  • Unit must not walk over another unit

Detailed Description

We have a list of coords, that belong to an island, and since units can't walk over water, it's useful to separate this list islandwise. From this list of coords we have to remove all coords, that aren't walkable, and for every category of non-walkable ground, we have to have a way of checking.

For changing grounds, such as buildings (they might disappear or appear at any time), this should happen really fast and easy, and will have to be checked every time a unit makes a step.

Implementation details

Island have a get_coordinates-method, based on this, we can create a get_walkable_coordinates method, which filters out the water and mountain coords from the result of the first function.

The pather must know, on which island the unit is on to get the list of coordinates. It can communicate with the island in the find_path and get_next_step functions, to find out, if a building or something like that is blocking the way. For this purpose, a function called something like check_walkability_of_tile_for_changing_ground will be implemented (with the differences to get_walkable_coordinates clearly documented). this checks if a building or something like that is here, probably by checking tile.object.

Open Questions

  • How can we find out, if a ground class is walkable?
  • Can we build a building on a unit?
    • I'd say no, but it's a problem, if you want to build a big building, and a wild animal is blocking the ground and possibly doesn't go away for some time.
Personal tools
Unknown Horizons
Design Document