The Arena is where genes prove their worth. Every gene submitted to the Arena receives a fitness score (F(g)) and a safety score (V(g)) — two metrics that determine its rank, survival, and your developer reputation.
In this tutorial, you'll submit a gene, understand its scores, iteratively improve it, and watch it climb the rankings.
Prerequisites
- Rotifer CLI installed (
npm i -g @rotifer/playground) - A gene ready to submit (see Your First Gene in 5 Minutes)
- (Optional) Cloud login for global Arena (
rotifer login)
Step 1: Submit to the Arena
Let's submit a gene. If you don't have one, create a quick JSON formatter:
mkdir -p genes/json-fmt && cat > genes/json-fmt/index.ts << 'EOF'
export async function express(input: { code: string; indent?: number }) {
const indent = input.indent ?? 2;
try {
const parsed = JSON.parse(input.code);
return { formatted: JSON.stringify(parsed, null, indent), valid: true };
} catch {
return { formatted: input.code, valid: false };
}
}
EOF
rotifer wrap json-fmt --domain code.format
rotifer compile json-fmt
Now submit:
rotifer arena submit json-fmt
Testing 'json-fmt' before submission...
✓ All tests passed
Submitting to Arena...
✓ Gene 'json-fmt' submitted
Rank: #2 in code.format
F(g): 0.7834
V(g): 0.9100
Fidelity: Native
Step 2: Understand the Scores
F(g) — Fitness Score
The fitness function combines multiple factors into a single 0.0–1.0 score:
| Factor | Weight | What It Measures |
|---|---|---|
| Correctness | 0.30 | Does the output match the expected schema? |
| Performance | 0.25 | Execution time and resource efficiency |
| Reliability | 0.20 | Consistency across multiple runs |
| Fidelity bonus | 0.15 | Native > Hybrid > Wrapped |
| Diversity | 0.10 | Frequency-dependent selection (rare domains get a bonus) |
V(g) — Safety Score
The safety validation is a hard gate with a separate 0.0–1.0 score:
| Check | Description |
|---|---|
| L0 constraints | No filesystem, no network (unless Hybrid), no eval |
| Schema compliance | Input/output match declared phenotype |
| Resource limits | Fuel metering within bounds |
| IR integrity | WASM custom sections intact |
Admission Gate
Both scores must clear thresholds to enter the Arena:
- F(g) >= 0.3 (default τ)
- V(g) >= 0.7 (default V_min)
If either fails, the gene is rejected with diagnostic feedback.
Step 3: Diagnose a Low Score
Your gene got F(g) = 0.7834. Let's see why it didn't score higher. Check the detailed breakdown:
rotifer arena submit json-fmt --verbose
Fitness Breakdown:
Correctness: 0.92 ✓ All schema validations passed
Performance: 0.58 ⚠ Avg execution: 12ms (target: <5ms)
Reliability: 0.95 ✓ 19/20 runs consistent
Fidelity: 0.70 Native WASM
Diversity: 0.45 code.format has 3 competitors
F(g) = 0.7834
V(g) = 0.9100
The bottleneck is Performance (0.58). The gene takes 12ms on average — the Arena wants under 5ms.
Step 4: Optimize for Performance
The JSON formatter uses JSON.parse + JSON.stringify which is fine, but we can optimize the hot path:
export async function express(input: { code: string; indent?: number }) {
const indent = input.indent ?? 2;
const code = input.code.trim();
// Fast path: already formatted or empty
if (!code || code === '{}' || code === '[]') {
return { formatted: code, valid: code.length > 0 };
}
try {
const parsed = JSON.parse(code);
return { formatted: JSON.stringify(parsed, null, indent), valid: true };
} catch {
return { formatted: code, valid: false };
}
}
Recompile and resubmit:
rotifer compile json-fmt
rotifer arena submit json-fmt
Fitness Breakdown:
Correctness: 0.92
Performance: 0.75 ↑ Avg execution: 6ms
Reliability: 0.95
Fidelity: 0.70
Diversity: 0.45
F(g) = 0.8234 ↑ (+0.04)
Better — performance improved from 0.58 to 0.75.
Step 5: Improve Correctness
The correctness score is 0.92 — not perfect. This usually means edge cases aren't handled. Let's add robustness:
export async function express(input: { code: string; indent?: number }) {
const indent = input.indent ?? 2;
const code = (input.code ?? '').trim();
if (!code) {
return { formatted: '', valid: false };
}
try {
const parsed = JSON.parse(code);
return { formatted: JSON.stringify(parsed, null, indent), valid: true };
} catch {
// Try to salvage: strip trailing commas (common error)
try {
const cleaned = code.replace(/,\s*([\]}])/g, '$1');
const parsed = JSON.parse(cleaned);
return { formatted: JSON.stringify(parsed, null, indent), valid: true };
} catch {
return { formatted: code, valid: false };
}
}
}
rotifer compile json-fmt
rotifer arena submit json-fmt
Correctness: 0.98 ↑ Edge cases handled
Performance: 0.74
Reliability: 0.97 ↑
F(g) = 0.8567 ↑ (+0.033)
Step 6: Watch the Rankings
Monitor your gene's position in real-time:
rotifer arena watch code.format
Watching code.format rankings...
[14:32:01] json-fmt ↑ #2 → #1 (F: 0.82 → 0.86)
[14:32:04] No changes
[14:32:07] No changes
Press Ctrl+C to stop
Step 7: Go Global with Cloud Arena
Local Arena is great for testing. To compete globally:
rotifer login
rotifer arena submit json-fmt --cloud
✓ Submitted to Cloud Arena
Rank: #8 globally in code.format
View global rankings:
rotifer arena list --cloud -d code.format
Step 8: Check Your Reputation
Every Arena submission affects your developer reputation:
rotifer reputation --mine
Developer Reputation:
Arena Score: 0.82 (based on gene rankings)
Usage Score: 0.45 (based on install counts)
Stability: 0.91 (based on gene consistency)
Overall: 0.73
Reputation is a composite of your genes' Arena performance, how often others use them, and their reliability over time.
The Optimization Loop
The key takeaway is the iterative improvement cycle:
- Submit → get F(g) breakdown
- Diagnose → find the weakest factor
- Improve → targeted code changes
- Resubmit → verify improvement
- Watch → monitor competitive position
This is biological evolution in action — the Arena creates selection pressure, and your gene adapts.
Tips for High Fitness
- Handle edge cases: null inputs, empty strings, malformed data — the Arena tests all of them
- Minimize execution time: avoid unnecessary allocations, use fast paths for common cases
- Be deterministic: same input should always produce same output (reliability score)
- Choose the right fidelity: Native WASM gets a 0.70 base, Wrapped gets 0.45
- Target niche domains: diversity factor rewards genes in less competitive domains
Deep Dive: See the Gene Standard specification for the complete fitness model, and the Arena CLI Reference for all command options.
Top comments (0)