The Strategy of Magical Combat
Dynamically swap spellcasting tactics at runtime via higher-order predicates.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tacticmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PROLOG PATTERN //
% The Strategies (Tactics)
tactic_aggressive(Target) :-
format('Casting furious firebolts at ~w!', [Target]).
tactic_defensive(Target) :-
format('Raising a shield of ice against ~w!', [Target]).
tactic_stealth(Target) :-
format('Fading into the shadows near ~w...', [Target]).
% The Context
% Takes a strategy predicate name as an argument and calls it
engage_combat(Target, Strategy) :-
call(Strategy, Target).
% ?- engage_combat(dragon, tactic_defensive).
% "Raising a shield of ice against dragon!"
Runic Tags:
#strategy
#behavioral
#prolog
#tactics
#dynamic-call