import { D20, roll } from '@randsum/dice'
// Simple d20 roll
D20.roll() // Returns 1-20
// Complex dice notation
roll('4d6L') // Roll 4d6, drop lowest
// D&D 5e character ability score generation
const abilityScores = Array.from({ length: 6 }, () => roll('4d6L').sum)
// Advantage and disadvantage
roll('2d20H') // Roll with advantage (2d20, keep highest)
roll('2d20L') // Roll with disadvantage (2d20, keep lowest)
Or directly from your terminal:
npx randsum 2d20 # Roll two twenty-sided dice
npx randsum 4d6L # Character stat roll (drop lowest)
npx randsum 2d20H # Roll with advantage
This monorepo contains the following packages and applications:
A Flexible, Type-safe, and Tree-shakeable dice rolling implementation. Where it all started. Optimized for minimal bundle size.
npm install @randsum/dice
Dice notation parser and validator, for parsing Randsum Dice Notation.
npm install @randsum/notation
A dice roller compatible with 5th Edition RPG Systems
npm install @randsum/5e
A dice roller for the Root RPG system.
npm install @randsum/root-rpg
A dice roller for Blades in the dark (and forged in the dark) RPG systems.
npm install @randsum/blades
A dice roller for the Salvage Union RPG system. Contains all official Salvage Union roll tables, and a contextual roll function for determining success.
npm install @randsum/salvageunion
Internal package containing shared utilities and types. Not intended for direct usage. All types are exported in each subsequent package for ease of use.
This is a monorepo powered by Moon and Bun. To get started:
# Clone the repository
git clone https://github.com/RANDSUM/randsum.git
cd randsum
# Install dependencies for all packages
bun install
# Build all packages
bun moon :build
# Run tests
bun moon :test
# Run type checks
bun moon :tsCheck
# Lint and format
bun moon :lint
bun moon :format
Moon manages our task pipeline and dependencies. Common tasks include:
:build
- Build all packages:test
- Run all tests:lint
- Run ESLint checks:format
- Run Prettier checks:tsCheck
- Run TypeScript checks:publish
- Publish packages (CI only):lint:fix
- Run ESLint and fix issues:format:fix
- Run Prettier and fix formatting issues:ci
- Run all checks (build, test, lint, format, tsCheck)
Each package can be targeted directly with moon [package]:task
, for example:
bun moon dice:test # Run tests for @randsum/dice only
bun moon blades:build # Build @randsum/blades only
-
747E
-
Getting Started - Installation and Documentation for using
randsum
-
Randsum Dice Notation - A guide for using Dice Notation with
randsum
. -
Sophie's Dice Notation - a great dice notation guide that helped me along the way
-
_why's poignant guide to ruby - _why not?
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to your branch
- Open a Pull Request
Please read our Contributing Guidelines for more details.
Sometime around 2012, I decided I wanted to learn to program. I had installed ruby on the best laptop six-hundred dollars could buy, set to make a dice roller as an easy first project.
I spent an easy 30 minutes trying to figure out how to make rand(n)
return 1...n
instead of 0...(n-1)
.
When I found the answer, I laughed and laughed. I've been chasing that high ever since.
I love this thing we call programming. It seems as if (biiiiig scare quotes) "AI" is going to be a part of it moving forward. You will find the extent of my comfort with these tools in this project, for it is the closest thing I have on this earth to a life's work, and programming is my craft. I care deeply about it, and there is no better way for me to understand LLM's and their place in my craft than to use them. There is no better place for me to use and understand them than here. We'll have to see the extent to which I come to regret/resent/respect this decision in the coming years together!