【Wikia解说】0刻脉冲

9-15 4,693 views

作者:nenn(百度id:正正正正正好

注1:本文中部分内容为对Minecraft技术wikia的直接翻译,译者为本人nenn。

蓝色框中的内容为原文,绿色框中的内容为参考译文,橙色框中的内容为译者注释。翻译原文的来源为:

http://technical-minecraft.wikia.com/wiki/0-tick_pulses

注2:本文中的翻译部分为学习交流用途而非商业用途,不声明版权,翻译内容仅供参考和交流。其余内容版权为Redstone Machinery Communication 红石机械交流促进会 所有。欢迎喜欢的读者注明本文链接并转载。当然,我们不介意明月庄主(优酷账号:明月庄主moon,百度id:明月庄主moon,Minecraft游戏名:moonboos)在未标明原链接的情况下使用本文中的翻译和讲解,因为已经见怪不怪了(滑稽)。


A 0-tick pulse is a redstone pulse, that turns on and off within one single game tick. This is possible, because block updates are calculated one at a time in a certain order, the block-update-order, even if they happen in the same game tick. To understand 0 tick technology one has to first acknowledge, that just because two things happen in the same game tick, they don’t happen at once. There’s always one thing happening first, and one thing happening second.
0刻脉冲即在一个游戏刻内激活和退激活的红石脉冲信号。即使在同一个游戏刻内,每一次方块更新也都遵循特定的顺序,即“方块更新顺序”,所以这种0刻脉冲是完全可能的。如果要理解0刻脉冲技术,那么你首先需要认可这一点:恰恰由于两个事件发生在同一游戏刻内,所以它们不会同时发生。总有一个发生在前,另一个发生在后。
这一段我需要强调三个概念,一为游戏刻,二为脉冲信号,三为“0刻”究竟指什么。

一。

简单来说,游戏刻就是Minecraft进行更新的最小单位时间间隔,1游戏刻=0.05秒。游戏刻英语表达为“game tick”,常简称“gt”,这是为了与红石电路中常用的红石刻(1红石刻=2游戏刻=0.1秒,常简称“t”)相区分。

二。

脉冲信号表达的是一种局部的信号概念。多数初级玩家口中常称作的脉冲并非脉冲原本的含义。虽然时钟信号也是一种周期性的脉冲信号,但是脉冲本身是一个大类的概念,把时钟信号称作脉冲极其容易造成误解。举个例子类比,你可以说人是一种灵长类动物,但是你不能说灵长类动物就是人。因为灵长类动物还包括多种猩猩、猴子等种类。类似的,你可以把时钟信号称作脉冲信号,但是当设计更复杂的时序电路时,这样的表达会造成误解,因为你无法区分单脉冲和周期性脉冲,也无法区分一般的周期性脉冲和时钟信号。根据常用习惯,一般脉冲的说法多指单脉冲,而非多数初级玩家所指的时钟信号。关于脉冲的详细概念,可以参考本人写的另一个帖子:【Confidential】短脉冲的实现及应用。其中详细介绍了脉冲的基本概念,建议先阅读该贴,不然会对后文的理解造成麻烦。

三。

0刻脉冲是指脉冲的长度(也可称脉冲宽度)为0游戏刻。也就是说,这个脉冲的两个边沿信号在同一个游戏刻内。但关于这两个边沿究竟在哪一个游戏刻,并不是我们关心的问题。因此这里的解释着重在强调这一点:0刻脉冲不是说在拉下拉杆的瞬间放出一个脉冲,而是指这个脉冲在时间上的展开长度是0游戏刻,也就是转瞬即逝。

Problems with the block update order


For many blocks, the block update order will be location dependent, and therefore appear random to most human beings. But there are certain redstone triggered events, that reliably wait for almost all other blocks to update first, which can be used to compensate for the otherwise random update order. However it needs to be mentioned, that sometimes things in 0 tick technology can appear completely nonsensical and weird, because of the constant randomness introduced by the update order.

关于方块更新顺序的麻烦问题


对多种方块来说,方块更新的顺序取决于其所在位置,所以对于大部分人来说,这个顺序呈现随机性。但游戏内有着确定的红石触发事件,其定会待所有其他方块先更新。这个机制将用于补偿其他的随机更新顺序。然而需要指出的是,有时0刻脉冲技术中的事物将变得完全无意义或者怪诞,这是因为由于更新顺序引入的不随时间变化(此处constant有永恒之意,故译作不随时间发生变化)的随机性。

这也就是在《【活塞门基础】递推递归活塞组的实现及其通式》9楼等处多次提及的:对游戏本身来说,这个随机随空间分布随机,随时间分布则完全确定。也就是说,当你将同样的电路放置在不同位置时,几个同一游戏刻内的事件顺序将可能发生变化。但只要电路位置不发生变化,这些事件的顺序总是如此,不会变化。

 

Why repeaters and comparators can be useful


Repeaters and comparators wait for almost all other redstone components to update first before they activate themselves. Additionally, comparators will always wait for all repeaters to update. Redstone components that wait a long time before updating are very helpful when making 0 tick pulse based contraptions. With repeaters and comparators the following 0 tick generator can be made:


Blue is input. Red block gets a 0 tick pulse output. This 0 tick generator was first discovered by test137e29.

为何红石中继器和红石比较器非常有用?


红石中继器和红石比较器会待几乎所有其他红石元件先更新之后,他们才会被激活。另外,红石比较器将总是待所有的红石中继器先更新后才更新。使用特殊装置产生0刻脉冲时,在元件更新前需要等待很长时间的红石元件非常有用。带有红石中继器和红石比较器的0刻脉冲发生器就可以这样制作:

蓝色方块为输入端,红色方块为0刻脉冲输出端。0刻脉冲发生器最早由test137e29发现。

红石中继器总是先于红石比较器更新。

This 0 tick generator works in the following manner. When the lever is switched on, there will first be a 1 tick delay from both the repeater and the comparator. After that 1 tick delay the repeater and the comparator activate in the same game tick: First the repeater will update, because repeaters always activate before comparators. The output redstone will be powered by the repeater and anything connected to the red output block will also activate. The comparator will wait with updating until all the output redstone has been activated and the technical blocks connected to the output have also been updated. Only after the output redstone and the technical blocks connected to the output have been updated, the comparator will activate, and activate a piston, which will interrupt the redstone signal. Therefore the redstone dust connected to the output will have been activated and deactivated within 1 game tick. And almost all technical blocks connected to the redstone output will have had enough time to update, because comparators wait for such a long time in the update order.
该0刻脉冲发生器的工作方式如下。拉杆拉下时,红石中继器和红石比较器都先会有1红石刻的延时。这1刻延时后,它们会在同一个游戏刻内激活:红石中继器会首先更新,这是因为它总是先于红石比较器被激活。输出端的红石粉会被红石中继器供能,而与红色输出端方块相连的任何元件都会被激活。等到输出端的所有红石被激活且与输出端相连的所有技术方块被更新后,红石比较器才会更新。只有当输出的红石和技术方块更新完后,红石比较器才会被激活,然后激活活塞阻断红石信号。所以与输出端相连的红石粉将被激活,并在同一个游戏刻内退激活。几乎所有与红石输出端相连的技术方块有足够的时间去更新,这是因为红石比较器按照更新顺序会等待很久。

红石中继器总是先于红石比较器更新,正是基于这一点,在同一个游戏刻内才能形成固定的更新顺序。如果将这里的一个红石中继器和一个红石比较器换成两个红石中继器或者两个红石比较器,那么更新顺序就会表现出随空间变化的随机特点,无法形成稳定的可靠的0刻脉冲发生器方案。例如下图的测试结果。

Chaining repeaters and comparators

As previously mentioned, in each game tick first all repeaters will update, and afterwards all comparators will update. However there’s still the following question: If two repeaters update within the same game tick, which one updates first? The answer to that question is: The repeater that first recieved its input one r-tick ago, will also output first. This makes repeaters and comparators even more useful, since the following things can be done:


If the lever on the picture on the right is flicked, the iron blocks, and technical blocks connected to them will update in the order, that is numerically shown on the picture. The blocks 1 and 2, will of course update before 3 and 4, because there are repeaters activating them, instead of comparators. However it is also guaranteed, that block 1 will activate before block 2, because the repeater that activates block 1 will be activated before the repeater that activates block 2, since the first repeater gets activated by a repeater, while the second repeater gets activated by a comparator. For similar reasons block 3 is also guaranteed to activate before block 4. It is even possible to make longer chains of repeaters and comparators to get more than just 4 updates in a reliable order.

将红石中继器和红石比较器串接起来

恰如前文所述,每个游戏刻内所有的红石中继器先进行更新,然后所有的红石比较器才会更新。然而还有一个问题:如果两个中继器在同一个游戏刻内更新,那么哪一个会先更新呢?这个问题的答案是:先接收到随机刻输入的红石中继器将先进行输出。这导致红石中继器和红石比较器更有应用上的意义,因为可以实现:

如果拉动图中的拉杆,那么与拉杆相连的铁块和技术方块将会按图中数字的顺序更新。方块1和2,将毫无疑问先于3和4更新,这是因为激活它们的是红石中继器而不是红石比较器。同样可以保证的是,方块1将会先于方块2激活,这又是因为激活方块1的红石中继器将先于激活方块2的。1这一路的第一个红石中继器被红石中继器激活,而2这一路的第一个红石中继器被红石比较器激活。类似的原因,方块3同样一定会先于方块4线更新。制作更长的红石中继器和红石比较器串将会得到超过4个有着可靠顺序的更新。

一言以蔽之,红石中继器先于红石比较器先得到更新,这种机制可以用来在同一游戏刻内形成可靠的更新顺序。这就是所谓的红石电路中微观延时的体现。其区别于大于等于1个游戏刻的宏观延时,微观延时往往不能通过一般的动画和声音顺序来分辨,其职能体现在元件之间的相互作用。
关于微观延时的更多信息,可以参考下面的连接:
【RMC精选】黑石原理及技术
【黑石】关于黑石原理的一些重要实验
【元件库】精密时序比较器——关于时序精密描述的实现
【元件库】精密脉冲边沿比较器
Why retracting Pistons can be useful


When a piston is extended and gets deactivated, it does not instantly retract when it updates. When the piston first gets updated, it will transform into a glitchy state, which looks like this:

The piston will then wait for other blocks to update first, before the piston updates a second time, which will convert it to block 36, and which will also convert the block in front of the piston to block 36, if the piston is sticky. The 2 updates will happen within 1 game tick, but while the first update happens relatively early in the update order, the second update happens quite late and most other blocks including repeaters and comparators will update, before the second update of the piston retraction happens (This needs to be verified, even though Myrens is pretty sure, that this is correct, since 90% of his 0 tick technology is based on this assumption, and it works)

为何收回的活塞有应用上的意义


当一个活塞伸长且退激活时,他不会在更新时立即收回。当活塞第一次更新时,它会转换到一种非常规态,看起来就像这样:

在活塞第二次更新前,活塞会待其他方块先更新。这个过程中,活塞会转变为36号方块,而如果活塞是粘性活塞,那么它之前的方块也将会为36号方块。这两次更新会在同一个游戏刻内发生,但第一次更新在更新序列中相对靠前,第二次活塞收回时的更新则较晚,晚于其他大部分方块包括红石中继器和红石比较器的更新。(虽然Myrens非常确信这种说法很正确,因为他90%的0刻技术基于该假设,且都与其符合地很好,但这一点需要进一步的证实。)

36号方块即移动的活塞臂,是一种技术性方块。该方块用于显示活塞臂从活塞基底伸出的动画。
Since it takes such a long time, in terms of 0 tick delays, for a piston to retract, almost all piston based 0 tick pulse generators use piston retractions to interrupt a redstone signal. Examples would be the following 0 tick pulse generators:

A 0 tick pulse generator, that turns the signal off using a piston retraction. When the green wool (input) gets powered, after 1 redstone tick of delay, the red wool (output) recieves a 0 tick pulse.
就0刻的延时而言,因为活塞的收回需要相当长的时间,所以几乎所有基于0刻脉冲发生器都使用活塞的收回来阻断红石信号。下面的0刻脉冲发生器就是个例子:

0刻脉冲发生器使用活塞的收回来切断信号。绿色羊毛(输入端)被充能后经过1红石刻的延时,红色羊毛(输出端)会接收到0刻脉冲。
In this 0 tick pulse generator the torch will turn off causing the piston to get into a glitchy state. The block in front of the piston will still be solid, while the piston is in the glitchy state. The repeater will then emit a redstone signal through the solid block to the output. The output redstone and most technical blocks connected to it will activate, while the piston is waiting in the glitchy state. Once everything connected to the output has activated the piston will update a second time, converting the block into block 36 and interrupting the redstone signal.
在这个0刻脉冲发生器方案中,红石火把的熄灭会导致活塞转为非常规态。活塞前的方块将依然维持非透明方块的原状,而活塞却转为非常规态。红石中继器随后通过这个非透明方块发出一个红石信号,直接送到输出端。输出端的红石线以及与其相连的大部分的技术性方块都会被激活,而活塞依旧停留在非常规态。一旦与输出端相连的所有元件被激活,活塞才会再次更新,将方块转化为36号方块并阻断红石信号。
In this 0 tick pulse generator the piston on top will first convert the redstone block into block 36. Unlike piston retractions, piston pushing happens relatively early in the block update order. After the redstone block is converted into block 36, the piston at the bottom will update and get into a glitchy state. Now all technical blocks connected to a potential output, will have time to update. After everything else has updated the piston at the bottom will start retracting the stone brick block, interrupting the signal. The 0 tick pulse part is now already complete. This contraption continues doing some other stuff, but that isn´t relevant to the 0 tick pulse generation.
These 0 tick pulse generators are widely used, because they generate comparatively long 0 tick pulses. The longer a 0 tick pulse is, the more technical blocks will react to it in a direction and location-independent way.

This is a pulse generator that directly powers a block, first shown by Defanive on YouTube. It also cuts the signal using a piston retraction, causing the 0 tick pulse to be long enough to make all technical blocks react to it, independent of direction or position.
该0刻脉冲发生器方案中,顶部的活塞会首先红石块转变为36号方块。与收回不同,活塞的伸长在方块更新序列中相对较早。红石块转变为36号方块以后,底部的活塞将会更新并转变为非常规态。此时,所有和潜在输出端相连的技术性方块都会更新。等这些都进行了更新以后,底部的活塞才会开始收回石砖,阻断信号。0刻脉冲的电路部分到此为止就已经完成了。这个神奇的装置还可以有其他的功能,但是那些功能与0刻脉冲无关。
那些0刻脉冲发生器现在已被广泛应用,这是因为他们产生相对较长的0刻脉冲。长0刻脉冲表示在某个单独的方向和位置时会有更多的技术性方块对其响应。

这就是一个直接给方块供能的脉冲发生器,最早由Defanive在Youtube上展示。其同样使用活塞的收回来切断信号,这产生了一个足够长的0刻脉冲,以至于任何位置任何朝向的技术方块都能够对其响应。
不要说你不认识Defanive是谁。如果不知道,可以看看这个:《直播,MC 1.3 原版生存
Chaining (retracting) pistons

Multiple zero tick pulse generators may be chained, and if the generator uses redstone blocks, the signal may be taken using redstone dust. This was first shown by pi314159265358978.

连接(收回的)活塞串

多个0刻脉冲发生器可以互相串接起来,如果它们用到红石块,那么0刻脉冲信号就可以被红石粉获取。这个现象最早由pi314159265358978揭示。
Test137e29’s weird piston effects


While a piston is in its glitchy state, the piston base is movable. This can be used to create the following, unexpected effects.
Pulling an extended piston:
If the lever on the picture is switched off, the piston on the left will be able to pull the piston on the right, even though the piston on the right is extended, and is supposed to be unmovable. This works in the following way:

When the lever is switched off, there will first be a one r-tick delay from the repeater and the comparator, before anything else happens. Then within one game tick the following updates happen:

First the repeater will turn off, because repeaters always update before comparators. This will cause the piston on the left to be converted into its glitchy state.

After that the comparator will turn off and the piston on the right will get converted into its glitchy state.

Now, since there’s nothing else to update, the pistons, who are in the glitchy state, will start retracting. However, since the piston on the left transformed into its glitchy state first, it will also retract first (it is really surprising how inuitive and reliable the update order of piston retractions is). When the piston on the left retracts, it will try to pull the piston on the right, which is still in its glitchy state. Since the piston base of a piston in a glitchy state is movable, the piston on the left will successfully pull the piston on the right.

Test137e29的非常规活塞效应


当活塞处于非常规态,活塞的基底就可以移动。这一点可以用来形成下述的非常规效应。
拉动一个已经伸长的活塞:
如果图中的拉杆拉起切断电源,那么即使右侧的活塞已经伸长,也理应不可移动,左边的活塞也依然可以拉动右侧的活塞。这可以通过下面的方法来做到:

拉杆拉起切断电源时,在任何现象发生之前,红石中继器和红石比较器首先会有一个随机刻延时。在之后的一个游戏刻内则会发生下列更新:

首先,红石中继器会退激活,这是因为它总是先于红石比较器更新。这会导致左侧活塞转变为非常规态。

之后,红石比较器将会退激活,右侧的活塞将会转变为非常规态。

此时,由于已经没有元件需要更新,所以还处在非常规态的活塞将开始收回。然而,因为左侧的活塞先转变为非常规态,因此它也将先收回(活塞收回的更新顺序与直觉的吻合及其可靠程度都令人惊叹)。左侧的活塞收回时,它将试图拉动右侧的还处在非常规态的活塞。因为处于非常规态的活塞基底是可移动的,所以左侧的活塞将会成功拉动右侧右侧的活塞。

Pushing a piston, while it extends:
If a piston is given a zero-tick-pulse, the piston will be in a state very similar to the glitchy state, after the zero tick pulse turned off. The only difference will be, that there is not a piston head in front of him, but the block 36 of an extending piston head. In this other glitchy state, the piston base is also movable. The contraption on the right will use this to push and extend a piston at the same time. This results in a block 36 of an extending piston head, that is not connected to any piston. The block 36 will ignore the fact, that there is no piston base, but after 3 game ticks, once the block 36 turns into a piston head, the piston head will realize, that it has no piston base, and it will delete itself.

The comparator in the middle is actually unnecessary with this precise setup.

当活塞伸长时推动活塞:
如果活塞接收到一个0刻脉冲,那么在0刻脉冲结束后,它将会转变为一个很接近非常规态的新状态。这个状态和非常规态唯一的区别在于,其前方没有活塞臂,而是活塞臂的36号方块。在这种其他的非常规态下,这个活塞同样可以被移动。图中的装置就可以在活塞伸长的同时让它被推动。这造成了一个没有和任何活塞相连的伸长活塞臂的36号方块。36号方块将会无视实际情况,即无视其后方没有活塞的基底,但是3个游戏刻以后,一旦一个36号方块转变为活塞臂,这个活塞臂将会意识到其本身后方没有活塞基底,然后游戏将删除这个活塞臂。。

中间的红石比较器对于这个精密的装置来说是不必要的。

Pistons with multiple heads:
If a piston is moved, while it extends, and another piston is pushed in its position in less than 3 game ticks, then the piston head of the first piston will not delete itself, because it recognizes that it is connected to a piston base, without checking, whether that piston is facing in the same direction as the piston head. This means that one may get many strange configurations, such as pistons with multiple heads.

Creating a piston with two heads using comparator-repeater timings.

多臂活塞:
如果活塞被移动,然后伸出,其他的活塞在少于3游戏刻的时间内被推动到这个活塞的位置,那么第一个活塞的活塞臂就不会被删除,这是因为其意识到其与活塞的基底相连,而不会检查活塞是否与活塞臂朝向相同。这意味着我们可以得到许多奇怪的结构,比如多臂活塞。

用红石中继器和红石比较器组成的时序来创造出一个有两个活塞臂的活塞。

How Pistons react to 0 tick pulses


If a sticky piston gets converted from its glitchy state to its retracting state, while a block 36 that resulted out of a piston extension (and not retraction) is in front of the sticky piston, and if that block 36 moves in the direction the sticky piston is facing, then that block 36 will be instantly converted into its block form at its destination. What this practically means is, that if a sticky piston recieves a 1 tick pulse, the block in front of its face will finish its extension after one tick, instead of the usual 1.5 redstone ticks. What this means in relation to 0 tick pulses is, that if a sticky piston recieves a 0 tick pulses, the block in front of its face will finish its extension in 0 ticks, meaning it gets instnatly teleported. However this only applies to sticky pistons. If a normal piston recieves a 0 tick pulse, the block in front of its face will need 1.5 redstone ticks to travel to the next block.

活塞对0刻脉冲如何响应


如果一个粘性活塞从非常规态转变为它的收回状态,此时活塞伸长(而不是收回)造成的36号方块在粘性活塞前方,且那个36号方块运动的方向与粘性活塞的朝向相同,那么那个36号方块就会立刻在其最后被推到的位置处转化为方块。这意味着,如果一个粘性活塞接收到一个1刻脉冲,其前方的方块将会在1红石刻后完成推动,而不是平时的1.5红石刻。这和0刻脉冲的关系就在于,如果一个粘性活塞接收到一个0刻脉冲,那么其前方的方块将会在0游戏刻内完成推动,这意味着这个方块被瞬移了。然而,这只适用于粘性活塞。如果一个普通活塞接收到一个0刻脉冲,那么其前方的方块依然需要1.5红石刻完成推动。

特别感谢:

好时(百度id:Hershey4)为搭建官网做出的巨大贡献。

chyx(百度id:让他该人士说)推荐Wikia。

RMC平台上参与讨论的各位。

评论已经关闭。