BHT MIDIBHT Smart Random
This is a plugin for Construct 2 by Scirra. Last updated: Nov 7 2015

This plugin generates non-repeating integers within a given range, and will cycle with a given threshold to not repeat within that threshold.


The plugin takes a Start value, and an End value, and will produce a unique sequence of those numbers, without repeating. The range is inclusive, so if you specify a range of 1 to 5, you will get the numbers 1,2,3,4,5, in a random pattern.

A Threshold value lets you configure how the cycle repeats when all of the numbers are used, and the sequence needs to continue/cycle. A Threshold=0 will completely ignore the previous sequence, so the numbers will be random within the same range again, but it is possible that the last number of the sequence may be the same as the first of the next. For example; 2,5,4,1,3 could be followed by 3,1,4,2,5. The value 3 will repeat because the sequence must be regenerated and no logic is applied to test the last value of the last sequence. A Threshold=1, would guarantee that the first number of the next sequence would not be a 3, so there would not be a repeat immediately when the sequence restarts. Care is still required not to abuse the Threshold, as if it is too large (that is, greater than half the range), it is impossible to guarantee not repeating the same values.

Supports the C2 Save/Load mechanism.

Drag the C2ADDON file onto the Construct GUI to install the plugin.
The start value of the range.
The end value of the range.
Repeat threshold
The threshold for not repeating the same values of the previous sequence.
Returns the next random value in the sequence.
Returns the start value of the range.
Returns the end value of the range.
Returns the threshold for not repeating the same values of the previous sequence.
Returns the next random value in the sequence without removing it. Allows you to 'peek' at the next value.
Smart Random
Re-randomizes the sequence. Repeats are ignored.
Create a new sequence by providing new values for Start, End, and Threshold. Repeats are ignored.
BHT Smart Random - v1.0

Smart Random example CAPX