dice-roll-audit
Audit WorldArchitect.AI dice rolls for fairness and anomalies; use when analyzing campaign dice data.
What this skill does
# Dice Roll Audit - Campaign Analysis
## Overview
This skill documents how to audit dice rolls from WorldArchitect.AI campaigns. Use this to analyze dice roll fairness, detect anomalies, and validate game mechanics.
## Quick Start
### Audit a Campaign by ID
```bash
WORLDAI_DEV_MODE=true python scripts/audit_dice_rolls.py <campaign_id>
```
### Example
```bash
# Audit campaign from URL: https://mvp-site-app-dev-i6xf2p72ka-uc.a.run.app/game/tAE30bFvyfO0rUd9cgyv
WORLDAI_DEV_MODE=true python scripts/audit_dice_rolls.py tAE30bFvyfO0rUd9cgyv
```
## What It Analyzes
### Dice Distribution
- Total rolls by die type (d4, d6, d8, d10, d12, d20, d100)
- Mean vs expected mean (fairness check)
- Standard deviation
- Distribution of roll values
### Anomaly Detection
- **Impossible values**: Rolls outside valid range (e.g., 0 or 21+ on d20)
- **Suspicious patterns**: Unusual clustering at high/low ends
- **Statistical deviation**: Significant variance from expected distribution
### Data Sources
The script extracts dice from:
1. **structured_fields**: Dice logged in tool calls and combat data
2. **text_pattern**: Dice mentioned in narrative text (e.g., "rolled a 15")
### Evidence Precedence & Parsing Rules
- **Primary sources**: `dice_audit_events` and `debug_info.tool_results` (authoritative).
- **Fallback**: `debug_info.stdout` JSON from Gemini code_execution (used only when no primary sources exist).
- **Legacy**: `dice_rolls` strings and narrative text patterns (only when structured sources are missing).
- **Distribution math**:
- Uses **individual_rolls** when available (e.g., `[3, 5]` for `2d6`).
- Falls back to parsed totals only when raw rolls are unavailable.
- Totals with modifiers can distort fairness checks, so prefer roll arrays when present.
## Output Example
```
============================================================
CAMPAIGN DICE ROLL AUDIT
============================================================
Campaign ID: tAE30bFvyfO0rUd9cgyv
Campaign Title: alexiel swtor
User ID: vnLp2G3m21PJL6kxcuAqmWSOtm73
============================================================
Total story entries: 498
Entries with dice rolls: 66
Total dice rolls found: 93
--- d20 Analysis ---
Total rolls: 89
Range: 0 - 23
Mean: 7.73 (expected: 10.50)
Deviation: -2.77
Std Dev: 5.41
Distribution: {0: 2, 1: 2, 2: 10, 3: 9, ...}
WARNINGS:
- Impossible values detected: [0, 21, 22, 23]
```
## How to Get Campaign ID
From a game URL like:
```
https://mvp-site-app-dev-i6xf2p72ka-uc.a.run.app/game/tAE30bFvyfO0rUd9cgyv
```
The campaign ID is the last segment: `tAE30bFvyfO0rUd9cgyv`
## Prerequisites
### Environment Variables
```bash
export WORLDAI_DEV_MODE=true
export WORLDAI_GOOGLE_APPLICATION_CREDENTIALS=~/serviceAccountKey.json
```
### Service Account Key
Location: `~/serviceAccountKey.json`
Project: `worldarchitecture-ai`
## Understanding Results
### Expected Means by Die Type
| Die | Expected Mean |
|------|---------------|
| d4 | 2.5 |
| d6 | 3.5 |
| d8 | 4.5 |
| d10 | 5.5 |
| d12 | 6.5 |
| d20 | 10.5 |
| d100 | 50.5 |
### Warning Indicators
- **Impossible values**: Indicates parsing issues or modifier inclusion in totals
- **High deviation (>2)**: May indicate unfair RNG or data extraction issues
- **All text_pattern source**: No structured dice logging - may need improvement
### Chi-Squared Authenticity Check
The audit now includes chi-squared testing for dice authenticity:
| Chi-Squared | Verdict |
|-------------|---------|
| < 30 | PASS - Normal random variation |
| 30-50 | WARNING - Minor anomaly |
| 50-100 | FAIL - Significant deviation |
| > 100 | FAIL - Likely fabrication |
**Reference case**: PR #2551 detected fabrication with chi-squared = 411.81
See `dice-authenticity-standards.md` for full chi-squared methodology and RNG verification standards.
## Troubleshooting
### Clock Skew Error
```
ValueError: WORLDAI_GOOGLE_APPLICATION_CREDENTIALS requires WORLDAI_DEV_MODE=true
```
**Solution:** Set `WORLDAI_DEV_MODE=true` before running
### No Dice Found
If "No dice rolls found", possible causes:
1. Campaign doesn't use D&D 5e mechanics
2. Dice rolls not stored in structured_fields
3. Narrative text doesn't contain dice notation
### Invalid JWT Error
The script automatically applies clock skew patch. If still failing, check:
- Service account key validity
- System clock accuracy
## GCP Cloud Logging
All dice rolls executed via the tool system are now logged to GCP Cloud Logging with the prefix `DICE_AUDIT:` and `DICE_TOOL_RESULT:`.
### Log Format Examples
```
DICE_AUDIT: notation=1d20+5 | rolls=[15] | modifier=5 | total=20 | nat20=False | nat1=False
DICE_TOOL_EXEC: tool=roll_attack | args={'attack_modifier': 5, 'target_ac': 15}
DICE_TOOL_RESULT: tool=roll_attack | weapon=Longsword | rolls=[12] | total=17 | hit=True | critical=False | damage=8
```
### Searching GCP Logs
```bash
# Find all dice rolls in last hour
gcloud logging read "textPayload:DICE_AUDIT" --limit=100 --freshness=1h
# Find all dice tool executions
gcloud logging read "textPayload:DICE_TOOL_EXEC" --limit=50
```
## Script Location
`scripts/audit_dice_rolls.py`
## Related Skills
- `dice-authenticity-standards.md` - Chi-squared testing and RNG verification
- `dice-real-mode-tests.md` - MCP real-mode testing
- `firebase-prod-campaigns.md` - Querying campaign data
- `worldai-mcp-server-usage.md` - MCP server interaction
Related in Ads & Marketing
ads
IncludedMulti-platform paid advertising audit and optimization skill. Analyzes Google, Meta, YouTube, LinkedIn, TikTok, Microsoft, and Apple Ads. 250+ checks with scoring, parallel agents, industry templates, and AI creative generation.
banana
IncludedAI image generation Creative Director powered by Google Gemini Nano Banana models. Use this skill for ANY request involving image creation, editing, visual asset production, or creative direction. Triggers on: generate an image, create a photo, edit this picture, design a logo, make a banner, visual for my anything, and all /banana commands. Handles text-to-image, image editing, multi-turn creative sessions, batch workflows, and brand presets.
rpg-migration-analyzer
IncludedAnalyzes legacy RPG (Report Program Generator) programs from AS/400 and IBM i systems for migration to modern Java applications. Extracts business logic from RPG III/IV/ILE source code, identifies data structures (D-specs), file operations (F-specs), program dependencies (CALLB/CALLP), and converts RPG constructs to Java equivalents. Generates migration reports, complexity estimates, and Java implementation strategies with POJO classes, JPA entities, and service methods. Use when modernizing AS/400 or IBM i legacy systems, analyzing RPG source files (.rpg, .rpgle, .RPGLE), converting RPG to Java, mapping data specifications to Java classes, planning legacy system migration, or when user mentions RPG analysis, Report Program Generator, RPG III/IV/ILE, AS/400 modernization, IBM i migration, packed decimal conversion, or mainframe application rewrite.
brand-library-architect
IncludedBuild a complete brand library for a product — visual asset render pipeline, brand documentation set (BRAND, COPY, MANIFESTO, BIOS, FAQ, GLOSSARY, TONE, PRICING), open-source convention files (README, CONTRIBUTING, SECURITY, CODE_OF_CONDUCT), and a self-contained press kit. This skill should be used when the user asks to "build a brand library / brand kit / press kit / brand assets" for a product, "set up a brand library workflow," "create a positioning manifesto plus visual identity," or any combination of brand documentation + visual asset pipeline. Apply phase-by-phase or run end-to-end. Templates are product-agnostic and use {{TOKEN}} placeholders the skill prompts the user to fill.
writing-tech-post
IncludedAuthors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
blog-google
IncludedGoogle API integration for blog performance: PageSpeed Insights, CrUX Core Web Vitals with 25-week history, Search Console performance, URL Inspection, Indexing API, GA4 organic traffic, NLP entity analysis for E-E-A-T, YouTube video search for embedding, and Google Ads Keyword Planner. Progressive feature availability based on credential tier (API key, OAuth/service account, GA4, Ads). Shares config with claude-seo at ~/.config/claude-seo/google-api.json. Use when user says "google data", "page speed", "core web vitals", "search console", "indexation", "GA4", "keyword research", "nlp entities", "blog performance", "youtube search", "google api setup".