P5-games-dice

Jul 20, 2023

Perl module to simulate die rolls

GamesDice simulates die rolls. It uses a function-oriented not object-oriented interface. No functions are exported by default. At present, there are two functions which are exportable roll and roll_array. The latter is used internally by roll, but can also be exported by itself.

The number and type of dice to roll is given in a style which should be familiar to players of popular role-playing games adb[+-/b]c. a is optional and defaults to 1; it gives the number of dice to roll. b indicates the number of sides to each die; the most common, cube-shaped die is thus a d6. can be used instead of 100 for b; hence, rolling 2d and 2d100 is equivalent. If F is used for b fudge dice are used, which either results in -1, 0 or 1. roll simulates a rolls of b-sided dice and adds together the results. The optional end, consisting of one of +-/b and a number c, can modify the sum of the individual dice. +-/ are similar in that they take the sum of the rolls and add or subtract c, or multiply or divide the sum by c. x can also be used instead of *. Hence, 1d6+2 gives a number in the range 3..8, and 2d410 gives a number in the range 20..80. Using / truncates the result to an int after dividing. Using b in this slot is a little different it’s short for “best” and indicates “roll a number of dice, but add together only the best few”. For example, 5d6b3 rolls five six- sided dice and adds together the three best rolls. This is sometimes used, for example, in role-playing to give higher averages.



Checkout these related ports:
  • Ztrack - Simple ncurses based pseudo-3D driving game
  • Zoom - Z-Interpreter for X with full V6 support
  • Zhlt - Zoner's Half-Life compile tools
  • Zephulor - Side scrolling arcade game
  • Zdoom - Source port for Doom-engine games
  • Zaz - Puzzle game where the player has to arrange balls in triplets
  • Zatacka - Nibbles-like multiplayer game
  • Zangband - Zangband (Zelazny Angband) with color, X11 support
  • Yquake2 - Improved version of Icculus Quake II
  • Yahtzee - Curses version of the dice game for one or more players
  • Yadex - WAD file editor, for games like Doom and Heretic
  • Xzip - Infocom game interpreter that runs under X11
  • Xye - Puzzle games like sokoban or boulderdash
  • Xworm - Classic game with apples and hungry worm
  • Xvmines - Simple minesweeper game for X Window System