Table of Contents

Class UniformCostCalculator

Namespace
Core.Systems
Assembly
Core.dll

Default cost calculator - all provinces cost 1. Use when no terrain or ownership modifiers needed.

public class UniformCostCalculator : IMovementCostCalculator
Inheritance
object
UniformCostCalculator
Implements

Fields

Instance

public static readonly UniformCostCalculator Instance

Field Value

UniformCostCalculator

Methods

CanTraverse(ushort, PathContext)

Check if a province can be traversed at all. Called before GetMovementCost - return false to skip entirely.

public 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.

public 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.

public 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