Announcement

Collapse
No announcement yet.

Randomized lists in Javascript

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Randomized lists in Javascript

    Had an idea for a random generator in Javascript, and not sure how to do one part. Essentially, I need to be able to display about 20 items on a list in random order without repeating any items. The random list is easy enough, I just don't know how to keep from having repeats.

    The only thing I can think of is using a boolean variable for each list item and having the script skip any that are marked as having been displayed already...
    » Horse Words «·» Roleplaying Stuff «

  • #2
    That's one of my favourite ways for doing something like that. If you pick an item that's already been picked, pick again. (In theory, if you don't need perfect statistical distributions, you could also re-assign the numbers for each item, so that then you're picking from 1-19, then 1-18, etc, but you have to decide if that's worth it).

    Comment


    • #3
      Either one would probably work, so long as there aren't any repeats. And if I can figure out a decent way to do them.

      The project is an attempt at creating random Bingo boards out of all the stupid complaints SCs make, like "I'm one of your top spenders", or "The competition lets me do it", or "I know the owner".

      Edit: Wait, got it to work a lot easier with an array, just in time to go to work. I'll post a link once I get back.
      Last edited by KabeRinnaul; 07-17-2010, 07:24 PM. Reason: Figured it out
      » Horse Words «·» Roleplaying Stuff «

      Comment

      Working...
      X