Archon is a ai generated prototype of a simulation engine for complex rules systems, such as Dungeons & Dragons (DnD). It allows you to define, simulate, and automate game mechanics, making it easy to experiment with custom rules or build automated agents.
It was generated by describing a rules engine to an llm and then asking it to implement various rules from DND game. Some guidance was given when implementing more complex rules like the sheild spell for example - I first asked it to allow reactions, create an agent that could make decissions and then told it how the sheild spell worked.
The primary reason I was interested in using a rules engine architecture is that it does a really good job of isolating the code for a given feature in a single location. Eg in a unstructured impertive codebase to add the power attack feat you might have to go and update all instances the attack action with logic for power attacking.
DND has lots of rules like this that modify the basic functioning of the game making an unstructured imperitive implementation hard for both humans an llms to understand or modify. Rules engines by contrast are inherently composable, making it easy to add or remove features.
Having now created an extensible template for the llm to follow I think it should be possible to try having a llm read through the players handbook to generate new prompts that extend archon to cover the entirety of the rule set.
- Rules: Define the game. Each rule is one or more conditionally applied effects.
- Conditions: Determine when a rule is applied.
- Effects: Determine how game state or computed properties change.
- Actions: Means by which agents interact with game state.
- Agents: Automated systems or human players that take actions.
- State: A set of facts about entities relevant to the game.
Clone the repository:
git clone https://github.com/yourusername/archon.git
cd archon
bun installHere's a simple "hello world" scenario:
bun index.ts
player attacks goblin
player rolls d20+3=18
18 exceeds the goblins AC
player deals 1d8+2=10 to goblin
goblin takes 10 damage and dies.player here can be controlled by human or an automated agent.