Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
anonymous_namespace{CCmpUnitMotion.h} Namespace Reference

Classes

struct  PathColorPalette
 

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 std::uint8_t 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 std::uint8_t KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN = 12
 When following a known imperfect path (i.e. More...
 
constexpr std::uint8_t 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 std::uint8_t 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 std::uint8_t ALTERNATE_PATH_TYPE_EVERY = 6
 
constexpr std::uint8_t BACKUP_HACK_DELAY = 10
 Units can occasionally get stuck near corners. More...
 
constexpr std::uint8_t VERY_OBSTRUCTED_THRESHOLD = 10
 After this many failed computations, start sending "VERY_OBSTRUCTED" messages instead. More...
 
constexpr PathColorPalette REGULAR_UNIT_PALETTE {{1, 1, 1, 1}, {1, 0, 0, 1}}
 
constexpr PathColorPalette FORMATION_CONTROLLER_PALETTE {{0, 0, 1, 1}, {0, 1, 0, 1}}
 

Variable Documentation

◆ ALTERNATE_PATH_TYPE_DELAY

constexpr std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::ALTERNATE_PATH_TYPE_DELAY = 3
constexpr

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 std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::ALTERNATE_PATH_TYPE_EVERY = 6
constexpr

◆ BACKUP_HACK_DELAY

constexpr std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::BACKUP_HACK_DELAY = 10
constexpr

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)
constexpr

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

◆ FORMATION_CONTROLLER_PALETTE

constexpr PathColorPalette anonymous_namespace{CCmpUnitMotion.h}::FORMATION_CONTROLLER_PALETTE {{0, 0, 1, 1}, {0, 1, 0, 1}}
constexpr

◆ KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN

constexpr std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN = 12
constexpr

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)
constexpr

Minimum distance to goal for a long path request.

◆ MAX_FAILED_MOVEMENTS

constexpr std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::MAX_FAILED_MOVEMENTS = 35
constexpr

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.

◆ REGULAR_UNIT_PALETTE

constexpr PathColorPalette anonymous_namespace{CCmpUnitMotion.h}::REGULAR_UNIT_PALETTE {{1, 1, 1, 1}, {1, 0, 0, 1}}
constexpr

◆ 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)
constexpr

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)
constexpr

◆ 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)
constexpr

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 std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::SHORT_PATH_SEARCH_RANGE_INCREASE_DELAY = 1
constexpr

◆ 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)
constexpr

◆ TARGET_UNCERTAINTY_MULTIPLIER

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

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 std::uint8_t anonymous_namespace{CCmpUnitMotion.h}::VERY_OBSTRUCTED_THRESHOLD = 10
constexpr

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

Should probably be larger than ALTERNATE_PATH_TYPE_DELAY.