⚙️ ALLOY RUNE DIFFICULTY: Apprentice Behavioral

The Strategy: The Algorithmic Grimoire

Define a family of algorithms, encapsulate each one, and make them interchangeable.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tactics-Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ALLOY PATTERN //
abstract sig TacticalSpell {
  yield: lone ExecutionTrace
}

sig BruteForceSpell, StealthInjectionSpell extends TacticalSpell {}

sig CombatNode {
  activeSpell: one TacticalSpell,
  result: lone ExecutionTrace
}
{
  result = activeSpell.yield
}

sig ExecutionTrace {}

pred engage_node[n: CombatNode] {
  some n.result
}

run engage_node for 3

The Strategy: The Algorithmic Grimoire

Though identical in structure to the State pattern within a static snapshot, the Intent is different. The CombatNode selects a TacticalSpell from its grimoire, swapping its computational approach. Alloy verifies that regardless of the spell chosen, the ExecutionTrace flows correctly.

Runic Tags: #behavioral #strategy #tactics