Hoiktronics - What Is It? [Guide]

Discussion in 'Terraria Guides' started by ZeroGravitas, Dec 30, 2014.

  1. ZeroGravitas

    ZeroGravitas The Destroyer

    [Last Updated: 2015-08-19. Questions/suggestions will help flush out this guide. :)Recommended reading first: Hoik Guide]
    + Introduction:

    Terraria wiring is different to that in real life (and Minecraft). It is activation based, rather than relying on a steady voltage state or continuously applied on/off indicator. These activation events only come from the following: pressure plates, timers (1, 3 or 5 second, after they've been turned on) or switches/levers clicked by a player. These 'switches' are more like buttons really, since they only send an instantaneous pulse, as do plates. There are no other input devices or sensors (as of 1.2.4.1). So making wire devices change what they're doing requires either a player, friendly NPC, statue mob or 'wild' spawned monster to hit a button. I'll call these characters 'actors' for want of a better umbrella term, since they trigger activations.

    Plates send only a single activation when hit by an 'actor', then nothing more until their body has cleared the plate (and then overlapped it again). Actors are only allowed to trigger 1 plate at a time and plates have to be at least 1 tile apart, so this puts a cap on how fast wiring devices can do stuff: the top speed of the actor involved. A former wiring staple, bird engines, top out at ~10.6 activations per second, in line with the bird's top speed in tiles/s. (Up to 37acts/s possible from some mobs via a rainstick configuration.)

    But straight line speed isn't all that interesting in it's possible uses. The path of mobs has to be diverted sometimes in order to make true switches (transistor equivalents) for logic operations. This can, and has, been done with birds, for example. But even birds are clumsy and somewhat unpredictable (although deterministic) in navigating bends. This means that there is a greater need for statues, whereas mobs from a single statue can be distributed around a device far more quickly with hoiktronics.

    'Hoiktronic' is intended to communicate the key use of the 'hoik' glitch (with sloped blocks) to control the movement of NPCs so rapidly and precisely that they become somewhat like big, fat electrons, facilitating rapid digital mechanisms. In even the best designed bird reset towers it take several seconds for a bird to blunder through all the motions, while a reset line (of about the same size and number of resets) takes 16 ticks or less (~1/4 of a second). Similarly, while PowerCosmic's bird powered lookup table for scoreboard display is very efficient, it still takes about 1 second to update, where as the hoiktronic equivalent is done almost too fast to see the change ripple through the segments (8-18ticks total).

    Skeletons are the tallest statue mob, so are best for use in hoiks. This is because the vertical and horizontal jump distance of the hoik glitch is determined by height category of the sprite colliding with the sloped blocks. The height also allows space to insert pressure plates into each hoik step, between, below, or above hoik teeth (depending on hoik type). Happily, skeletons have the same dimensions as players and town NPCs, which is convenient because the same hoiktronic designs will work with any of these. So player can test the design themselves, before letting the little monsters loose all over the place.
    Actors Group Shot.png
    1 player, 10 skeletons max, 21 'town' NPCs, (and up to 15 snow zombies, if you're clever!)
    Note: multiple actors can activate the same plate within the same tick. But each actor is limited to triggering a single plate per tick (leftmost and topmost plate gets priority, in lieu of a simultaneous triggering). This issue is only now relevant due to the speed of hoiks.

    This new wiring paradigm can arguably be divided into further subtypes as follows:

    + Type 1 Hoiktronics - Captive Actors: are held in the hoiktronic logic device, waiting for input. This allows it to respond immediately (same tick) to any input signal. The flip-flops in my first hoiktronic counter operate at up to 60 times per second, i.e. changing state once per game tick. This is effectively a 'synchronous' device, and perhaps the closest you can get to conventional electronics logic in Terraria, since input signals are updated to output every tick.

    Type 1 Hoiktronic counter runs at up to 60Hz.
    Only the flip-flop has been implemented in game, but other types of logic should be possible using a similar setup. These might take 2 ticks, or a little longer to update, at worst. Getting skeletons or NPCs into position can be pretty tricky, so initialisation sequences can be an issue. However the biggest flaw in this approach is that the number of logic devices is limited to the number of actors available in a world simultaneously (max 10 skeletons + max 24 NPCs). So it would be impractical to build computers on this basis.

    + Type 2 Hoiktronics - Travelling Actors: are sent down hoik lines to update logic one step at a time, asynchronously. Actors behave like marbles or billiard balls rolling through a Digi-Comp mechanical computer, tipping levers this way or that, their path shaped by barriers. They are the read/write head. Unlike type 1, this paradigm is far more easily extendible, at only the cost of latency, as a longer run will increase the time it takes to complete a full iteration of logic updates, etc.

    A horizontal binary counter, like one shown above, can count to the age of the universe
    by using a 1s timer as input and being extended to the width of a 1920p screen.

    In many circumstance one can also simply throw in more actors to move matters along quicker. For example, the linear counters in this video tour of my lab can have several skeletons rippling down their length simultaneously, provided they aren't so close they overlap (interfering with each other directly). Separate hoiktronic components could also be run in parallel, provided great care is taken with timing when interfacing them together.

    Extending these devices too far can hit other practical limits of the game: skeletons will spontaneously de-spawn within ~12 seconds when they go off screen (1920p resolution), instantly under certain conditions. At night, off-screen NPCs will immediately teleport to a home too, unless their home is visible. Players are the most reliable of actors, since they only despawn on death and don't (necessarily) try to move around on their own (falling out of alignment for down-hoiks, for example).

    A particularly useful feature, of horizontal hoiks, is that the exact vertical position of an actor during a step depends on whether the previous step had a top (against ceiling), or a bottom (against floor) hoik tooth.This distinction is just enough to make the difference between hitting a pressure plate or clearing it on the next step (diagram below, left). This allows for an unbroken hoik run, of a fixed number of steps, when a series of logic levels are reset (or set). DicemanX's reset mechanism (below right) with the same run time regardless of number of resets required. My more compact reset line (see top of post) is half the size, but more complex with variable execution time, due to optional waist height bottom hoik steps (and only works right to left). This feature has many other potential uses...
    Reset Mechanism Mechanic1 copy.png Diceman Reset Line.jpg

    + Type 3 Hoiktronics - Discrete Components: hoiktronic logic can be packaged up into self contained units, with only wires connecting between (see below). This is more like the old bird powered logic and is limited by the 0.5s input cooldown on spawning statues. To overcome this you could simply chain these discrete devices together with teleporters, output to next input. However, this would then be more of a convoluted type 2 hoikronics, with instantaneously fast, wired teleporter routes replacing hoik connection lines. The extra wiring for the teleporter interlinks may prove prohibitive in (parts of) complex builds, and could lead to extra failure modes, with actors being accidentally back-teleported when multiple actors are in use.
    Universal Logic Gate.jpg
    DicemanX's "Universal Logic Gate" (illustrative only).

    + Hoiktronic Computing:

    Teleporters can be used to instantly mount a spawned skeleton onton a hoik, without having to wait for them to clear the statue on foot. Teleporters are also particularly useful for exit points that would be difficult to install within a complex mechanism using hoik-only routing (since we're stuck in 2 dimensions here). DicemanX's expandable computer is a good example of this, with many teleporters all linked up to the same exit, to clear skeletons out when they're finished with. It's also a execution of a relatively powerful design for doing mathematical operations on binary numbers.
    DicemanX's Extendible Computer.png
    By representing binary number stings using the actuated states of hoik teeth, we have started to make rudimentary contraptions that can perform simple mathematical operations on these numbers: addition, multiplication (currently via repeated addition), subtraction (via complement and addition), division (via repeated subtraction), etc. These are the basics of computation. There's still a long way to go to make a more general purpose (programmable) computer. It's unclear how far we will be able to extend this technique, given various issues (particularly de-spawning), but there's a lot of things left to invent and uses to put existing developments to.

    + Issues:

    Multiplayer
    - skeletons and NPCs seem to behave entirely correctly, although they may fail to render for long lengths of hoik, so machines may seem to be working by entirely invisible magic. Players do not work correctly in devices like the counters shown in the type 2 hoiktronics video. Wiring events seem to take several ticks to get updated, while block collisions continue to update, hence player will not be diverted correctly by instantaneous actuation of blocks. Alternative server software has not been tested.

    Down Hoiks - are generally problematic, because they are sensitive to the actor's precise horizontal positioning (must be right up against the thick side of the sloped teeth). Players can easily fall out after walking into a down mount, and lengths over 6-7 consecutive steps are unsuitable for use with skeletons and NPCs are their continual movement will cause them to get jammed.

    + 1.3 Update Changes (2015-07-30):
    • There is one more NPC available now (the Tax Collector [​IMG] ).
    • NPC behaviour has also been slightly modified, @DicemanX says this has broken parts of many of his hoiktronics builds, which will need tweaking.
    • Mob behaviour looks largely unaffected, so far.
    • Hoik physics itself seems otherwise unchanged. (However, trap timings have been tweaked, which may affect related builds.)
    • Target Dummies look set to revolutionise hoiktronics since their 'ghosts' can drop or be teleported away from the fixed standing position of their sprite! It appears this will add an additional 100 very well behaved size 3 (player/skeleton sized) actors.
      eUICZgW.jpg Credit to @z26 here in T-MEC.
    + Relevant Links:
     
    Last edited: Aug 19, 2015
  2. ZeroGravitas

    ZeroGravitas The Destroyer

    Reserved for possible media embedding expansion.
     
  3. DicemanX

    DicemanX Brain of Cthulhu

    Reserved for commentary.
     
  4. DiabeticBacon.exe

    DiabeticBacon.exe Skeletron Prime

    I dont understand anything of it xD
     
  5. DicemanX

    DicemanX Brain of Cthulhu

    There's some pretty advanced stuff presented in this guide, so the best way to get started is to look at ZeroGravitas' initial hoik guide to understand the basics of hoiks:

    http://forums.terraria.org/index.ph...c-etc-transport-using-only-sloped-tiles.1656/

    It's also a good idea to try to build some of the hoiks presented in this guide to get a sense of how they work. Once basic hoiking is understood, the next step is to figure out how branching pathways (that dictate which way a player or NPC will travel) work, as that is the basis behind most of the contraptions presented in the opening post. One way to do that is to download the worlds ZeroGravitas and I have made available, and try operating some of the contraptions yourself (most are pretty easy to operate) and observe how the NPCs behave inside the hoiks.

    Once the fundamentals are grasped, it will become a lot easier to figure out how some of the more complicated contraptions work, since they are based on some basic repeating elements.
     
  6. randomterrarian42

    randomterrarian42 Terrarian

    Now we'll have to wait to the point when you create an in-game computer capable of connecting to internet, download terraria, and play terraria in terraria. And terraria in terraria in terraria. And terraria in terraria in terraria in terraria. And...
     
  7. ZeroGravitas

    ZeroGravitas The Destroyer

    It's funny how prevalent this 'loopy' recurrence meme is, in replies to our hoiktronic ALUs... I'd blame Douglas Hofstader, but I'm sure it's more general.

    Be interesting for someone to would out how many orders of magnitude slower Terraria would run on a Turing-ish machine built in game... Ignoring the impossibility of fitting it's entire 700Mb (or so) memory footprint into the storage capacity of a world's blocks, our machines so far do (very) roughly 1 'calculation' every 10 seconds (ish). While the game uses X% of a processor that can do hundreds of millions per second...
     
  8. randomterrarian42

    randomterrarian42 Terrarian

    Use water cooling and overclock. like, yeah....use a bucket to stop heat and cheat engine to make the game faster :p
     
  9. ZeroGravitas

    ZeroGravitas The Destroyer

    Added the following section, since there don't seem enough changes in the 1.3 update to warrant a re-write. Please let me know of any other significant things to include. :)