🥞 FORTH STACK DIFFICULTY: Adept Behavioral

State (Forth)

Mutate an entity's soul dynamically via XT vectoring.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Soul-Shifting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FORTH PATTERN //
\ Soul-Shifting: The State Pattern
\ Changing the behavior of a word by updating a DEFER.

DEFER BEHAVIOR

: PEACEFUL-STATE ( -- ) ." The golem stands idle." CR ;
: ENRAGED-STATE ( -- ) ." The golem SMASHES!" CR ;

: PROVOKE ( -- )
  ' ENRAGED-STATE IS BEHAVIOR
  ." Golem provoked!" CR ;

: CALM ( -- )
  ' PEACEFUL-STATE IS BEHAVIOR
  ." Golem pacified." CR ;

\ Usage:
\ CALM BEHAVIOR
\ PROVOKE BEHAVIOR

The State pattern alters an entity’s entire paradigm without changing its identifier. By heavily leveraging DEFER and IS, a word’s underlying execution vector changes dynamically. The entity behaves entirely differently based on the soul currently bound to it.

Runic Tags: #behavioral #state #forth #mutation