The Abstract Factory of the Prolog Oracle
Conjure families of related ancient artifacts through logic queries.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Rulemancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PROLOG PATTERN //
% The Universal Truths of Artifact Creation
% Abstract factories (or rather, the predicates defining the origin rules)
factory(elven_forge).
factory(dwarven_forge).
% Product A: Swords
create_sword(elven_forge, mithril_blade).
create_sword(dwarven_forge, adamantine_cleaver).
% Product B: Shields
create_shield(elven_forge, star_buckler).
create_shield(dwarven_forge, deep_bulwark).
% Client query to summon a matching set
equip_hero(Factory, Sword, Shield) :-
factory(Factory),
create_sword(Factory, Sword),
create_shield(Factory, Shield).
% ?- equip_hero(elven_forge, Sword, Shield).
% Sword = mithril_blade,
% Shield = star_buckler.
Runic Tags:
#abstract-factory
#creational
#prolog
#logic
#oracle