Strategy of the Tactician's Codex
Define a family of algorithms, encapsulate each one, and make them interchangeable.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Divination // Tactical-insight
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// RUST IDIOMATIC PATTERN //
pub trait PathfindingStrategy {
fn route(&self, start: &str, end: &str);
}
pub struct StealthRoute;
impl PathfindingStrategy for StealthRoute {
fn route(&self, start: &str, end: &str) { println!("Routing {} to {} via shadowy sub-nets.", start, end); }
}
pub struct AssaultRoute;
impl PathfindingStrategy for AssaultRoute {
fn route(&self, start: &str, end: &str) { println!("Blazing direct path from {} to {}.", start, end); }
}
pub struct Navigator {
strategy: Box<dyn PathfindingStrategy>,
}
impl Navigator {
pub fn set_strategy(&mut self, s: Box<dyn PathfindingStrategy>) { self.strategy = s; }
pub fn execute(&self) { self.strategy.route("Node Alpha", "Mainframe"); }
}
The Tactician’s Codex stores a vast array of algorithms, from stealth routing to outright frontal assault vectoring. The Strategy pattern allows the cyber-mage to encapsulate these behaviors and hot-swap them at runtime.
Instead of hardcoding complex navigation logic into the drone’s chassis, the drone merely delegates the decision-making to the currently active Strategy. As the grid environment shifts, the mage swaps the algorithm to match the threat.
Runic Tags:
#behavioral
#strategy
#divination
#algorithms