Sunday, January 6, 2019

Shuffle Algorithm

The main point of using this function is to shuffle arrays.
This function uses Fisher-Yates shuffle. It just generate a set of numbers in random order that are not repeated.
This can also found in hercules github.

Examples: 
F_ShuffleNumbers( 0, 5, .@output); // possible output 4,1,3,2,0,5
F_ShuffleNumbers( -5, 1, .@output); // possible output -3,-5,-4,-2,-1,1,0
F_ShuffleNumbers( 0, 100, .@output, 5); // possible output 9,55,27,84,33
Reminder: Use *freeloop command when appropriate !

Snippet:



I have used them in ...
1. outdated - reshuffle player's registration before entering battleground (recent topic - script)
2. randomize the woe time (script)
3. shuffle the portal location, make it like a maze event (outdated script)

External Links:

Question asked on the forum
How me and Haru optimize and perfect this function 
meko's Array manipulation functions
Shuffle Algorithm topic
 

No comments:

Post a Comment

Linux compiler error that never shown on Visual Studio

let's just admit Visual Studio sux ... ok ? right now, if you want to host a Private Ragnarok Online server, its just better to choose...