Skip to main content

Module weight_source

Module weight_source 

Source
Expand description

WeightSource trait for computing attack weights from external state (relationship metadata, personality traits, etc.).

This is a deliberately minimal abstraction for v0.1.0 — it exists so consumers like the future encounter crate can pass a policy closure for deriving weights, without coupling this crate to any specific narrative-stack types. The full encounter-specific integration lives in whatever bridge crate the narrative team ships; this trait is just the hook.

Structs§

ClosureWeightSource
A closure-based WeightSource that wraps any Fn(&A, &A) -> Option<f64>.

Traits§

WeightSource
A source of attack weights. Given an attacker and a target (and whatever context Self carries), produce the weight for the corresponding attack edge.

Functions§

populate_from_source
Populate a WeightedFramework from a list of attack pairs, pulling each weight from the provided WeightSource. Pairs for which the source returns None are skipped. Pairs for which the source returns an invalid weight propagate an Error::InvalidWeight.