Numo: Crafting the Perfect Recipe for On-Chain Games with MUD and AI
Magic happens when DSL meets MUD and AI
What Is Numo?
Numo is an AI-native Domain-Specific Language (DSL) designed to enhance the MUD development framework. With Numo, developers can describe their game concepts in a simple YAML file, which then generates the underlying code, streamlining the development process for on-chain games.
Numo helps developers create robust game mechanics with less code, shifting the focus from repetitive boilerplate to creative game design. By combining Numo's high-level abstraction with MUD's powerful framework, developers can take a model-driven, low-code approach that significantly speeds up development and improves software quality. Whether you're building on-chain MMORPGs, player-driven economies, or strategic gameplay elements, Numo simplifies the coding process, allowing you to concentrate on game design.
While we focus on on-chain game examples due to their complexity and ability to showcase our tools, Numo is versatile and can be used to build any type of decentralized application (dApp), not just on-chain games.
Why Use Numo?
Numo is not a replacement for MUD but a powerful enhancement. Here’s why it stands out:
Write Less, Achieve More: Using Numo, developers can write a single YAML file to generate initial code for business logic, data models, and CRUD operations, reducing hundreds of lines of work to just a few.
Built for AI Collaboration: Numo provides a structured foundation that, when combined with AI tools, enables consistent, well-structured code generation. AI can focus on refining complex logic, rather than building architecture from scratch.
Efficient Integration with MUD: Numo abstracts and enhances on-chain game frameworks like MUD, which handle low-level, on-chain data storage and sync. By abstracting MUD, Numo allows developers to work at a higher level of domain modeling and design, while MUD takes care of the underlying on-chain mechanics. This approach provides flexibility and efficiency in development.
Low-Code Solutions for On-Chain Game Creators
Game development requires comprehensive planning, and Numo helps bridge the gap between concept and implementation by translating high-level game design into fully functional on-chain code. It employs Domain-Driven Design (DDD) principles to facilitate this process:
Expressive DSL: Numo lets developers describe game entities, relationships, and behaviors in a format that is both human-readable and machine-processable, speeding up development.
Simplified Business Logic Implementation: Numo manages simple CRUD tasks automatically, with no extra coding required. For more complex logic, developers can add custom smart contract code using AI tools like Cursor.
Case Studies: Realizing Numo's Potential
Case Study 1: Less Code, More Output
Objective: Demonstrate how minimal DSL code can generate extensive functionality.
Approach:
Wrote a concise Numo DSL script defining a simple application—a blog with articles and comments.
Created a domain model file with less than 40 lines of code. You can view it [here](https://github.com/wubuku/Dapp-LCDP-Demo/blob/main/docs/IntroToDDDMLforMudDevelopers.md#blog-example).
Used Numo to automatically generate multiple files, including business models and CRUD logic in Solidity and TypeScript.
Outcome:
The generated source code files included at least:
ArticleAddCommentLogic.sol
ArticleAddTagLogic.sol
ArticleAggregate.sol
ArticleCreateLogic.sol
ArticleDeleteLogic.sol
ArticleEvents.sol
ArticleRemoveCommentLogic.sol
ArticleSystem.sol
ArticleTagLib.sol
ArticleUpdateCommentLogic.sol
ArticleUpdateLogic.sol
These files contained more than **500 lines of code** (excluding blank lines), showcasing how Numo can produce extensive functionality from a minimal input.
The lines of code were counted using the command:
find . -name "Article*.sol" -type f | xargs cat | grep -v '^\s*$' | wc -l
Developers gained efficiency by writing significantly less code while maintaining a high-level understanding of the game's core components.
Case Study 2: DSL + AI vs. AI Alone
Objective: Show the advantages of combining Numo with AI compared to using AI alone to build multi-file apps.
Approach:
1. Using AI Alone:
Step 1: Created a new MUD project using the vanilla template and started the development server.
pnpm create mud@latest CaseStudy-Numo-plus-AI-vs-AI-Alone
pnpm dev
Step 2: Modified the `
mud.config.ts
` file to define the data model for the game, including tables like `SkillProcess`, `SkillPrcMtrlCount`
, and `SkillPrcMtrl
`.Step 3: Attempted to generate the
`SkillProcessSystem.sol`
file using AI, with the following prompt:
"You are a senior Solidity developer. You are developing an on-chain game based on the MUD framework. In this game, players can participate in various skill-based activities like farming, woodcutting, mining, and crafting. However, the number of concurrent production processes is limited. For instance, a player can manage up to two farming processes, one woodcutting process, one mining process, and one crafting process simultaneously. The SkillProcess entity is designed to manage these activities. Please read `
mud.config.ts
` and `SkillProcess.sol` then write a `createSkillProcess` function that creates a new and unstarted process."
Result: The AI-generated code failed to compile due to errors such as incorrect argument counts for struct constructors. The implementation of the business logic was also incorrect, importing unrelated tables and using them improperly.
2. Using Numo + AI:
Applied Numo to define the application's structure and generate a well-structured skeleton code.
The Numo-generated code served as a blueprint for the AI to complete the business logic.
Prompted the AI to fill in the specific logic within the Numo-generated framework.
The AI generated compilable and logically correct code on the first try.
Outcome:
AI Alone:
Produced disorganized, error-prone code that failed to compile and required significant manual correction.
The AI incorrectly used unrelated components like `Counter` without proper context.
Lacked structural guidance, leading to logical errors and inefficient development.
Example errors included:
Error: Wrong argument count for struct constructor: 10 arguments given but expected 7.
Numo + AI:
Created a coherent, functional codebase with minimal errors.
The AI effectively filled in the business logic within the Numo-generated structure.
Resulted in a more efficient development cycle, demonstrating the synergy between Numo and AI tools.
The full experiment and code can be found in this repository.
This case study highlights the importance of a structured foundation provided by Numo, which significantly enhances the effectiveness of AI in code generation.
Quick Start with Numo: From Model to Code
To understand the power of Numo, let’s dive into a couple of quick examples:
Hello World
Create a `numo`
directory in your project root, then add a `Counter.yaml`
file:
singletonObjects:
Counter:
properties:
Value:
type: u32 # Maps to Solidity's "uint32".
methods:
Increase:
shouldCreateOnDemand: true
result:
isObjectReturned: true
event:
name: CounterIncreased
properties:
OldValue:
type: u32
Using Docker, execute the command to generate the required scaffolding, and watch as Numo converts this into multiple files, ready for implementation.
Blog Example
Create a `blog.yaml`
file to scaffold a simple blog application with articles and comments:
aggregates:
Article:
metadata:
Preprocessors: ["CRUD_IT"]
id:
name: Id
type: u64
generator:
class: sequence
properties:
Author:
type: address
Title:
type: String
Body:
type: String
Comments:
itemType: Comment
entities:
Comment:
metadata:
Preprocessors: [ "CRUD_IT" ]
id:
name: CommentSeqId
type: u64
generator:
class: sequence
properties:
Commenter:
type: String
Body:
type: String
This simple YAML file allows Numo to generate all CRUD operations and data models for a blog, significantly reducing the amount of manual coding required.
Conclusion
Numo simplifies on-chain game development by reducing the amount of code developers need to write. By combining high-level abstraction, AI integration, and a low-code approach, Numo builds on the foundation of MUD to streamline the development process for on-chain game devs.
Whether you are developing intricate game mechanics or prototyping a new concept, Numo helps you focus on what truly matters—the game experience—while taking care of most of the design part of the code.
Ready to simplify your on-chain game development? Start your journey with Numo today.
Further Reading
For an in-depth exploration of Numo's data types and additional advanced examples like the Infinite Seas case study, check out our follow-up article here. This follow-up will provide more comprehensive details on leveraging Numo's capabilities for complex on-chain game mechanics, offering valuable insights into real-world applications and deeper technical implementation.
Join Discussion at https://discord.gg/yMG9z8ANnM 🏠
such an awesome read!