Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

NodeBB

  1. Home
  2. Archives
  3. Immortal Archive
  4. Requests
  5. "rand" is pure garbage

"rand" is pure garbage

Scheduled Pinned Locked Moved Requests
3 Posts 3 Posters 27 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pollution
    retired
    wrote on last edited by
    #1

    Yeah, pure garbage. I'm sure everyone already knows that. I'm going to rearticulate a suggestion I made back when we were on the old board about fixing this.

    To create that degree of randomness that's so useful in scripting, incorporate the dice command and output the value rolled to some $value ($dice). For example:

    dice 1 d 100
    if $dice <= 10
     <whatever>else
    if $dice > 10
    and $dice <= 30
     <whatever>else
    if $dice > 30
    and $dice <= 100
     <whatever>endif
    endif
    endif</whatever></whatever></whatever> 
    

    Here you have 3 possible outcomes, each with a separate probability of occuring. Since the dice command already exists, I hope that makes it a bit easier to incorporate into this functionality. It would certainly improve our scripting tools.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vizzini
      retired
      wrote on last edited by
      #2

      I think Nib's prolly the man to speak to about this. From a coder's perspective, there's an internal function dice() that takes an argument along the lines of dice(<number of="" dice="" rolls="">d<denomination of="" dice="">+offset).

      e.g

      dice (20d6+10) would give you a min result of 10 + 20d6 = 30, max result 10 + 20d6 = 130.

      The only problem I see with functions like these is of "striping", where the random factor isn't actually very random, making the randomisation a little "predictable", which is to say that in repeating the same function over and over and recording the results, definite patterns emerge in the data.

      Linux provides a number of methods of providing much more random data, utilising things like entropy data extracted from the normal operation of the system, none of which are hard to implement. Indeed, there are external entropy packages we could employ for just this purpose.

      In summary, I don't think it would be hard to give you a method of generating finite and bounded randomness based on defined probablility constraints. In fact, I'd be surprised if this hasn't already been addressed in the wealth of new functions Nib's bolted on recently.

      Scott.

      Scott.</denomination></number>

      1 Reply Last reply
      0
      • NibelungN Offline
        NibelungN Offline
        Nibelung
        registered
        wrote on last edited by
        #3

        Actually, I've got the source for the Mersenne Twister random number generator… which has a disgustingly long period for the random numbers, something about 2^19937-1. I think that is enough. I'll slap that puppy into the code.

        For your reading pleasure or if you are really interesting in this generator: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        Powered by NodeBB | Contributors
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups