# In Minecraft how do I randomise the output in a redstone circuit?

I have 5 buttons and only one of these can be correct, all others must be false.

These 5 outputs will go into 2 outputs, in between there needs to be a circuit which changes which single button out of the 5 will go down the "correct" output of the final 2. The 4 remaining buttons must go to the second of the final 2 outputs.

Both final outputs must give out a true signal for a brief period the same as a button on its own would produce.

There should also be a way of activating the circuit.

Not sure if that is explained well enough so I have made a basic diagram of what I need.

The diagram shows how I need the signal to be split. However in between the buttons and the final two wires there needs to be a circuit (marked by the grey box). This circuit changes the single button connected to the left wire. The right input should start the circuit and randomise the 5 buttons.

There are no limits to size, amount of materials used or method used.

• Yay, a redstone challenge! So basically, you want something in the middle of the diagram that will make it so the correct button is always random? – Kevin Yap Mar 12 '11 at 4:48
• I'm guessing you want some sort of clock for the randomization part, hm? – Raven Dreamer Mar 12 '11 at 4:49
• Also, is there any size or amount of redstone constants? (please say no, please say no) – Kevin Yap Mar 12 '11 at 4:54
• I'm thinking of a pig/cow herd fenced into an area with pressure plates, but I can't get any further than that without getting distracted by all the other possible uses for such (music generator, trap gauntlet automation...). – Stu Pegg Mar 12 '11 at 16:43
• Let me see if i understand this correctly: Inputs: buttons 1-5, randomize Output: valid, invalid. When the circuit is randomized, one of the buttons is piped to the `valid` channel, the other 4 are piped to the `invalid` channel. Is this correct? – zzzzBov Mar 15 '11 at 17:14

Since there is no answer I will show how to make a random unit:

If you are not ready to be brainfucked go to conclusion at the end.

Take a 3-clock unit and set an output somewhere, now since this is only 3-clock it's gonna burn at RANDOM place so the output will be random. Like this:

Now you probably don't want it to change so much but only when it stopped, well.. idk if anyone used it(probably used), anyway I've made it my self, I call it "signal cuter" the point is to split the signal into 2 signals: first contain odd number of "not gates" and the second even, and then merge them into "or gate", the result is: when a signal is sent, it's gonna stay as the output until the second path will cut the signal and that way no matter for how long you set the input to "on", the output gonna be "on" only for length(second path) - length(first path) "ticks".

in this example, all signals that are more then 3 ticks length are shorted to 3 ticks long. On same property you can make a "signal protector" also made by me :), it's not passing signals less than X long all the difference is that both paths first and second need to be odd length and the X is equal to length(second path) - length(first path), but the signal become shorter then the original signal length. Example:

FINALLY the conclusion: so now you can take the a 3-clock and to chain it with the "signal protector" with X=2 and THIS WILL BE STABLE!! It won't throw junk until the 3-clock burned and the result is stable, the next random will be generated after the next 3-clock burn, if you want to make it faster just make many units of that.

THE RESULT:

It's still throw junk in "Redstone Simulator" but in "Minecraft" this works great! Please if you're passing on this technique, leave the names "Signal Cutter" and "Signal Protector".

• Someone appears to have drawn all over your diagrams. :) Apart from that it looks like a very useful idea. However not for this question as far as I can tell. I'ts fairly late so forgive me if I have misunderstood but this appears to give out only one random output. I need 5 outputs and for one of them to be randomly on. And it must only be 1 while all others are off. i have came up with a design that does the rest, I just need that part now. Will try to post my progress soon. – RedstoneDwarf Mar 19 '11 at 5:14
• Get a drawing tablet. They make better freehand circles. – Kaz Wolfe Aug 14 '14 at 7:31

First, this is a really involved question. :) So I decided to split my answer into two parts, where the second part is a separate Q/A, involving how to activate a random wire.

This part of the Answer, takes that random wire (1 of 5), and multiplexes it with 5 buttons, to direct 1 of the 5 buttons to a valid-output circuit, and the other 4/5 to an invalid-output circuit.

Due to the diagram's complexity, I'm only showing 3 buttons, not 5 - however, extending it to 5 buttons is very straightforward, and should be clear from the diagram.

## Top-level circuit diagram

The 5-Wires box is from the other Question. Basically there are 5 wires (gosh), exactly one of which will be active at any time, with the active wire changing each time a button is pressed. The wires are connected to a 222 circuit, which takes two inputs - a wire, and a button. The 222 circuit has two outputs, connected to two different 5-input OR circuits.

If the wire to a given 222 circuit is active, and the button is also pressed, it will send a positive signal down the red wire, to the valid circuit. The signal will last as long as a button stays pressed, roughly half a second I think. If the wire is inactive and the button is pressed, the 222 circuit will send a positive signal down the green wire to the invalid circuit. In all other cases, there is no signal sent down any wire.

## Notes

I have tested the individual components in isolation. The 222 circuit works fine, the 5-clock and 333-circuit in the other part, work fine - but I haven't wired up an entire test circuit (not even 3 buttons), because it's really freaking big. However, as far as I can tell, it should work - there are no parts that require extremely precise timing, I turned all the corners on Redstone wiring as needed to avoid glitches, and I don't see any section that would be affected by the SW rule.

I also don't have Baezon's MCE, since it uses Java 6 (I have JRE 5). It might be easier to enter and test in a simulator than doing it by hand, which I was. :) If it doesn't work, let me know what part broke.

The entire circuit is fairly complex, with a lot of wires crossing, but I don't see how you can avoid that. When you're connecting 5 wires to 5 buttons, and directing each result to two other circuits - that's a lot of cross-overs.

The 222 circuit is fairly mundane, I claim no originality - the only reason I gave it a name, is I had to give it some label in the diagram for clarity. :)

You can make a random number generator with a cactus and pressure plates, you grow the cactus on the center block, and stick pressure plates all around, you then place a block in such a way that whenever the cactus grows it drops a block (this block will be thrown in a random direction), activating one of the pressure plates (wood plates only).

This is a work-in-progress, I plan on adding more updates as I fiddle with stuff, for now I just want to get the conceptual stuff down:

## Inputs:

``````B1 - Button 1
B2 - Button 2
B3 - Button 3
B4 - Button 4
B5 - Button 5
R  - Randomize
``````

## Outputs:

``````V  - Valid, 1 indicates the currently valid button is pressed
I  - Invalid, 1 indicates one or more of the currently invalid buttons are pressed
``````

My current thoughts on this for pseudo-random output are to set up a chain of 4 T flip-flops to a toggleable clock generator. 4T flip-flops create a 4 nybble of data, which holds 16 values (0-15, or whatever obligatory counting scheme you may be using).

16 also happens to be almost divisible by 5, giving you only one extra state, which you can pipe to one of the buttons giving it a slightly heavier weight.

The clock generator should be on only while `R` is on, and `R` will ideally be a pressure-plate, so that variable durations may be used. This has the added benefit that the clock generator will not be on constantly, and that a shorter clock-cycle may be used if burnout doesn't happen quickly.

The output of the T flip flops can ANDed with the input from B[1-5] to produce the desired output. I will go into more details later.