Beginners – A dice roller in C.

I am learning C and have implemented a role dicer for learning purposes.

It uses arc4random (3) to generate random numbers since I couldn't find anything better.

It works both interactively if no argument is given when it reads a cube string from stdin, one per line (I used getline (3) for that); and reading the cube sequence from arguments.
A dice chain is a dice specification that is similar to those used in most role-playing games, e.g. rolldice 3d6 roll 3 6 dice and combine them, and rolldice 4d8+2s1 Rolls 4 dice of size 8, rolls a roll, sums the rolls and adds 2 to the result. Further information can be found in the manual.

I wrote a manual page for it, the manual page is based on the manual of Stevie Strickland's rolling dice, but the code that I wrote from scratch.

Here is the manual:

rolldice(6)                     Games Manual                    rolldice(6)

       rolldice - rolls virtual dice

       rolldice (-s) (dice string...)

       rolldice rolls virtual dice.  The dice strings passed on the command
       line contain information on the dice to roll in a format  comparable
       to the format used in most role playing games.

       If  no dice strings are provided as command line arguments, rolldice
       uses stdin as input and runs interactivelly.

       The options are as follows:

       -s     Print out the result of each individual  die  separately,  as
              well as the operations and totals.

       The  dice  string  uses  the  exact format outlined below.  Optional
       parts are between square brackets.  A # must be replaced by  a  num‐


       (#x)   How many times to roll.  If ommited, defaults to 1 roll.

              Main part of the dice string.  The first number is the number
              of dice to roll in each roll, if ommited, roll just one  die.
              The  second  number  is the number of sides the dice have, if
              ommited, roll 6-sided die.  The second number can be replaced
              by  a  percent  sign,  implying a 100-sided die.  The numbers
              rolled on each die are then added up and given as the result.

       (*#)   How many times to multiply the result of each roll.

              Number to be added or subtracted, depending on the sign, from
              each roll.  This step is handled after the multiplication.

       (s#)   How many lowest dice rolls to drop.  This step is handled be‐
              fore the multiplication.

       0      Success.

       >0     Error occurred.

       Roll three six-sided dice and sum the results:

              rolldice 3d

       Roll four eight-sided dice and sum the results,  them  multiply  the
       result by 2 and add 2 to it:

              rolldice 4d8*2+2

       Roll four six-sided dice, drop the lowest result and add the remain‐
       ing results. Do this three times:

              rolldice 3x4d6s1

       This version of rolldice was written as an exercise  for  practicing

       The idea for getnumber()  was  from  an  anon  from  /g/'s  dpt.   I
       could've used strtol(3) but, as I said, I did it for practicing.


Here is the code:


#define DEFROLLS      1
#define DEFDICE       1
#define DEFFACES      6
#define DEFMODIFIER   0
#define DEFDROP       0

static int separate;

/* structure of a dice string */
struct dice {
    int rolls;
    int dice;
    int faces;
    int multiplier;
    int modifier;
    int drop;

static void rolldice(struct dice);
static struct dice getdice(char *);
static int getnumber(char **);
static void usage(void);

/* roll a virtual dice */
main(int argc, char *argv())
    struct dice *d;
    int c, i, exitval;
    char *line = NULL;
    size_t linesize = 0;
    ssize_t linelen;

    separate = 0;
    while ((c = getopt(argc, argv, "s")) != -1) {
        switch (c) {
        case 's':
            separate = 1;
    argc -= optind;
    argv += optind;

    exitval = EXIT_SUCCESS;
    if (argc == 0) {    /* no arguments, run interactivelly */
        if ((d = reallocarray(NULL, 1, sizeof(*d))) == NULL)
            err(1, NULL);
        while ((linelen = getline(&line, &linesize, stdin)) != -1) {
            *d = getdice(line);
            if (d->rolls == 0) {
                warnx("%s: malformed dice string", line);
                exitval = EXIT_FAILURE;
            } else {
        if (ferror(stdin))
            err(1, "stdin");
    } else {            /* run parsing the arguments */
        if ((d = reallocarray(NULL, argc, sizeof(*d))) == NULL)
            err(1, NULL);
        for (i = 0; i < argc; i++) {
            d(i) = getdice(*argv);
            if ((d(i)).rolls == 0)
                errx(1, "%s: malformed dice string", *argv);
        for (i = 0; i < argc; i++)
    if (ferror(stdout))
        err(1, "stdout");

    return exitval;

/* get a random roll given a dice structure */
static void
rolldice(struct dice d)
    int i, j, min, drop;
    int *roll, rollcount, rollsum;

    if ((roll = reallocarray(NULL, d.dice, sizeof(*roll))) == NULL)
        err(1, NULL);

    rollcount = 1;
    while (d.rolls-- > 0) {
        rollsum = 0;
        if (separate)
            printf("Roll #%d: (", rollcount++);

        /* get random values */
        for (i = 0; i < d.dice; i++) {
            roll(i) = 1 + arc4random() % d.faces;
            rollsum += roll(i);
            if (separate)
                printf("%d%s", roll(i), (i == d.dice-1) ? "" : " ");

        /* drop smallest values */
        drop = d.drop;
        while (drop-- > 0) {
            min = INT_MAX;
            for (i = 0; i < d.dice; i++) {
                if (roll(i) != 0 && min > roll(i)) {
                    min = roll(i);
                    j = i;
            rollsum -= roll(j);
            if (separate)
                printf(" -%d", roll(j));

        /* sum rolls, apply multiplier and modifier */
        rollsum = rollsum * d.multiplier + d.modifier;

        if (separate) {
            if (d.multiplier != 1)
                printf(" * %d", d.multiplier);
            if (d.modifier != 0)
                printf(" %c %u", (d.modifier < 0) ? '-' : '+', abs(d.modifier));
            printf(" = ");

        /* print final roll */
        printf("%d%c", rollsum, (d.rolls == 0 || separate) ? 'n' : ' ');


/* get dice in format (#x)(#)d(#|%)(*#)(+#|-#)(s#), where # is a number */
static struct dice
getdice(char *s)
    struct dice d;
    int n, sign;

    /* set number of rolls */
    if ((n = getnumber(&s)) < 0)
        goto error;
    d.rolls = DEFROLLS;
    if (*s == 'x') {
        d.rolls = (n == 0) ? DEFROLLS : n;
        if (n < 1)
            goto error;
        if ((n = getnumber(&s)) < 0)
            goto error;

    /* set number of dices */
    if (*s != 'd')
        goto error;
    d.dice = (n == 0) ? DEFDICE : n;
    n = 0;

    /* set number of faces */
    if (*s == '%') {
        n = 100;
        if ((n = getnumber(&s)) < 0)
            goto error;
    d.faces = (n == 0) ? DEFFACES : n;
    n = 0;

    /* set multiplier */
    if (*s == '*') {
        if ((n = getnumber(&s)) < 1)
            goto error;
    d.multiplier = (n == 0) ? DEFMULTIPLIER : n;
    n = 0;

    /* set modifier */
    if (*s == '+' || *s == '-') {
        sign = (*s++ == '-') ? -1 : 1;
        if ((n = getnumber(&s)) < 1)
            goto error;
    d.modifier = (n == 0) ? DEFMODIFIER : sign * n;
    n = 0;

    /* set number of drops */
    if (*s == 's') {
        if ((n = getnumber(&s)) < 1)
            goto error;
    d.drop = (n == 0) ? DEFDROP : n;
    if (d.drop >= d.dice)
        goto error;

    if (*s != '' && *s != 'n')
        goto error;

    return d;

    return (struct dice) {0, 0, 0, 0, 0, 0};

/* get number from *s; return -1 in case of overflow, return 0 by default */
static int
getnumber(char **s)
    int n;

    n = 0;
    while (isdigit(**s)) {
        if (n > (INT_MAX - 10) / 10)
            return -1;
            n = n * 10 + **s - '0';
    return n;

static void
    (void) fprintf(stderr, "usage: rolldice (-s) (dice-string...)n");

Is my solution portable? And is it well commented?
I think I rely too much on BSD extensions like err (3) and POSIX extensions like getopt (3). It has to be compiled with -lbsd on Linux. Is it bad?

Is my code comparable to Stevie's? Or is it worse?
Please see Stevie's Cube and compare my code with his.

I think Stevie's Rolldice contains serious typing errors, e.g. B. Accepting strings that do not contain any d how 1d6, for example rolldice foo the same as rolldice 1d6 for Stevie. And its implementation accepts multiple modifiers, but only uses the last one (rolldice 1d6-3+2+1 the same as rolldice 1d6+1). My version doesn't have these errors.

(Note: I had access to Stevie's Rolldice program before I wrote mine, but I didn't see Stevie's code until I finished mine, which I wrote from scratch.)

BBC Code Dice Roller in PHP

I don't program PHP too often. I wanted to write a dice roller BBC code parser for my forum. What do you see that can be improved?

You can see the code live here:


  • Basic Rolls: NdM: Roll N dice with M sides. i.e. 3d20 rolls three twenty sided dice.
  • Add Modifiers: 1d20+1 or 1d20-5: Add (or subtract) the indicated amount from the roll
  • Reroll Low Results: 1d20r3: Roll 1d20, but keep re-rolling if the result is 3 or lower.
  • Keep Highest Rolls: 4d6^3: Roll 4d6, but keep only the 3 highest results, discarding the remainder.
  • Keep Lowest Rolls: 4d6v3: Roll 4d6, but keep only the 3 lowest results, discarding the remainder.
  • Note: You cannot have ^ and v in the same roll -- 3d6^1v1 is invalid.
  • Compound Rolls are OK: 3d6-2d6-5+3: Roll 3d6, subtract 2d6, subtract 5, add 3
  • Whitespace is ignored: 1 d 6 and 1d6 are the same thing. '1 d 2 0' will work too, all white space is completely ignored
  • Syntax Errors Any syntax errors cause the entire roll to be considered invalid.


"; } ?> = 2 && $capture(1)) ? $capture(1) : 0; preg_match('/v(d+)/', $rollToken, $capture); $keepLowCount = (sizeof($capture) >= 2 && $capture(1)) ? $capture(1) : 0; preg_match('/^(d+)/', $rollToken, $capture); $keepHighCount = (sizeof($capture) >= 2 && $capture(1)) ? $capture(1) : 0; $detailText .= (empty($detailText) ? "" : "
") . "" . ($rollSign == -1 ? "-" : "") . "$rollToken Results: "; $subTotal = 0; $rollResults = array(); if ($rerollThreshold >= $diceType) { $detailText = $INVALID_ROLL_ERROR; break; //Future note: This should break out of the big foreach ($rollTokens) loop } for ($k = 0; $k < $numberOfDice; $k++) { array_push ($rollResults, rand($rerollThreshold+1, $diceType)); } if ($keepHighCount > 0 || $keepLowCount > 0) { if ($keepHighCount > 0) { $keepCount = $keepHighCount; $selectorFunction = "max"; } else { $keepCount = $keepLowCount; $selectorFunction = "min"; } if ($keepCount > $numberOfDice) { $detailText = $INVALID_ROLL_ERROR; break; //Future note: This should break out of the big foreach ($rollTokens) loop } $keep = array(); $discard = array(); foreach ($rollResults as $key => $val) { $discard($key) = $val; } for ($k = 0; $k < $keepCount; $k++) { $highest = call_user_func($selectorFunction, $discard); $highestIndex = array_search($highest, $discard); array_push($keep, $highest); unset($discard($highestIndex)); } foreach ($rollResults as $roll) { $keepIndex = array_search($roll, $keep); $discardIndex = array_search($roll, $discard); if ($keepIndex !== False) { $detailText .= "$roll "; $subTotal += $roll; unset($keep($keepIndex)); } else { $detailText .= "$roll "; unset($discard($discardIndex)); } } } else { foreach ($rollResults as $rollResult) { $detailText .= "$rollResult "; $subTotal += $rollResult; } } $subTotal *= $rollSign; $detailText .= " (Total = $subTotal)"; $rollTotal += $subTotal; } } } else { $detailText = $INVALID_ROLL_ERROR; $rollTotal = "0"; } $detailText .= "
Total: " . $rollTotal; $detailText = "Dice Roll: " . $inputClean . "
$detailText"; return array('input'=>$inputText, 'total'=>$rollTotal, 'detailText'=>$detailText); } ?>

Darkroom – How do I design movies with a JOBO tank and a manual roller?

I have experience in developing b / w movies with normal Patterson tanks and using inversion.

Now I have a JOBO 1540 tank and a manual JOBO roller base and as there are no instructions for actual film development, I am not sure how to use them for good results.

Should I turn the tank continuously? With inversion, it would be more like the tank was spinning every minute of development (and so on).

When I look at a video of motorized JOBO processors, I think it's also a good idea to change the direction of rotation?

I also suspect that a good speed is between 60 and 70 rpm.

E Series Tapered Roller Bearings – Advertising, offers

The Timken Company has developed a new type of tapered roller bearings of the E series, which has a very high efficiency. The company also introduced the new standard for warehouse services.

Timken Company's E-Series tapered roller bearings can be used in extremely harsh conditions. It adds a double sealed design; This leads to less pollution by particles and other objects compared to other storage products of the same category. The newly added coating can protect the bearing surface well because it increases corrosion resistance. This type of product also performs better as it is equipped with the Timken multipurpose grease, which contains some additives that are resistant to corrosion and friction. In addition, there are a wide range of sizes and structures of tapered roller bearings of the E series to meet the requirements of different industries.

As everyone knows, the Timken Company is one of the world's leading warehouse suppliers. There are different types of products that are manufactured by this company and can meet the different needs of customers. The products all have a very good quality. In addition, the company can also provide customers with good services. The company's innovation makes it possible to offer customers better products. Apart from these, the company also has advanced technologies such as advanced materials technology, advanced process technology and design and analysis technology, etc. With these technologies, the company can produce more sophisticated products.

All in all, the company always considers the customers. It tries its best to improve the technologies as well as the services to meet the development of the market. Obviously, the newly developed tapered roller bearings of the E series are very innovative and can meet the specific requirements of the customers.

The tapered roller bearings of the E series have many special features. For example, they have a high sealability and a pronounced anticorrosive capacity. These products also have a longer life.

NORTH INTERNATIONAL is the direct agent of SKF bearings, FAG bearings, IKO bearings, KOYO bearings, NTN bearings, NSK bearings, TIMKEN bearings, ball bearings, self-aligning ball bearings, spherical roller bearings, Tapered roller bearings, double row deep groove ball bearings, thrust ball bearings, deep groove ball bearings, angular contact ball bearings, axial cylindrical roller bearings, cylindrical roller bearings, the self-aligning bearing … all these products are available from stock. If any special requirements on specification, materials and so on, we can set the rolling and guarantee delivery. So if you are interested, you are welcome to contact us.

Some advantages and disadvantages of cylindrical roller production – advertising, offers

Cylinder bearings are commonly used in industrial applications instead of plain bearings, as the latter tend to cause more friction which can lead to further obstructions. For example, in a machine that requires sliding, roller bearings are always preferred. There are two reasons. On the one hand cause rolling bearings comparatively less friction and thus prevent the wear of the machine. Second, rolling is always a lot easier to do and paves the way for smooth machine operation.

There are now various types of bearings, the most common are cylindrical bearings. As the name implies, these bearings consist of cylindrical and crowned rolling elements to prevent the stress from being concentrated to a specific point. The production of cylindrical rollers is available worldwide as it is one of the most commonly used machine parts for industrial applications. Before you deal with this, let's take a look at the advantages and disadvantages of cylindrical roller bearings.

These rollers can be used for functions that require a high radial load capacity, eg. For example, for compressors, machine tools, cement pulverizers, etc. As your load becomes heavier, the roller components must be kept static, which is possible with such roller bearings. It can withstand some light thrust movements, making it ideal for roller blades, fan blades, wheel bearings, etc.

Since the cylindrical roller bearings have a higher radial capacity than the other types of roller bearings, they can carry more load. You can also record axial displacements in the machines used. In machines that perform vibration applications, cylindrical roller bearings are useful.

While cylindrical roller bearings have both advantages and disadvantages, they are definitely used in a number of industrial applications. To find out more about these bearings, you can turn to cylindrical roller production.

NORTH INTERNATIONAL specializes in high quality bearings and related products. The company aims to become the benchmark for Chinese warehousing companies using advanced technology, stable and reliable products, and professional and thoughtful service to provide users with a more cost-effective solution.

download game cmoar roller coaster vr

Click the Download Now button to download Game cmoar roller coaster vr Plumber.
The entire process takes only a few moments.


– Title: Game cmoar roller coaster vr
– Download type: Security (no torrent / no viruses)
– Status file: clean (from last analysis)
– File size: not defined
– Price: free
– Special requirements: No




Take a tour to an incredible place. Experience the longest adventure in
an almost 4-minute dangerous roller coaster ride. Free version was …
Cmoar Roller Coaster VR v1.1 Download apk + OBB data for Android
Execution. Download Cmoar Roller Coaster VR for Android. To be taken

March 6, 2016 … Cmoar Roller Coaster VR is an entertainment game for Android download
Version of Cmoar Roller Coaster VR Apk + Data for Android from …
March 8, 2016 … Cmoar Roller Coaster VR 1.1 Apk + Data for Android Download rexdl Take a tour
to an incredible place. Experience the longest …
November 11, 2015 … You are about to download Cmoar Roller Coaster VR 1.1. APK for Android,
Take a tour to an incredible place. Experience the …
Take the Rollercoaster Jungle Amusement Park Pro Download QR … Coaster
! VR Stereograph. Download the QR code. Coasters! VR Stereograph. Developer: …
Virtual Reality RollerCoaster VR for Google Cardboard Download QR- … VR
Roller Coaster Game Download QR- … Cmoar Roller Coaster VR Download
QR- …
22.01.2016 … In our eyes this is the best experience of the virtual roller coaster ride on …
Cmoar Roller Coaster VR can be enjoyed by just about anyone. A free version
The app is available for download, although the ride is cut at just over one
Minute. … This virtual reality game is a modern version of a classic …
Cmoar.CmoarRollerCoaster & hl = DE. Note: This is a review gameplay video
I test and demonstrate VR games.
Cmoar Roller Coaster VR – Apps on Google Play
Cmoar Roller Coaster VR v1.1 Apk + Obb Free[Fullversion[FullVersion[Vollversion[FullVersion
Cmoar Roller Coaster VR v1.1 Apk + Data for Android – RevDl
Cmoar Roller Coaster VR 1.1 Apk + Data for Android –
Cmoar Roller Coaster VR 1.1 APK Download – Android …
The VR Scooter Coaster List – VR iPhone
These are the best virtual reality apps to 2016 with | to start
Cmoar Roller Coaster VR Google Carton 3D SBS – FrameFools
download game cmoar roller coaster vr…-project-igi-2-full-game-free-download-for-pc

unity – physics-based roller coaster movement on Unity3d?

Thank you for providing a response to Game Development Stack Exchange!

  • Please be sure answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarification or answers to other answers.
  • Make statements based on opinions; secure them with references or personal experiences.

Use MathJax to format equations. Mathjax reference.

For more information, see our tips for writing great answers.