AGENT SKILL

roll-dice

Roll dice using a random number generator. Use when asked to roll a die (d4, d6, d8, d10, d12, d20, d100), roll multiple dice, or generate random dice rolls for tabletop RPGs, board games, or decision making.

License 许可
MIT
最近更新
2026-10-08
Stars
★ 0
Forks
1

01 前言 Front Matter

name
roll-dice
license
MIT
metadata
{ "author": "welcome", "version": "1.0" }
description
Roll dice using a random number generator. Use when asked to roll a die (d4, d6, d8, d10, d12, d20, d100), roll multiple dice, or generate random dice rolls for tabletop RPGs, board games, or decision making.

03 SKILL.md 正文

Roll Dice

When to use this skill

Use this skill when the user needs to:

  • Roll a single die (d6, d20, etc.)
  • Roll multiple dice (2d6, 4d8, etc.)
  • Roll with modifiers (d20+5, 2d6-1)
  • Generate random numbers for games or decisions

Rolling a Single Die

Generate a random number from 1 to the given number of sides:

# Bash (macOS/Linux)
echo $((RANDOM % <sides> + 1))
# PowerShell (Windows)
Get-Random -Minimum 1 -Maximum (<sides> + 1)
# Python (more precise for large numbers)
import random
print(random.randint(1, <sides>))

Replace <sides> with the number of sides on the die (e.g., 6 for a standard die, 20 for a d20).

Common Dice Types

Notation Sides Common Use
d4 4 Small damage rolls
d6 6 Standard die, ability scores
d8 8 Weapon damage
d10 10 Percentile rolls (paired)
d12 12 Greataxe damage
d20 20 Attack rolls, skill checks, saving throws
d100 100 Percentile rolls

Rolling Multiple Dice

For NdX notation (N dice with X sides):

# Roll 3d6 (three six-sided dice)
for i in {1..3}; do echo $((RANDOM % 6 + 1)); done | paste -sd+ | bc
import random

def roll(n, sides, modifier=0):
    rolls = [random.randint(1, sides) for _ in range(n)]
    total = sum(rolls) + modifier
    return {"rolls": rolls, "modifier": modifier, "total": total}

# Examples
print(roll(3, 6))        # 3d6
print(roll(1, 20, 5))    # 1d20+5
print(roll(2, 8, -1))    # 2d8-1

Parsing Dice Notation

When the user provides dice notation like "2d6+3", parse it:

import re
import random

def parse_and_roll(notation: str) -> dict:
    match = re.match(r"(\d+)?d(\d+)([+-]\d+)?", notation.strip().lower())
    if not match:
        return {"error": f"Invalid notation: {notation}. Use format: NdX+M (e.g., 2d6+3)"}
    
    n = int(match.group(1) or 1)
    sides = int(match.group(2))
    modifier = int(match.group(3) or 0)
    
    rolls = [random.randint(1, sides) for _ in range(n)]
    total = sum(rolls) + modifier
    
    result = f"{notation} → {rolls}"
    if modifier:
        result += f" {'+' if modifier > 0 else ''}{modifier}"
    result += f" = {total}"
    
    return {"notation": notation, "rolls": rolls, "modifier": modifier, "total": total, "display": result}

# Usage
print(parse_and_roll("2d6+3"))
print(parse_and_roll("d20"))
print(parse_and_roll("4d8-2"))

Gotchas

  • Bash $RANDOM range: $RANDOM produces 0-32767. For dice this is fine, but for very large ranges use Python's random.randint().
  • Inclusive ranges: Dice rolls are always 1 to N inclusive. random.randint(1, N) is correct; random.randrange(1, N) excludes N.
  • Modifier can be negative: "d20-2" means subtract 2 from the roll. The total can go below 1.
  • Always show individual rolls: When rolling multiple dice, show each die result plus the total — users want to see the breakdown.

Validation

After rolling:

  1. Each individual die result is within 1 to sides (inclusive)
  2. Total equals sum of individual rolls plus modifier
  3. Display shows the full breakdown (individual rolls + modifier = total)

04 同仓库更多 Skills

anjijava16
anjijava16/Agent_Skills

roll-dice

Roll dice using a random number generator. Use when asked to roll a die (d4, d6, d8, d10, d12, d20, d100), roll multiple dice, or generate random dice rolls for tabletop RPGs, board games, or decision making.

★ 0
anjijava16
anjijava16/Agent_Skills

pdf-service

Extract text and tables from PDFs, fill PDF forms, merge and split PDF files, and convert PDFs to other formats. Use when the user mentions PDFs, document extraction, form filling, or needs to manipulate PDF files.

文档处理
★ 0
anjijava16
anjijava16/Agent_Skills

pdf-processing

Extract text, tables, and metadata from PDF documents. Parse scanned PDFs with OCR, analyze PDF structure, and convert PDFs to other formats. Use when the user needs to read, parse, or extract content from PDF files, even if they just say "get the text from this document."

文档处理
★ 0
anjijava16
anjijava16/Agent_Skills

my-skill

A template skill for [describe task]. Use when the user asks to [trigger phrases].

Skill与智能体开发
★ 0
anjijava16
anjijava16/Agent_Skills

data-analysis

Analyze datasets — compute summary statistics, clean messy data, add derived columns, detect outliers, and generate charts. Use when the user has a CSV, TSV, Excel, or JSON data file and wants to explore, transform, visualize, or understand the data, even if they don't explicitly mention "analysis."

数据分析师电子表格分析与可视化
★ 0
anjijava16
anjijava16/Agent_Skills

code-review

Review code for bugs, security vulnerabilities, performance issues, and style problems. Provide actionable feedback with severity levels and fix suggestions. Use when the user asks to review, audit, or check code quality, or wants a second pair of eyes on a pull request, diff, or code change.

开发工程师代码审查
★ 0