Translation: MetaCat
Non-Player Characters (NPCs) are permanent residents of the gaming world whose behavior is not controlled by players. Instead, their actions are determined by a set of pre-written conditions created by game developers, which evaluate the actions NPCs should take based on the world’s state. NPCs typically appear in the form of quest givers and companions, engaging in dialogue-driven story progression, distributing items as vendors, or engaging in combat with enemies.
Our game “Duck Duck Destruction” serves as a case study, showcasing a pattern that allows players to write decision tree scripts for NPCs and deploy them in an autonomous world.
Motivation
Compared to projects like Gnomik or Sentences, our paradigm has less subjective bias, as the former introduces rules and lore into gameplay through a dedicated top-down control layer. In contrast, our approach allows players to make subtle contributions to the world, maintaining its vitality without disrupting its fundamental mechanics. We believe that player-deployed NPCs are a beneficial medium for collective creation and emerging storytelling, as they can both express and interact while preserving the integrity of the world’s structure.
Mechanics
“Duck Duck Destruction” is a game where players program NPC ducks to battle in an arena environment using decision tree smart contracts. These smart contracts determine NPC behavior as conditional responses to in-game events: “If shot, move away from current location” or “Attack any ducks entering melee range.”
Once a sufficient number of players submit decision trees, the game host initiates the game. The game then proceeds automatically, prompting ducks to take action based on their programmed decision trees each round. The game ends when all ducks are eliminated or the last duck survives.
NPC Behavior Script: Example of a decision tree diagram
Smart Contracts
Each NPC script is a smart contract deployed on an 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 address of their deployed NPC smart contract. This function can be selectively restricted based on game progress, asset ownership, or a simple address whitelist.
Once the script is registered, the parent world directly calls it or as an indirect result of player actions. Since the MUD/EVM lacks a Tick mechanism or other means to autonomously activate scripts, it is essentially passive, with any actions taken by NPCs predicated on player-initiated actions. Therefore, the parent world of the script must include a function call to trigger NPC script execution.
Once triggered, the NPC script uses the world state to evaluate action plans based on its predefined logic and programming.
Applications
“Duck Duck Destruction” places NPCs in a fast-paced combat environment to showcase our original underlying mechanics minimally. Due to its session-based model, its current functionality resembles a nursery for NPCs, lacking a richer environment for direct interaction.
However, we can envision the use of these primitive elements in a more open sandbox world, where NPC reactions are asynchronously triggered by player cues. An example could be programmable companion pets with unique personalities that follow players and react uniquely to the environment and other characters, leading to complexity in their behavior. This complexity makes the world unpredictable and full of surprises. “Dwarf Fortress” provides an example, where players stumble upon NPC hippos in their self-constructed sewers because their logic dictates that a watery environment is a suitable habitat.
In a world that allows the deployment of hierarchical NPCs and enables them to perform different actions, players can also collaboratively guide branching quest lines in a chain story manner, where interactions between player characters and NPCs drive determination and pursuit of common goals.
Alternative Approaches
Conceptually, alternative approaches can utilize player-written logic to surpass NPC representation and extend its application to certain parts of the world landscape or equippable items. This could be an outpost whose flag and decorations shift from pristine to dilapidated when besieged by guerrillas, or a cyberpunk gadget programmed by players to trigger smoke bombs from their inventory whenever a foe uses ranged weapons.
Although our work attempts to explicitly frame transparency as a generative feature, implementations using zero-knowledge proofs can be leveraged in more competitive environments. Topology’s Shoshin is an example, allowing players to write scripts and submit combat NPCs with private decision trees. Zero-knowledge stacks like EZKL can achieve verifiable off-chain computing tasks, enabling more complex and expressive NPC logic, including AI/ML model integrations.
Both alternative approaches have drawbacks that make chain-story interactivity less intuitive. Particularly, EZKL, relying on a proof backend, technically reduces the autonomy of world mechanisms. Nonetheless, we find these alternative approaches intriguing as they allow worlds to incorporate exploration into gameplay, provide a better contributor experience, and potentially enhance resistance to bots.
Expansion
Currently, players initiating the “Duck Duck Destruction” game competition are responsible for covering network fees generated by all registered NPC contracts. This could be improved by allowing players to pool resources through a dedicated fund contract or a gas subsidy model with a payer extension.
Acknowledgments
Contract design and engineering by Norswap. Visual assets package by Tea Strazicic, SFX by Orion Ohana, released under CC BY 4.0.