Announcement

Collapse
No announcement yet.

Random Int in Range duplicating numbers?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Random Int in Range duplicating numbers?

    Hi.

    Having an issue thats a bit hard to track down.
    Occasionally my array is missing an item.

    Sometimes it would be 1, other times it would be 2 items missing.
    I then noticed a mistake where i set random int in range from 0-38.

    The array contains only 38Items.
    So i set the random into in range to 0-37

    This got rid of the 2 items missing.
    But now there are occasionally 1 item missing.

    Is it possible that Random Int in Range selects a number twice occasionally?
    http://celestialarch.com
    Free UE4 things available. More coming

    #2
    Ahh i printed it to the screen on the forloop and it does in fact bring the same int at occasions. Will have to do some check and for every duplicate i need to rerun one loop atleast or perhaps more for every duplicate entry
    http://celestialarch.com
    Free UE4 things available. More coming

    Comment


      #3
      Im not sure if this is the best way to go about it. But it works.

      I get the Int's it randomly selected and write it to an array at the end of the loop body, and then during the loop it checks if that int was already selected. If it was (false) then i just rerun that specific loop body and not the entire loop)

      Click image for larger version

Name:	f3d0283ea5.jpg
Views:	1
Size:	106.9 KB
ID:	1066834
      http://celestialarch.com
      Free UE4 things available. More coming

      Comment


        #4
        Hello,
        I got sometimes troubles with some random int in range and when i did a "set" and used the "get" result to set all i solved it.

        Edit : i even used a rand to get a var in an array and use this array result, and got same multi issue. Only setting a var and use this var solved it.

        Comment


          #5
          Hi

          I did a test earlier, strange results.

          https://answers.unrealengine.com/que...ly-random.html

          Narg
          http://www.seven-mountains.eu/

          Comment

          Working...
          X