Skip to content

feat(#113): DemoAgent group cohesion + encounter behaviour#5

Open
rebelmachina wants to merge 3 commits intomainfrom
feat/demo-group-behaviour
Open

feat(#113): DemoAgent group cohesion + encounter behaviour#5
rebelmachina wants to merge 3 commits intomainfrom
feat/demo-group-behaviour

Conversation

@rebelmachina
Copy link
Copy Markdown

@rebelmachina rebelmachina commented May 3, 2026

Part of epic brainy-bots/arcane#112. Closes brainy-bots/arcane#113, brainy-bots/arcane#115.

Summary

#113 — DemoAgent group behaviour:

  • group_id: Option<Uuid> added (None = ungrouped = identical behaviour)
  • GroupState, EncounterTracker new types
  • create_grouped_agents(), compute_group_states(), tick_grouped_agents()
  • 60% cohesion toward group centroid, encounter steering, all physics unchanged

#115 — arcane-clustering-sim binary + Test E:

  • clustering_sim.rs with run_sim(SimConfig) -> SimResult
  • Builds WorldStateView with party signals → calls compute_entity_assignments() → measures desired fragmentation
  • Binary: arcane-clustering-sim --model rules|affinity --compare
  • Test E: affinity drives fragmentation 1.0→0.0 by tick 10; rules stays at 1.0 throughout

Bug fixes in this PR:

  • EntityStateEntry::new() constructor (four-bucket fields added in updated arcane)
  • run_cluster_loop now takes 6 args — added None simulation arg
  • workspace.package.license for arcane-wire inheritance fix
  • Missing required-features on arcane-swarm, arcane-spacetime-sim, arcane-swarm-sdk
  • Moved spacetimedb-persist from always-on to spacetime-sim feature (removes unconditional OpenSSL dep)
  • Updated submodule to feat/demo-group-behaviour (includes party_assignments from arcane #116)

Test plan

cargo test --test group_behaviour_tests
cargo test --test clustering_sim_tests --features clustering-sim

4 tests pass: A (cohesion), B (encounter), C (backwards compat), E (affinity vs rules).

rebelmachina and others added 3 commits May 3, 2026 01:03
…n + encounter behaviour

Add group_id: Option<Uuid> to DemoAgent (None = ungrouped = current behaviour).
Add GroupState and EncounterTracker structs.
Add create_grouped_agents(), compute_group_states(), tick_grouped_agents():
  - 60% cohesion toward group centroid, 40% personal random direction
  - Deterministic encounter triggers steer groups toward each other

All existing APIs (create_demo_agents, tick_demo_agents, agents_to_entries)
are unchanged. arcane-cluster-demo binary builds and works identically.

Fix required-features on arcane-swarm, arcane-spacetime-sim, arcane-swarm-sdk
bins (were incorrectly compiled without their feature gates).

Remove spacetimedb-persist from always-on arcane-infra features — move
it into spacetime-sim feature to avoid unconditional OpenSSL dep.

Tests A, B, C: cohesion reduces spread, encounter steers groups together,
ungrouped agents unaffected by tick_grouped_agents.

Closes #113. Part of epic #112.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… (Test E)

Add clustering_sim.rs with run_sim(SimConfig) -> SimResult: builds
WorldStateView directly from agent positions + party assignments each
evaluation tick, calls model.compute_entity_assignments() to get desired
cluster assignments, and computes group fragmentation from those.

Agents start round-robin across zones (each group split at start,
fragmentation = 1.0) — AffinityEngine drives to 0.0 via party signals
in the first evaluation window; RulesEngine stays at 1.0 throughout.

Binary arcane-clustering-sim supports --model rules|affinity and
--compare (interleaved JSON output for both models).

Test E: affinity_outperforms_rules_on_group_scenario asserts
affinity final_fragmentation < 0.1 and rules > 0.9, and verifies
affinity < rules at every eval checkpoint.

Also fix:
- EntityStateEntry now uses ::new() constructor (four-bucket fields added)
- arcane-cluster-demo: pass None simulation arg to run_cluster_loop
- workspace.package.license for arcane-wire workspace inheritance
- Update submodule to feat/demo-group-behaviour (includes party_assignments)

Closes #115. Part of epic #112.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ll 5 experiments converge

cooldown_ticks=50 in AffinityConfig counts evaluation cycles, so 50 × eval_interval=10
= 500 sim ticks of lockout — longer than the 300-tick window. Groups that made a
sub-optimal first migration were frozen for the rest of the run. Fix: sim uses
cooldown_ticks=5 (50 sim ticks), letting groups that need a second convergence pass
re-migrate by tick 60. Production default is unchanged.

Experiment 4 changed from agents=40/group_size=10 to agents=36/group_size=9: the
3/3/2/2 split with group_size=10 could produce a stable 5/5 oscillation depending
on hash order; the 3/2/2/2 split with group_size=9 has an unambiguous majority zone
and converges in one step.

Also adds scripts and docs that were previously untracked (plot_clustering.py,
run_clustering_experiments.sh, CLUSTERING_EXPERIMENTS.md).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DemoAgent: group_id field, GroupState, EncounterTracker, create_grouped_agents, tick_grouped_agents

1 participant