Translation: MetaCat
Non-player characters (NPCs) are permanent residents of the game world whose behavior is not controlled by the player. Instead, their behavior is determined by a set of pre-written conditions created by the game developer, which evaluate the actions the NPC should take based on the state of the world. NPCs usually appear in the form of quest givers and companions for dialogue-driven story advancement, vendors distributing items, or engaging in combat with enemies.
Our game Duck Duck Destruction is a case that demonstrates a model that enables players to script decision trees for NPCs and deploy them in an autonomous world.
Motivation
Our primitives are less subjective than projects such as Gnomik or Sentences, which introduce rules and lore crafting to gameplay through a dedicated top-down master control layer. In contrast, our approach allows players to make subtle contributions to the world, keeping it alive without destroying its basic mechanics. We believe that player-deployable NPCs are a favorable medium for collective creation and emergent storytelling, as they enable expression and interaction while maintaining the integrity of the world's infrastructure.
Mechanics
Duck Duck Destruction is a game of entirely player-written NPC ducks that fight in an arena environment. Players program their ducks via decision tree smart contracts that determine the NPC's behavior as conditional responses to in-game events: "If shot at, move away from your current location" or "Attack any duck that comes into melee range."
After a sufficient number of players submit decision trees, the game host starts the game. The game then proceeds automatically, with each round prompting the ducks to take actions based on the programmed decision trees. The game ends when all ducks are eliminated or when the last duck is alive.

NPC Behavior Script: Graphical Example of a Decision Tree
Smart Contract
Each NPC script is a smart contract deployed on a MUD/EVM compatible stack. To add these scripts to a given world, the world contract needs a registration function that allows players to submit the addresses of their deployed NPC smart contracts. This function can be selectively restricted based on game progress, asset ownership, or a simple address whitelist.
Once a script is registered, it will be called by the parent world directly, or as an indirect result of a player's action. Since the MUD/EVM underlying lacks a tick mechanism or other method of autonomously activating scripts, it is inherently passive, and any actions taken by the NPC are premised on actions initiated by the player. Therefore, the script's parent world must contain a function call that triggers the NPC script to execute.
Once triggered, the NPC script uses the world state and evaluates a course of action based on its predefined logic and programming.
Application
Duck Duck Destruction places NPCs in a fast-paced combat environment to minimally showcase our primitive underlying mechanics. Due to its session-based model, it currently functions similarly to an NPC nursery, lacking a richer surrounding environment to interact with directly.
However, we can imagine the use of this primitive element in a more open sandbox world, where NPC reactions are triggered asynchronously via player prompts. An example might be a companion pet with a programmable personality that follows the player around and reacts uniquely to the environment and other characters, leading to complexity in their behavior. This complexity results in a world that is unpredictable and full of surprises. An example of this is found in Dwarf Fortress, where players stumble upon NPC hippos in a sewer they built because their logic determines that an environment with water is a suitable habitat.
In a world that allows for the deployment of hierarchical NPCs and allows them to perform different actions, players can also collaboratively direct branching quest lines in a chained story-like manner, where interactions between player characters and NPCs drive determination and pursuit of a shared goal.
Alternatives
Conceptually, alternatives could leverage player-written logic beyond the representations of NPCs and extend its application to parts of the world landscape or equippable items. This could be an outpost whose flags and decorations change from clean to worn when under siege by guerrillas, or a player-programmed cyberpunk gadget that triggers smoke bombs from the player's inventory whenever an opponent uses a ranged weapon.
While our work attempts to explicitly frame transparency as a generative feature, implementations built using zero-knowledge proofs could be leveraged in more competitive contexts. An example of this is Topology’s Shoshin, which allows players to script and submit combat NPCs with private decision trees. Zero-knowledge stacks such as EZKL enable verifiable off-chain computation tasks, and also allow for more complex and expressive NPC logic, including AI/ML model integration.
Both alternative approaches suffer from the drawback of making chain storytelling interoperability less intuitive. EZKL in particular makes the world mechanics less strictly autonomous due to its reliance on a proof backend. Nonetheless, we find these alternatives interesting as they enable worlds to incorporate exploration into gameplay, provide a better contributor experience, and potentially enhance bot resistance.
Extensions
Currently, players who start a Duck Duck Destruction game match are responsible for the network fees incurred by running all NPC contracts registered under them. This could be improved with a dedicated fund contract that allows players to pool resources, or a gas subsidy model with a payer extension.
Acknowledgements
Contract design and engineering by Norswap. Visual asset pack by Tea Strazicic, SFX by Orion Ohana, released under CC BY 4.0.