Fun with Python: A Terminal Dice Roller

@thecrazygm · 2025-08-19 16:00 · Synergy Builders

Hey everyone,

Today I want to share a script for deterministic dice rolls right from the command line. If you know anything about me, you know I live in the terminal. Even though I built the ultimate-dice web app, sometimes I just want to roll some funky click-clack math rocks without leaving my shell. So, I built this.


Deterministic Dice Rolls in the Terminal

This script is a bit different from my web-based dice roller. It uses a method inspired by the old dice.js smart contract from Hive-Engine, seeding its rolls using live data directly from the Hive blockchain to ensure a deterministic and provably fair result.

Here’s how it works:

  1. It fetches the last two blocks from the Hive blockchain.
  2. It creates a unique seed string by combining the block_id of both blocks and the transaction_id of the first transaction in the most recent block.
  3. This seed is then hashed to generate a number that powers the random number generator, ensuring the roll is tied to that exact moment on the blockchain.

The script can handle simple rolls, like a standard 1d20:

dice_1.png

It can also parse more complex dice notation, including multiple types of dice and modifiers, like 1d20+3-2d6+3:

dice_2.png

It's a fun little tool for anyone who loves the command line and wants a quick way to get a provably fair dice roll for a TTRPG or any other reason.

You can find the script and run it directly from the Gist below.

As always, Michael Garcia a.k.a. TheCrazyGM

#dev #rpg #archon #tribes #pimp #proofofbrain
Payout: 0.000 HBD
Votes: 197
More interactions (upvote, reblog, reply) coming soon.