Series Of Random Values?

Would anyone happen to know how to make a series of random values that are different?

Example:

An objects behaviors are to generate a series of numbers that are not the same.

The numbers range from 1-20, but the object will only choose 6 of those numbers and none of them will repeat.

You can use a list and a random block to either:

  1. Add a random value to a list, if it’s already in the list then roll again.
  2. Have a list and randomly remove a value at a time, updating the list on each roll.

Umm, I already tried using the 2nd method and the value was not removing from the list, I don’t know what I was doing wrong when I followed the example.

Also, how would I do the first method? like I said I don’t really understand how lists work.

@CodeAlpaca should be able to explain them to you.

1 Like

So there are 2 ways you can remove a value from a list here but first, remember that the pop input only removes the last value in the list.

  1. Have a list 1-20 and use List Order behavior to shuffle the list and use the pop input to remove values from the list.

  2. Or you can use remove on list modify after getting the radnom value you want. This would have more steps.

image

1 Like

So for the first step, it would list the outputted numbers in one go? or would I have to keep activating it until I get 6 values that are not the same?

Pop only outputs the last value in the list and removes it.
You need to input pop for each time you want a value

1 Like

Oh wait, the trigger mailbox will activate it right?

Yeah, the mailbox was just to show how to activate the system.

2 Likes

Awesome, it worked. Thank you so much.

3 Likes