[Plugin] Smart Random

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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

    v1.1 (C3 and C2 runtime)

  • Cool.

  • Many thanks, blackhornet.

    Looking forward to having a play with this.

  • Cool. i am going to try

  • Thanks a lot!

  • This is very useful thanks

  • 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.

  • luvleggs

    You don't actually mention which part is random. Is it the layout, or the items, or the placement of the items?

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • blackhornet I got the random part sorted out but for the life of me I can't see to sort out why some of my layouts are adding more than one to the global variable of score. I've followed examples and they look the same to what I've done but know I must be missing something.

    My capx is at https://www.dropbox.com/s/4aeuxdgbvht0d ... .capx?dl=0

    If you don't mind looking I would be most appreciated. I took it down to just two layouts for the time being. My goal is to have the user drag x number of items into dropbox defined at the top of each layout then when they have completed that they add 1 to their total score. Once the total score equals 8 they would be take to end game layout.

  • The problem is you aren't disabling your dropbox.score check in Main2. Event 10 keeps running until it hits 5 because of your Wait 2 seconds. Use a Group and move event 9 into it and disable it as the first action. That will stop that code from running repeatedly while the Wait is running. Be sure to reset it "On startup". Also don't restart BHTSmartRandom (Main1 - event 1), or that will reset the counter and break the mechanism.

  • blackhornet Sorry to be dim but when you say disable dropbox.score what do you mean? the wait 2 seconds, destroy dropbox after adding to sCore or is do you mean to disable txtCount > set text to "dropbox.score"? I've pulled the reset of BHT off of main2, not sure why it was still there. Even when I pull the wait 2 sec on main 1 I am getting a score of 3 so I'm pretty sure I'm not comprehending correctly.

  • blackhornet Oh wow, that is awesome I now understand.

    I didn't realize you could literally deactivate a group.

    Much appreciated.

  • Hi,

    Sorry if its a stupid question put how do i use this? I have put the plugin in my plugin folder but construct isn't recognizing i have it installed?

    Thanks in advance

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)