Perfect Faulty Gate - A selection of logic gates to cause multiple and/or random outcomes

FairyPrincessSerenity

Empress of Light
I couldn't find anything on this, so I gave myself a whole heap of stress assembling this logic gate.

What it is... Well, that's easy enough to explain. A basic Faulty Gate is based on probability. It either works or it doesn't. How often it works is based on how many light bulbs are lit. The more there are, the more likely it'll work. That wasn't good enough for me, as I needed something that was "yes or other yes" rather than "yes or no" with a single input. Here's an image of the logic gate with and without wires.

Perfect Faulty Gate.png


I'll try to explain this mess as best as I can. The input is the switch on the snow block. It activates both halves of the circuit. For reference we'll call the top one Circuit A and the bottom one Circuit B.

Circuit B runs into a Faulty Switch set at 100% probability. This is simply to slow down the current. The blue wire going from that gate connects to the Faulty Bulb on the bottom half of the switch gate. That leads to the yellow wire, which activates the Announcement Board on the bottom. By default the bottom light bulb is always lit.

Circuit A leads into a Faulty Gate that is set to only activate 25% of the time. Attached to that gate are yellow and green wires. The yellow wire connects to the top Faulty Gate while the green wire connects to the light bulbs themselves. This is where it gets technical. The green wires prevent Circuit B from reading the bottom Announcement Board and reads the top Announcement Board instead. The red wire coming out of the top Faulty Gate resets the light bulbs back to the way they were to begin with.

So it's either going to be Circuit A or Circuit B that's going to get activated, never both, but you're always going to get a result.

That's pretty much it. The device can be used for any either/or event that you want. Unmodified, this machine will output a 25%/75% probability of one thing happening versus the other.

-> My gate is specifically based on manipulating the probability between two outcomes. Head on down the thread a bit if it's not what you're looking for. There's a good chance you'll find something useful.
 
Last edited:
This seems more complicated than it should be, but darned if my initial attempts to simplify it got anywhere. Faulty gates are surprisingly fiddly. Or maybe I just don't understand them as well as I thought.
 
This seems more complicated than it should be, but darned if my initial attempts to simplify it got anywhere. Faulty gates are surprisingly fiddly. Or maybe I just don't understand them as well as I thought.

I did manage to compress the design by chopping out unnecessary wires; since I made the initial post.

Perfect Faulty Gate (small).png
 
I'm planning on updating my blackjack machine by replacing the hoik-based randomizers with the faulty-lamp based randomizers. I will be using these:

mPOUuhw.png
bKAjbvX.png


Each lever pull sends a signal through one of two paths.

Here's what it looks like with 4 output lines:

slg59sH.png
7EnJITq.png


With such branching it's possible to create 2^N output lines (N is any integer). The challenge is in creating a randomizer that gives equal probabilities for non 2^N output lines, such as the 52 I need in my case. This is actually very easily accomplished by hooking up 12 of the 64 lines back to the original trigger for the starting signal through the randomizer.

The other challenge is to create a randomizer that removes an output line after it has been used (simulating the drawing and removal of a card from a deck of cards). This too can be easily accomplished by having a node at the end of each of the output lines which either sends the signal further on, or sends the signal back to trigger the randomizer again. The node is altered when the signal passes through the first time, so that each subsequent signal arriving at the node will be diverted to the start again. The state of the node can be controlled with a transistor, allowing for a reset of all the nodes (simulating the shuffing of all drawn cards back into the deck).
 
Last edited:
With such branching it's possible to create 2^N output lines (N is any integer). The challenge is in creating a randomizer that gives equal probabilities for non 2^N output lines, such as the 52 I need in my case. This is actually very easily accomplished by hooking up 12 of the 64 lines back to the original trigger for the starting signal through the randomizer.
It seems you inadvertently just solved the problem I was currently brainstorming about - how to create a d20 (as well as d12, d10 and d6). Just imagine a group of players on a Terraria server playing D&D...
 
It seems you inadvertently
Heh, I think it was probably quite, erm, 'vertent'.;) Same problem really. I'd also been wondering how will be best to make evenly distributed random outcome selections that aren't powers of 2, also. Now, you say:
This is actually very easily accomplished by hooking up 12 of the 64 lines back to the original trigger for the starting signal through the randomizer.
But it's not a trivial step, right(?), because you can't loop the cascade of gate activations - the faulty logic gates would just smoke. You'll need to buffer the repeat through a re-triggering mechanism, which will necessarily take at least 1 tick per re-roll. Probably hoiktronics. (Unless I'm missing something?)
 
But it's not a trivial step, right(?), because you can't loop the cascade of gate activations - the faulty logic gates would just smoke. You'll need to buffer the repeat through a re-triggering mechanism, which will necessarily take at least 1 tick per re-roll. Probably hoiktronics. (Unless I'm missing something?)

Well, trivial in the sense that we can easily create 1-tick delays using hoiktronics. There are a lot of posts on this already, especially by inomanoms :).
 
we can easily create 1-tick delays using hoiktronics
Sure, sure. OK for us old time hoik enthusiasts and the enthusiastic new-comers, but a whole other field of game mechanics to grasp for the new influx or wirers. I mean, best not to take such things for granted. Also, I love to have purity of design where possible; it'd be awesome to have non-hoiktonic solutions where possible (too). Edit: Also, @inomanoms would hate the thought of the unpredictable execution times with that, lol. ;)

Anyway, this is pretty :):
 
Last edited:
Sure, sure. OK for us old time hoik enthusiasts and the enthusiastic new-comers, but a whole other field of game mechanics to grasp for the new influx or wirers. I mean, best not to take such things for granted.

But it should be fun for the newer engineers to figure such things out! ;).

Here's how I might build the delay:

da1Izpr.png
HkvOIYV.png


This is a randomizer that has three outputs that all have 1/3rd of a chance of activating. The 4th is sent into a 1-tick delay mechanism before sending the signal through the randomizer again.

This is basically inomanoms's approach, with the addition of an extra layer of teleporters to make sure the dummy ghost is centered properly after each teleport.
 
Last edited:
To go back to @Eternalserenity's original application, you can make it with 1 fewer gate, using an XOR (or XNOR NXOR) in place of the cross linked transistors.

I don't know if it's logically equivalent, but it seems to function as intended. Perhaps it's logically simpler to understand: Every time there's a "no" outcome via the XOR it emits smoke, since it's output signal loops back to reset the input lamp from the initial switch, back to the same state. However, when the randomizer also sends an input to the XOR, both of the XOR's input lamps change state simultaneously, hence it's output state does not change (due to it's uniquely handy truth table), and so no smoke and no "no". Just the "Yes" from the randomizer's output:
The torches are just there so one can clearly see that only one output line toggles at a time. And there are switches to change the probability bias, why not.

So, thank you for starting such a fruitful thread here!:) Could you edit the thread title to be more specifically descriptive, though (to help people find the treasures they are looking for in future). Something like "Perfect Faulty Logic Gate Random selection between multiple outcomes." or at least something that refers to the randomization function, please.:) Sorry to go on at people, but I'm really feeling the need to try to keep our threads as organized as possible, having had trouble riffling through all the old posts when making the video feature, and now with so many more new threads dropping in per day (per hour!), and more people than ever looking to T-MEC.:happy:
 
Let's go back to the non-powers-of-two - alternative approach without hoiks (let's take 20 and 7 as examples): First, we split off any power of two from the number (as if writing it in binary and just taking out one of the bits). Let's go with the largest one, so for 20 that would be 16 and for 7 it's 4. Now we just use a single randomizer with two outcomes and a 16/20 = 4/5 or a 4/7 chance respectively - if it succeeds, we send a signal to a power-of-two-randomizer (16-randomizer or 4-randomizer respectively), otherwise we send one to a randomizer for the rest - for 20, the rest would be a 4-randomizer, for 7 a 3-randomizer which, again, would consist of a 2/3 and then a 1/2 randomizer. Delayers can be added (as early as psosible in the circuit) to make sure the signal comes after the same number of steps, no matter the output - this would lead to any randomizer needing ceil(log2(N)) steps, where N is the number of outputs - or, in simpler terms, X steps, where 2^X is the next larger power of two. No dirty stuff involved and a clearly defined delay.

Also, @ZeroGravitas - stop encouraging people to smoke. It's not good and you know it.
 
Let's go back to the non-powers-of-two - alternative approach without hoiks (let's take 20 and 7 as examples): First, we split off any power of two from the number (as if writing it in binary and just taking out one of the bits). Let's go with the largest one, so for 20 that would be 16 and for 7 it's 4. Now we just use a single randomizer with two outcomes and a 16/20 = 4/5 or a 4/7 chance respectively

Pretty clever approach, taking advantage of our ability to manipulate probabilities in the starting randomizer by stacking lamps. This should work nicely for any randomizer in which all of the starting outcomes are allowed in subsequent trials, such as rolling a die. Also, kudos to the design team for giving us this type of flexibility in randomizers.

It seems the hoik delay approach will still be necessary when outcomes need to be removed after they are generated the first time, such as randomly drawing and removing a card from a deck.
 
It seems the hoik delay approach will still be necessary when outcomes need to be removed after they are generated the first time, such as randomly drawing and removing a card from a deck.
Let's not give up hope that quickly. I'm sure we'll find a better way - and if it involves constructing a giant randomizer with 2^N total outputs that receives an N-bit integer X and outputs a signal through one of the first X outputs.
 
Let's go back to the non-powers-of-two - alternative approach without hoiks (let's take 20 and 7 as examples): First, we split off any power of two from the number (as if writing it in binary and just taking out one of the bits). Let's go with the largest one, so for 20 that would be 16 and for 7 it's 4. Now we just use a single randomizer with two outcomes and a 16/20 = 4/5 or a 4/7 chance respectively - if it succeeds, we send a signal to a power-of-two-randomizer (16-randomizer or 4-randomizer respectively), otherwise we send one to a randomizer for the rest - for 20, the rest would be a 4-randomizer, for 7 a 3-randomizer which, again, would consist of a 2/3 and then a 1/2 randomizer. Delayers can be added (as early as psosible in the circuit) to make sure the signal comes after the same number of steps, no matter the output - this would lead to any randomizer needing ceil(log2(N)) steps, where N is the number of outputs - or, in simpler terms, X steps, where 2^X is the next larger power of two. No dirty stuff involved and a clearly defined delay.

Also, @ZeroGravitas - stop encouraging people to smoke. It's not good and you know it.
Would you be able to send me a screenshot of this? I was unable to get a clear image in my head after reading it multiple times.
 
Would you be able to send me a screenshot of this? I was unable to get a clear image in my head after reading it multiple times.
Well, I haven't built it, but here's an example flow chart for a 19-randomizer.
Let's break this down to a basic principle for a randomizer with N outputs:
  • If N is 1, we'll just forward the signal to the output (though trivial, this is important).
  • Otherwise, we always have two sub-randomizers:
    • Either N is a power of two (e.g. 8), in which case both sub-randomizers handle half of the outputs (4 each) and there's a 1/2 (or 1:1) chance for either of them;
    • Or N is not a power of two (e.g. 19), so we check for the greatest power of two (let's call it P) smaller than N (16 in this case). Then we use a randomizer where one output has the chance P/N (or P:N-P) (i.e. 16/19 or 16:3 for N = 19), leading to a P-randomizer, with the other output leading to a (N-P)-randomizer.
Each sub-randomizer works exactly the same way, breaking everything up into powers of two until everything's down to 1.
 
Well, I haven't built it, but here's an example flow chart for a 19-randomizer.
Let's break this down to a basic principle for a randomizer with N outputs:
  • If N is 1, we'll just forward the signal to the output (though trivial, this is important).
  • Otherwise, we always have two sub-randomizers:
    • Either N is a power of two (e.g. 8), in which case both sub-randomizers handle half of the outputs (4 each) and there's a 1/2 (or 1:1) chance for either of them;
    • Or N is not a power of two (e.g. 19), so we check for the greatest power of two (let's call it P) smaller than N (16 in this case). Then we use a randomizer where one output has the chance P/N (or P:N-P) (i.e. 16/19 or 16:3 for N = 19), leading to a P-randomizer, with the other output leading to a (N-P)-randomizer.
Each sub-randomizer works exactly the same way, breaking everything up into powers of two until everything's down to 1.
I understand now, thanks.
 
Back
Top Bottom