• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] How to create random pick system? Details inside.

Level 18
Joined
Jun 2, 2009
Messages
1,233
Hello. I am going to ask for whole system this time. Here is the example.

You have 5 integers.
Game selects randomly 3 of the integers and sorts.
Same integer cannot be selected more than once.

Example

Game picked numbers 1, 3 and 4.
The trigger with number 1 runs, then runs 3 and runs 4.
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
It would be best. Because he already knows i will never get it. No one tried to spent time for explain, i have learned how to do what i want
Problem solved, everyone happy :)
If i was capable to understand and wanted to learn about this system, probably i have already asked for details and explanation.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
The basic idea is to create a set of numbers, such as an array set. Then pick a random element from that set, removing it in the process. These picked elements then are stored in a list, such as an array list. Repeat until you picked the number of elements desired. Then you can sort the list using any sorting algorithm, such as linear sort.

The use of a set to store the numbers to pick from allows an optimisation for removal if implemented using an array. The removed element can be replaced with the last element. If an array list was used then all subsequent elements have to be moved down 1 place.
 
Top