Interface IMovementCostCalculator
ENGINE: Interface for calculating movement costs between provinces.
Allows GAME layer to provide custom cost calculations based on:
- Terrain type (mountains cost more than plains)
- Province ownership (enemy territory costs more)
- Unit type (cavalry faster on plains, slower in forests)
- Weather, supply, fortifications, etc.
Default implementation: UniformCostCalculator (all costs = 1)
public interface IMovementCostCalculator
Methods
CanTraverse(ushort, PathContext)
Check if a province can be traversed at all. Called before GetMovementCost - return false to skip entirely.
bool CanTraverse(ushort provinceId, PathContext context)
Parameters
provinceIdushortcontextPathContext
Returns
- bool
GetHeuristic(ushort, ushort)
Get heuristic estimate from province to goal (for A*). Must be admissible (never overestimate actual cost). Default: return FixedPoint64.One (safe but slow). Better: return distance-based estimate if coordinates available.
FixedPoint64 GetHeuristic(ushort fromProvinceId, ushort goalProvinceId)
Parameters
fromProvinceIdushortgoalProvinceIdushort
Returns
GetMovementCost(ushort, ushort, PathContext)
Get movement cost from one province to an adjacent province. Higher cost = less desirable path. Return FixedPoint64.MaxValue to indicate impassable.
FixedPoint64 GetMovementCost(ushort fromProvinceId, ushort toProvinceId, PathContext context)
Parameters
fromProvinceIdushortSource province
toProvinceIdushortDestination province (adjacent to source)
contextPathContextOptional context (unit owner, unit type, etc.)