Thread: Dice loop

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Rep Power

    Dice loop

    So I'm working on a program involving five dice being rolled 3 three times. Whenever I roll a six, I want to keep that die (Like Yahtzee) and continue rolling with the remaining dice. I have however no clue how to code it so that it keeps a six and continues with the remaining dice. Does anyone know how to do that?
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Alpharetta, GA
    Rep Power
    First off, if you haven't done so already, write a function roll() (or something like that) that takes a variable number of dice, loops through that number of random integers, and returns a list of the results. This will give you the bility to generate an arbitrary number of die rolls on a given throw.

    Selecting out the sixes from the returned list is left as an exercise.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo.

IMN logo majestic logo threadwatch logo seochat tools logo