Skip to content

Implement AffinityEngine core — IClusteringModel::evaluate() #70

@rebelmachina

Description

@rebelmachina

Epic: #64 (AffinityEngine)
Depends on: #66 (InteractionGraph), #67 (MigrationState), #68 (AffinityConfig), #69 (ClusterScorer)

What

Implement the main AffinityEngine struct in crates/arcane-affinity/src/lib.rs:

Seven-phase algorithm

  1. Update interaction graph (decay + inject party/guild/proximity signals)
  2. Tick migration cooldowns
  3. Compute cluster centroids and membership from view
  4. Score each entity, determine reassignments (threshold + cooldown check)
  5. Spatial fallback for new entities
  6. Cleanup removed entities
  7. Convert per-entity assignments to merge/split ClusterDecisions

Phase 7 translation heuristics

  • Merge: ≥ merge_entity_threshold entities in A want to move to B → emit Merge(A, B)
  • Split: cluster has two non-interacting subgroups (connected components in interaction graph restricted to cluster) → emit Split(cluster, group_a, group_b)

Acceptance criteria

  • Full evaluate() implementation with all 7 phases
  • validate_view() warns on empty players
  • Integration test with synthetic WorldStateView returning valid decisions

Spec

See arcane-engine repo: in_08_affinity_engine.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions