Pyrogenesis  trunk
Functions | Variables
anonymous_namespace{CCmpUnitMotion.h} Namespace Reference

Functions

const CColor OVERLAY_COLOR_LONG_PATH (1, 1, 1, 1)
 
const CColor OVERLAY_COLOR_SHORT_PATH (1, 0, 0, 1)
 

Variables

constexpr entity_pos_t SHORT_PATH_MIN_SEARCH_RANGE = entity_pos_t::FromInt(12 * Pathfinding::NAVCELL_SIZE_INT)
 Min/Max range to restrict short path queries to. More...
 
constexpr entity_pos_t SHORT_PATH_MAX_SEARCH_RANGE = entity_pos_t::FromInt(56 * Pathfinding::NAVCELL_SIZE_INT)
 
constexpr entity_pos_t SHORT_PATH_SEARCH_RANGE_INCREMENT = entity_pos_t::FromInt(4 * Pathfinding::NAVCELL_SIZE_INT)
 
constexpr u8 SHORT_PATH_SEARCH_RANGE_INCREASE_DELAY = 1
 
constexpr entity_pos_t SHORT_PATH_LONG_WAYPOINT_RANGE = entity_pos_t::FromInt(4 * Pathfinding::NAVCELL_SIZE_INT)
 When using the short-pathfinder to rejoin a long-path waypoint, aim for a circle of this radius around the waypoint. More...
 
constexpr entity_pos_t LONG_PATH_MIN_DIST = entity_pos_t::FromInt(16 * Pathfinding::NAVCELL_SIZE_INT)
 Minimum distance to goal for a long path request. More...
 
constexpr entity_pos_t DIRECT_PATH_RANGE = entity_pos_t::FromInt(24 * Pathfinding::NAVCELL_SIZE_INT)
 If we are this close to our target entity/point, then think about heading for it in a straight line instead of pathfinding. More...
 
constexpr entity_pos_t TARGET_UNCERTAINTY_MULTIPLIER = entity_pos_t::FromInt(8 * Pathfinding::NAVCELL_SIZE_INT)
 To avoid recomputing paths too often, have some leeway for target range checks based on our distance to the target. More...
 
constexpr u8 KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN = 12
 When following a known imperfect path (i.e. More...
 
constexpr u8 MAX_FAILED_MOVEMENTS = 35
 When we fail to move this many turns in a row, inform other components that the move will fail. More...
 
constexpr u8 ALTERNATE_PATH_TYPE_DELAY = 3
 When computing paths but failing to move, we want to occasionally alternate pathfinder systems to avoid getting stuck (the short pathfinder can unstuck the long-range one and vice-versa, depending). More...
 
constexpr u8 ALTERNATE_PATH_TYPE_EVERY = 6
 
constexpr u8 BACKUP_HACK_DELAY = 10
 Units can occasionally get stuck near corners. More...
 
constexpr u8 VERY_OBSTRUCTED_THRESHOLD = 10
 After this many failed computations, start sending "VERY_OBSTRUCTED" messages instead. More...
 

Function Documentation

◆ OVERLAY_COLOR_LONG_PATH()

const CColor anonymous_namespace{CCmpUnitMotion.h}::OVERLAY_COLOR_LONG_PATH ( ,
,
,
 
)

◆ OVERLAY_COLOR_SHORT_PATH()

const CColor anonymous_namespace{CCmpUnitMotion.h}::OVERLAY_COLOR_SHORT_PATH ( ,
,
,
 
)

Variable Documentation

◆ ALTERNATE_PATH_TYPE_DELAY

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::ALTERNATE_PATH_TYPE_DELAY = 3

When computing paths but failing to move, we want to occasionally alternate pathfinder systems to avoid getting stuck (the short pathfinder can unstuck the long-range one and vice-versa, depending).

◆ ALTERNATE_PATH_TYPE_EVERY

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::ALTERNATE_PATH_TYPE_EVERY = 6

◆ BACKUP_HACK_DELAY

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::BACKUP_HACK_DELAY = 10

Units can occasionally get stuck near corners.

The cause is a mismatch between CheckMovement and the short pathfinder. The problem is the short pathfinder finds an impassable path when units are right on an obstruction edge. Fixing this math mismatch is perhaps possible, but fixing it in UM is rather easy: just try backing up a bit and that will probably un-stuck the unit. This is the 'failed movement' turn on which to try that.

◆ DIRECT_PATH_RANGE

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::DIRECT_PATH_RANGE = entity_pos_t::FromInt(24 * Pathfinding::NAVCELL_SIZE_INT)

If we are this close to our target entity/point, then think about heading for it in a straight line instead of pathfinding.

◆ KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN = 12

When following a known imperfect path (i.e.

a path that won't take us in range of our goal we still recompute a new path every N turn to adapt to moving targets (for example, ships that must pickup units may easily end up in this state, they still need to adjust to moving units). This is rather arbitrary and mostly for simplicity & optimisation (a better recomputing algorithm would not need this).

◆ LONG_PATH_MIN_DIST

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::LONG_PATH_MIN_DIST = entity_pos_t::FromInt(16 * Pathfinding::NAVCELL_SIZE_INT)

Minimum distance to goal for a long path request.

◆ MAX_FAILED_MOVEMENTS

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::MAX_FAILED_MOVEMENTS = 35

When we fail to move this many turns in a row, inform other components that the move will fail.

Experimentally, this number needs to be somewhat high or moving groups of units will lead to stuck units. However, too high means units will look idle for a long time when they are failing to move. TODO: if UnitMotion could send differentiated "unreachable" and "currently stuck" failing messages, this could probably be lowered. TODO: when unit pushing is implemented, this number can probably be lowered.

◆ SHORT_PATH_LONG_WAYPOINT_RANGE

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::SHORT_PATH_LONG_WAYPOINT_RANGE = entity_pos_t::FromInt(4 * Pathfinding::NAVCELL_SIZE_INT)

When using the short-pathfinder to rejoin a long-path waypoint, aim for a circle of this radius around the waypoint.

◆ SHORT_PATH_MAX_SEARCH_RANGE

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::SHORT_PATH_MAX_SEARCH_RANGE = entity_pos_t::FromInt(56 * Pathfinding::NAVCELL_SIZE_INT)

◆ SHORT_PATH_MIN_SEARCH_RANGE

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::SHORT_PATH_MIN_SEARCH_RANGE = entity_pos_t::FromInt(12 * Pathfinding::NAVCELL_SIZE_INT)

Min/Max range to restrict short path queries to.

(Larger ranges are (much) slower, smaller ranges might miss some legitimate routes around large obstacles.) NB: keep the max-range in sync with the vertex pathfinder "move the search space" heuristic.

◆ SHORT_PATH_SEARCH_RANGE_INCREASE_DELAY

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::SHORT_PATH_SEARCH_RANGE_INCREASE_DELAY = 1

◆ SHORT_PATH_SEARCH_RANGE_INCREMENT

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::SHORT_PATH_SEARCH_RANGE_INCREMENT = entity_pos_t::FromInt(4 * Pathfinding::NAVCELL_SIZE_INT)

◆ TARGET_UNCERTAINTY_MULTIPLIER

constexpr entity_pos_t anonymous_namespace{CCmpUnitMotion.h}::TARGET_UNCERTAINTY_MULTIPLIER = entity_pos_t::FromInt(8 * Pathfinding::NAVCELL_SIZE_INT)

To avoid recomputing paths too often, have some leeway for target range checks based on our distance to the target.

Increase that incertainty by one navcell for every this many tiles of distance.

◆ VERY_OBSTRUCTED_THRESHOLD

constexpr u8 anonymous_namespace{CCmpUnitMotion.h}::VERY_OBSTRUCTED_THRESHOLD = 10

After this many failed computations, start sending "VERY_OBSTRUCTED" messages instead.

Should probably be larger than ALTERNATE_PATH_TYPE_DELAY.