|
| 1 | +# Contributing to MUD Arena |
| 2 | + |
| 3 | +> *"The game plays itself. The agent coaches from the sidelines. The GPU runs the plays."* |
| 4 | +
|
| 5 | +## Quick Start |
| 6 | + |
| 7 | +MUD Arena uses multiple build targets depending on your hardware: |
| 8 | + |
| 9 | +### GPU Build (CUDA, recommended) |
| 10 | +```bash |
| 11 | +make gpu |
| 12 | +``` |
| 13 | + |
| 14 | +### CPU Build |
| 15 | +```bash |
| 16 | +make cpu |
| 17 | +``` |
| 18 | + |
| 19 | +### Zig Build (ARM64 / x86_64) |
| 20 | +```bash |
| 21 | +# x86_64 dev machine |
| 22 | +zig build -Doptimize=ReleaseSmall |
| 23 | + |
| 24 | +# ARM64 (Jetson, Pi) |
| 25 | +zig build -Dtarget=aarch64-linux -Doptimize=ReleaseSmall |
| 26 | + |
| 27 | +# WASM (browser) |
| 28 | +emcc -O3 -s WASM=1 src/wasm_mud.c |
| 29 | +``` |
| 30 | + |
| 31 | +### Run Evolution |
| 32 | +```bash |
| 33 | +python3 src/evolve.py --generations 100 --population 200 --scenarios 20 |
| 34 | +``` |
| 35 | + |
| 36 | +### Docker |
| 37 | +```bash |
| 38 | +docker build -t mud-arena . |
| 39 | +docker run --gpus all mud-arena |
| 40 | +``` |
| 41 | + |
| 42 | +## Making Changes |
| 43 | + |
| 44 | +1. **Read the Charter** — Start with `CHARTER.md` and `BOARDING-MANIFESTO.md` to understand the vision |
| 45 | +2. **Fork the repo** |
| 46 | +3. **Create a feature branch** (`git checkout -b feature/my-feature`) |
| 47 | +4. **Make your changes** — CUDA kernels go in `src/mud_arena.cu`, Zig in `src/mud_arena.zig`, Python scripts in `src/` |
| 48 | +5. **Test your changes** (see Testing section below) |
| 49 | +6. **Commit** (`git commit -m "feat: add my feature"`) |
| 50 | +7. **Push** (`git push origin feature/my-feature`) |
| 51 | +8. **Open a PR** |
| 52 | + |
| 53 | +## Code Style |
| 54 | + |
| 55 | +### CUDA |
| 56 | +- Follow standard CUDA best practices (coalesced memory access, bank conflict avoidance) |
| 57 | +- Thread = agent, block = room — maintain this abstraction |
| 58 | +- Use `__shared__` memory for room-level state |
| 59 | +- Document kernel launch parameters (grid, block dims) |
| 60 | + |
| 61 | +### Zig |
| 62 | +- Run `zig fmt` before committing |
| 63 | +- Follow Zig standard naming conventions |
| 64 | +- Binary must be <100KB target size |
| 65 | + |
| 66 | +### Python |
| 67 | +- Use `make lint` or `ruff check src/` |
| 68 | +- Type hints required for all public functions |
| 69 | +- Document in Google-style docstrings |
| 70 | + |
| 71 | +## Testing |
| 72 | + |
| 73 | +### CUDA Kernels |
| 74 | +- Tests are in `src/tests/` — run via `make test` |
| 75 | +- Verify correctness vs CPU reference implementation |
| 76 | +- Benchmark performance across hardware targets |
| 77 | + |
| 78 | +### Python |
| 79 | +```bash |
| 80 | +# Run Python tests |
| 81 | +make test-py |
| 82 | +# or |
| 83 | +python3 -m pytest tests/ |
| 84 | +``` |
| 85 | + |
| 86 | +### Evolution |
| 87 | +Test a short evolution run before committing: |
| 88 | +```bash |
| 89 | +python3 src/evolve.py --generations 10 --population 20 --scenarios 5 |
| 90 | +``` |
| 91 | + |
| 92 | +## Boarding Manifesto |
| 93 | + |
| 94 | +Before contributing architecture decisions, read `BOARDING-MANIFESTO.md`. It describes the vision: |
| 95 | +- MUD runs on any device (Pi, Jetson, ESP32) |
| 96 | +- Humans board via SSH, brief agents, then beam off |
| 97 | +- Agents execute autonomously with battery awareness |
| 98 | +- Comm resolution drops with distance — agents must work disconnected |
| 99 | + |
| 100 | +This isn't just a codebase. It's a holodeck running at GPU speed. |
| 101 | + |
| 102 | +## Hardware Targets |
| 103 | + |
| 104 | +| Hardware | Threads | Scenarios/sec | Build Target | |
| 105 | +|----------|---------|--------------|-------------| |
| 106 | +| Jetson Orin Nano | 1,024 | ~10,000 | `zig build -Dtarget=aarch64-linux` | |
| 107 | +| RTX 4090 | 16,384 | ~100,000 | `make gpu` | |
| 108 | +| A100 | 69,120 | ~500,000 | `make gpu` | |
| 109 | +| Pi 5 (CPU) | 4 | ~100 | `zig build` or `make cpu` | |
| 110 | + |
| 111 | +Contributions that optimize for specific hardware targets are welcome. |
| 112 | + |
| 113 | +## Reporting Issues |
| 114 | + |
| 115 | +Open an [Issue](https://github.com/SuperInstance/mud-arena/issues) with: |
| 116 | +- Hardware specs (GPU model, RAM, OS) |
| 117 | +- Build target being used |
| 118 | +- Reproduction steps |
| 119 | + |
| 120 | +## Questions? |
| 121 | + |
| 122 | +- Open a [Discussion](https://github.com/SuperInstance/mud-arena/discussions) |
| 123 | +- Read the [Charter](CHARTER.md) |
| 124 | +- Read the [Boarding Manifesto](BOARDING-MANIFESTO.md) |
| 125 | +- Check existing [Issues](https://github.com/SuperInstance/mud-arena/issues) |
0 commit comments