![]() |
VOOZH | about |
Randomizers are redstone circuits that generate random signals. They can be used in a multitude of things, from running a light show, to making a casino. Note that randomizers, like the majority of redstone circuits, will only work in active chunks. If this is wanted for a adventure map or something where the player may get far away, it may be desirable to build the randomizer in an area loaded by a chunk loader[Java Edition only] or in a ticking area.[Bedrock Edition only]
This randomizer utilizes the fact that droppers dispense items in random order. It will output a random signal strength of 1 or 3 whenever a signal is provided. To create it, place a dropper, hopper, and comparator as shown. Then put items of varying stack size into the dropper, e.g. a sword and a piece of dirt. When you power the dropper, it will put an item into the hopper, turning on the comparator. Since the items take up different amounts of space, the power level will vary. It may seem as if adding items that stack to sixteen will allow an output of two, but unfortunately unless the hopper is weighted with items beforehand, items that stack to 16 only result a level of one.
Shulker boxes have the ability to be placed by dispensers, broken by pistons, and retain their items. When a shulker box is randomly placed by the dispenser, a comparator can produce 15 unique redstone signals.
A mob randomizer is the general term for randomizers which use mobs to trigger redstone with their random wandering. This type of randomizer is best when several outputs are wanted and it doesn't matter when the signal occurs or for how long. Mob randomizers are usually created with either pressure plates or tripwires. Using tripwire is probably the easiest method, but it requires more iron.
The type of mob used in the randomizer can create some important variations. Some common choices include:
In
|
This randomizer uses jukeboxes and hoppers to generate a redstone signal with a random strength from 1 to 12. This is unique because most other randomizers do not generate analog signals with so many possibilities. The two downsides to this randomizer are that it can only generate signals as fast as it takes for each music disc to finish playing and that it can be somewhat expensive.
→
|
→
|
👁 Image
Analog 2-RNG
The dropper contains one stackable item and one non-stackable item.
👁 Invicon Stick.png: Inventory sprite for Stick in Minecraft as shown in-game linking to Stick with description: StickOutputs either power level 1 or 3 while on, power level 0 while off.
When the input turns on, the dropper will randomly choose to push either the stackable item or the non-stackable item into the hopper, causing the comparator to output either power level 1 or 3. Because the powered dropper is a solid/opaque block, it will also deactivate the hopper, preventing it from pushing the item back to the dropper until the input turns off.
Variations: If the dropper is powered indirectly (for example, by quasiconnecitvity or an adjacent powered block), the hopper won't be deactivated and will immediately push the item back into the dropper. This turns the circuit into a monostable rising edge detector with a 3.5-tick output pulse (still with a random power level of 1 or 3).
With only two items in the dropper, both output power levels will be chosen with equal probability. The probability of the output levels can be changed by adding additional stackable and non-stackable items to the dropper (which must all be different from each other so they won't stack). For example, with two different stackable items and three different non-stackable items, the RNG will output power level 1 40% of the time and power level 3 60% of the time.
Earliest Known Publication: March 14, 2013[1]
→
|
→
|
👁 Image
Analog 3-RNG
The dropper contains one 64-stackable item, one 16-stackable item, and one non-stackable item.
👁 Invicon Stick.png: Inventory sprite for Stick in Minecraft as shown in-game linking to Stick with description: Stick
👁 Invicon Snowball.png: Inventory sprite for Snowball in Minecraft as shown in-game linking to Snowball with description: Snowball
👁 Invicon Stone Shovel.png: Inventory sprite for Stone Shovel in Minecraft as shown in-game linking to Stone Shovel with description: Stone Shovel When in Main Hand: 3.5 Attack Damage 1 Attack Speed
The hopper contains five 16-stackable items in the far right slot.
👁 Invicon Snowball.png: Inventory sprite for Snowball in Minecraft as shown in-game linking to Snowball with description: SnowballSchematic: Analog 16-RNG
Digital randomizers work by randomly generating a binary number and selecting a corresponding output using a binary decoder. To achieve a flat probability the bits are randomly generated, typically using an analog randomizer with a 50% chance of activation and a red-coder.
This randomizer uses a repeating command block adding 1 point to a score per tick, then another repeating command block truncating the value to its maximum. When a random value is needed, repeating command blocks testing for certain values are used. This setup is not completely random as it is based on the time it is activated, but is random enough for most purposes.
In this example, the minimum value is 10 and the maximum is 20.
To start, a dummy scoreboard objective must be created to store the values: /scoreboard objectives add randomizer dummy. Next, two repeating command blocks are needed, both set to "always active". The first one adds 1 point to the score every tick: /scoreboard players add ticks randomizer 1. The second one truncates the value to the aforementioned minimum and maximum: /execute if score ticks randomizer matches 21.. run scoreboard players set ticks randomizer 10 (where "21" is the maximum exclusive value and "10" is the minimum value). Finally, a set of command blocks testing each value are needed, all attached to the single input; for example, /execute if score ticks randomizer matches 12 run say hi will run /say hi (placing [@] hi in chat) if the random value between 10 and 20 is 12. The following schematic shows an example setup where the command blocks testing each value are attached to an input:
The randomizer is based on the random target selector criteria (limit=1,sort=random). It is a derivative of the idea by NOPEname.[4]
At startup, run the following commands. You may wrap them in a function for convenience.
scoreboard objectives add RandomBit dummy
execute unless entity @e[type=armor_stand, tag=RandomizerResult] run summon minecraft:armor_stand 0 -1 1 {Marker: 1b, NoGravity: 1b, Invisible: 1b, Silent: 1b}
tag @e[type=armor_stand,x=0,y=-1,z=1] add RandomizerResult
scoreboard players set @e[tag=RandomizerResult] RandomBit 0
execute unless entity @e[type=armor_stand, tag=Randomizer] run summon minecraft:armor_stand 0 -1 0 {Marker: 1b, NoGravity: 1b, Invisible: 1b, Silent: 1b}
execute unless entity @e[type=armor_stand, tag=Randomizer] run summon minecraft:armor_stand 1 -1 0 {Marker: 1b, NoGravity: 1b, Invisible: 1b, Silent: 1b}
tag @e[type=armor_stand,x=0,y=-1,z=0] add Randomizer
tag @e[type=armor_stand,x=1,y=-1,z=0] add Randomizer
The execute unless part is not necessary, but it is helpful if you do wrap them in a function and want to invoke the function multiple times (e.g. for testing).
Every time you need to obtain a random bit (0 or 1), you can run the following commands, either manually, via a chain of command blocks, or a function.
tag @e[type=armor_stand,tag=Randomizer] remove PickedBit tag @e[type=armor_stand,tag=Randomizer,sort=random,limit=1] add PickedBit execute store result score @e[type=armor_stand, tag=RandomizerResult] RandomBit run data get entity @e[type=armor_stand, tag=PickedBit,limit=1] Pos[0]
Now you have a scoreboard objective with a randomized bit. This method can easily be extended to generate a random number in a large range.
/random command basedAs of Java Edition 1.20.2, there is native support for generating randomized values with the /random command.
There is native support of randomized scoreboard objectives in Bedrock in the form of /scoreboard players random ....