The Strategy
Hot-swapping mathematical theorems to adapt the ward's defensive geometry on the fly.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Transmutation // Theorems
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LEAN PATTERN //
namespace MathematicalWards
def Strategy := Nat → Nat
def linearDefense : Strategy := fun x => x * 2
def exponentialDefense : Strategy := fun x => x * x
structure DynamicWard where
mana : Nat
currentStrategy : Strategy
def executeDefense (w : DynamicWard) : Nat :=
w.currentStrategy w.mana
def adaptWard (w : DynamicWard) : DynamicWard :=
{ w with currentStrategy := exponentialDefense }
end MathematicalWards
The Strategy pattern in functional languages is merely first-class functions passed as data, allowing dynamic reassignment of behavior.
Runic Tags:
#behavioral
#lean4
#strategy
#wards