The State
Morphing the behavior of a ghoul based on its inner hunger.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Necromancy // Form Shifting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BARE METAL ARCHITECTURE RUNE //
section .data
current_state dq state_idle
section .text
global _start
_start:
; Act based on current state
mov rax, [current_state]
call rax
; Transition to frenzied
mov qword [current_state], state_frenzied
mov rax, 60
syscall
state_idle:
; Wander aimlessly
ret
state_frenzied:
; Attack aggressively
ret
The State pattern allows an entity to radically alter its behavior when its internal state changes. By simply swapping a function pointer in memory, the underlying chassis seamlessly transitions from a dormant idle to a ravenous frenzy.
Runic Tags:
#state
#assembly
#behavioral
#necromancy