TransWikia.com

Is it possible to activate a single random wire in Terraria?

Arqade Asked by Wrigglenite on August 4, 2020

I’ve been trying to create a system to instantly activate a single random wire out of many, to use for teleporters or traps, but all my attempts always activate more than one wire. I’m imagining some wiring mechanism with one input wire, many output wires, and each time the input wire is activated, one (and only one) of the output wires, selected randomly, will instantly activate.

Is something like this possible?

One Answer

Depending on what "many" and "instantly" mean, something like this is possible.

Here's a setup that can activate exactly one of the two announcement boxes in it in what I expect is 2-3 ticks from when the lever is pulled, although I am not an expert on Terraria's logic gate timings. It could be chained together to give more outputs, although each layer would slow down the process slightly, giving an overall delay based on the logarithm of the number of outputs (or linear with the number of layers).

Diagram Without Wires Diagram With Wires

The important materials, besides the signal source and the outputs, are an XOR Logic Gate, 2 additional Logic Gates of any type to be used as Faulty Gates, 2 Faulty Logic Gate Lamps, at least 5 normal Logic Gate Lamps, and wires.

These are assembled into:

  • A faulty logic gate that has 1 On Lamp and its Faulty Lamp.
  • A faulty logic gate that has 1 On Lamp and 1 Off Lamp, and possibly more if you want to weight the chances towards one side, plus of course its Faulty Lamp.
  • An XOR gate that has two lamps attached. The lamp states do not matter.

The faulty logic gate with three or more lamps (counting the Faulty Lamp) is the source of randomness. When the Faulty Lamp is activated by the red wire, it has a chance of sending a signal to the yellow wire. If the yellow wire signals, it will trigger the announcement box on the left and prevent the XOR on the right from sending a signal. If the yellow wire does not signal, the green wire from the unconditional faulty gate will trigger the XOR.

The unconditional faulty logic gate, also triggered by the red wire, is needed to line up the timing of the wires leading to the two lamps on the XOR gate. If the red wire from the lever led directly to the top lamp, it would result in the XOR gate always immediately signalling the blue wire whenever the red wire activates, before the yellow wire has a chance to activate.

The random source could be weighted either towards the left output with more ON lamps or the right output with more OFF lamps. If you wanted 3 outputs with equal chances, you could set up a 2/3 weighting on the left, then build the 50/50 setup below it, with the left output of the first layer acting as the input of the second layer.

As long as you don't want more than 8-ish outputs, this style of setup should feel reasonably instant to a human.

Answered by Joseph Kendall on August 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP