Table of Contents

Interface IMovementCostCalculator

Namespace
Core.Systems
Assembly
Core.dll

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

provinceId ushort
context PathContext

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

fromProvinceId ushort
goalProvinceId ushort

Returns

FixedPoint64

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

fromProvinceId ushort

Source province

toProvinceId ushort

Destination province (adjacent to source)

context PathContext

Optional context (unit owner, unit type, etc.)

Returns

FixedPoint64