[Plugin] Smart Random

Post your completed addons to share with the community

Post » Sun Nov 08, 2015 6:47 pm

People are constantly fighting to get a simple non-repeating random integer from within a range. This plugin solves that. Although I've recommended the RandomArray plugins myself, they do not deal with how the cycle repeats after you use up all of the numbers in the range. This plugin deals with that issue also.

You pick a start value, an end value (inclusive), and a threshold for how many values on the next cycle should not repeat from the end of the current cycle. This maximizes the randomness of a repeating sequence, if needed.

BHT Smart Random
Demo
Documentation
Last edited by blackhornet on Tue Mar 28, 2017 12:49 pm, edited 1 time in total.
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Sun Nov 08, 2015 6:52 pm

Cool.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sun Nov 08, 2015 7:07 pm

Many thanks, blackhornet.

Looking forward to having a play with this.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,375
Reputation: 58,432

Post » Tue Nov 10, 2015 2:54 am

Cool. i am going to try
B
72
S
25
G
5
Posts: 89
Reputation: 7,275

Post » Fri Dec 04, 2015 10:27 am

Thanks a lot!
Image
B
63
S
28
G
39
Posts: 459
Reputation: 24,183

Post » Fri Dec 04, 2015 4:50 pm

This is very useful thanks :)
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Sun May 15, 2016 7:25 pm

Being reasonably new, might I ask how this would be applied to Layouts.

For example If I have certain number of items to collect, say 10 and upon collecting 10 items I want the user to add a point to their score and go to another non-repeating layout and repeat the process until they reach the ultimate goal of achieving 10 points where they would then be taken to an end of task layout.
B
29
S
10
G
3
Posts: 69
Reputation: 3,515

Post » Sun May 15, 2016 8:52 pm

@luvleggs
You don't actually mention which part is random. Is it the layout, or the items, or the placement of the items?
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Sun May 15, 2016 9:21 pm

Sorry @blackhornet can't believe you didn't read my mind ;)

Ultimately all of them but to start just the layout.

I can randomize my items an and their placement reasonably well and normally I would use "Main"&floor(random(1,8)) for my Main1-8 layouts. For some reason on this one I get duplicates more often than I would like and it is adding more points than just one for every ten items so I end up collecting 10 items in layout 1, it goes to layout 3 and my point total which should just increase by one is upping by 4.
B
29
S
10
G
3
Posts: 69
Reputation: 3,515

Post » Sun May 15, 2016 10:31 pm

Set up one array for 1-8, and call "Main"&BHTSmartRandom.Next. The only trick is you need to keep a counter so that you know all 8 layouts have been visited. You could use an instance variable on BHTSmartRandom itself. You could also use a second array that you copy the values over to, and pop them off one at a time, but the counter seems simpler here.

The wrong increment issue is something else. We'd need to see what you are doing there. It should be straight forward.
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest

cron