Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement

Template:Mcrs diagrams

Disambig gray  本文章介绍的是需要复杂的红石电路进行组合建造的机械装置。关于进阶红石电路,请见“红石电路”。关于适用于初学者的红石电路教程,请见“教程/初级红石电路”。

红石电路与现实生活中的数字电路(基于布尔逻辑代数)基本可以等同看待。如果您熟悉高等教育中的数字电路与初等计算机科学的知识的话,本篇目对您来说将较为容易理解。

计算机

在Minecraft中,一些游戏内的系统在计算机科学中与图灵机等价——也就是说这样您可以建构信息处理的装置。这些系统包括:水,沙子,矿车,活塞与红石。

这些系统中只有红石是特别为信息处理而设计的,主要以红石信号的方式来表示。

红石与电力类似,具有高适应性与较快的切换速度。就像在现实世界中电力取代了蒸汽动力成为高科技的基石一样,前述的这些特性使红石力压其他机械系统,成为Minecraft中最具有科技含量的部分。

现代数字电路与红石工程在复杂信息处理的应用时。都被简化为抽象的从基本到复杂的多层次结构。

第一层是最基本的组件:红石粉、红石火把、红石中继器、活塞、按钮、拉杆与压力板等所有与红石信号相关的方块。

第二层是二进制逻辑门;他们是能够处理有限位(一般是1-3位)的混合装置。

第三层是由逻辑门组合而成的高阶组件。这些组件用于处理模式化的位数据,一般能够将其编码为更加易读的数字。例如数学加法器,组合锁具,寄存器等。

第四层,也是最后一层,是由一系列的高阶组件组合成的功能型计算机系统,通常能够在不需要人工维护的情况下处理任意数据。

8-bit Register Page (J400 series)

一个8位寄存器,属于第三层结构


半加器

半加器

逻辑门:同或,蕴含

红石火把数量:12

红石粉数量:7

方块数量:19

尺寸:5X4X4

这个半加器能够输出两个一位二进制数的和。结果位输出到输出端S(英文Sum,加法和之意)。如果两个数字都是1,那么会产生进位1到输出端C(Carry,进位之意)(C会变为0)。这个半加器可以被修改为具有同相输出的C端,但图中这种结构在全加器链中可以照搬。

注:由于红石线的新特性,本结构已经失效!为了应急,您可以先使用下面的全加器,只要不使用C输入端即可。

全加器(1位)

全加器(1位加法器)

逻辑门:同或(2),蕴含,非,或,与

红石火把数量:16

红石粉数量:32

方块数量:48

尺寸:从上到下6X12X5,包括输入/输出端。

这个全加器能够将两个一位二进制数与前一个加法器的进位C相加(事实上是C而不是C,第一层的左下部),产生一个和(S端)和进位(事实上是C而不是C)。

如果要改造为减法器,把其中一个二进制输入取反(第一个或第二个数)即可。如果输入被取反,输出也是反向的。在现实世界中的计算机里,二进制带符号数的第一位(也被称为“标志位”)决定了该二进制数的正负,如果你把这个特性(应用相同的反相规则)引入,你就可以得知该数字是负数,还仅仅只是一个较大的数字。

当使用上述的逻辑门时,注意输入与输出,您可能会对为什么这里使用了如此多的反相信号而不是同相信号有疑问。这个全加器使用了比异或门更能实现压缩的同或门,同理,蕴含门比与门更为压缩。因此如果您想压缩全加器的体积,必须使用反相信号。如果用能够表示2层方格的符号来表示,图像将十分复杂,因此我们将每一层都单独用图表表示了出来,而且也方便您分层次地建造。

活塞全加器

1位活塞全加器

2位活塞全加器

红石火把数量:3

粘性活塞数量:2

红石中继器数量:8

红石粉数量:16

方块数量:7

交替全加器

全加器

进位输入与输出端对称,这样您能够方便的压缩并组合多个这样的单元。

红石火把数量:14

红石线数量:15

尺寸:5x6x3

4位加法器

4位加法器

注意!重要性最低的那一位数就是图表中的最左边那位(即“个位”)。这里之所以标明,是为了向您清楚地说明全加器比起半加器的功能优势——半加器无法处理比其低一数位的进位。如果您想依据一般的使用习惯把个位放在右边,那么将图表左右镜像处理即可。

注:由于红石线的新特性,本结构的个位部分的半加器已经失效!为了应急,您可以先使用全加器,只要不使用C输入端即可。

逻辑门:同或(7),蕴含(4),非(4),或(3),与(3)

红石火把数量:56

红石粉数量:108

方块数量:164

尺寸:23X12X5

这个加法器能够将两个四位二进制数相加(A与B),产生每一位数的和(S)与整个和的进位(C,相当于第五位)。和的位数顺序与加数的顺序相同,这也就是说,最左侧的S是和的最低位。这个4位加法器仅仅是一个全加器链的示例,您可以通过同样的构造来建造具有更多位数加法或减法能力的计算单元。

逻辑单元(2-4译码器)

在电路中,有时候您可能需要建造能够依据输入来选择输出的逻辑单元。这样的逻辑单元能够用于更复杂的电路中,比如说算术逻辑单元(ALU)。下面介绍的逻辑单元又被称为2-4译码器。

这是一个2位逻辑单元,依输入不同可以有4种状态。

Logic unit

输出端在最上面一行,依照11、00、01、10的顺序排列(输入端顺序为上侧的是第一位,下侧第二位)。

下面是另一种采用格雷码的简化版本。输出端为顶部那行末端的红石火把。本设计能够被扩展到任意位,但会受到电路延时的限制。相对地,输出排序为11、01、00、10。

Logic unit 3

二进制转换为八进制(3-8译码器)

3bit Implies

3位二进制转换为1位八进制

这个装置是一系列逻辑门的组合,分为8部分。当组合起来时能够将一个3位二进制数输入转换为一位八进制数输出(未编码状态,所以输出端数量与进制数相同),功能等同于3-8译码器。由于其最大占地面积不过5x5x3,所以有很强的适应性。

右图的每一部分都可以将输入端连接到共同的输入源,但建议您在每一个输入端都加一个反相器以使在该电路与其他电路协同工作时,输入端保持独立性。

某些部分也可以作为三态缓冲器使用,或至少您能够方便地将其改造为三态缓冲器。

下表与右上图的8部分一一对应。

对应八进制数字 0 1 2 3 4 5 6 7
尺寸 5x3x2 5x3x3 5x5x3 5x5x3 5X3X3 5x4x3 5x5x3 5x5x3
红石火把数量 1 2 2 3 2 3 3 4
红石粉数量 7 7 12 10 7 7 10 10

二进制转换为十进制/十六进制(4-10或4-16译码器)

4bit Implies

4位二进制转换为十进制/十六进制

这个装置是一系列逻辑门的组合,分为10或16部分。当组合起来时能够将一个4位二进制数输入转换为一位十进制或十六进制数输出(未编码状态,所以输出端数量与进制数相同),功能等同于4-10或4-16译码器。由于其最大占地面积不过3x5x2,所以有很强的适应性。

与上一章节的3-8译码器类似,右图的每一部分都可以将输入端连接到共同的输入源,但建议您在每一个输入端都加一个反相器以使在该电路与其他电路协同工作时,输入端保持独立性。

右图的右下角是一个说明性质的图例,图表中列出的16个部分的输入端皆按此逆时针顺序排列。

对应十进制/十六进制数字 0 1 2 3 4 5 6 7 8 9 A B C D E F
尺寸 3x3x2 3x4x2 3x4x2 3x4x2 3x4x2 3x5x2 3x5x2 3x5x2 3x4x2 3x5x2 3x5x2 3x5x2 3x5x2 3x5x2 3x5x2 3x5x2
红石火把数量 1 2 2 3 2 3 3 4 2 3 3 4 3 4 4 5
红石粉数量 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

十六进制转换为二进制(16-4编码器)

您也可以将一个十六进制信号转换为一个4位二进制信号。与前面不同的是,您不再需要除了或门之外的任何逻辑门了——因此您只需要分析各个输入端与哪几个输出端的对应关系,然后直接用红石线连过去。需要注意的是,为了防止不同输入端连线的互相干扰,在最终连到输出端之前您需要用连续的两个非门或是中继器来互相隔离;您也可以选择在一堆连向某一输出端的红石线末端用最简单的输入隔离型或门(参见红石电路条目的或门设计方案B或C)。在最终投入使用前请先测试以保证不会出错。


下面是十六进制与对应二进制的列表:

十六进制数 0 1 2 3 4 5 6 7 8 9 A B C D E F
第4位 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
第3位 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
第2位 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
第1位 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

如果您想得到一个八进制转二进制的8-3编码器,在本机构基础上剥离第四位输出与前八位输入即可。

示例-顺序敏感的3位十进制数密码锁

Door Lock Key

一个对顺序敏感的3位十进制数密码锁逻辑图

右侧的示例采用了ORs(符号为>=1)、异或门 (符号为=)、 RS或非锁存器(符号为SR)和一些延迟器(符号为dt*)。依个人喜好,我采用了同或门设计方案C。

右侧的例子采用了4位设计,因而您可以设置一个十六进制的密码。由于状态(0)十六进制 == (0000)二进制无法激活系统,故您只可以设置15种密码(1到F,或0到E)。如果您希望加入第16种,那么请自行编辑电路添加第五位输入。

接下来我们将规定(0)十六进制 为 (1111)二进制,至于[1,9]区间内的数请查看上一节末尾的表格。这样,我们就可以使用十进制数字作为密码的外在显示了。我们必须把十个按钮分配到对应的二进制数据上,请看右图的前两列:第一列代表表示为十进制(当然十六进制在[0,9]区间内和十进制的表示一样)的输入码;第二列对应着每一个输入码的二进制。当然您也可以添加更多的按钮来对应区间[A,E],我只是为了讲解方便而把那几位去除了。方框/b1\输出第一位,方框/b2\输出第二位,依此类推。

接下来您可以看到用Key[i](i=1,2,3)来表示的密码设置区。这几个Key[i]方框的第一个输出均为第一位,第二个输出为第二位,依此类推。您可以在每个Key[i]处用拉杆设置二进制加密型的密码。请参考上一节末尾的表格,还有(0)十六进制:= (1111)二进制的特殊对应。如果我们用按钮输入了第一位,装置会与这一位对应的四位二进制数逐位比较。一旦每一位都正确,才会输出置位信号到下一级。

因此我们要实现逻辑运算(((b1=b1 & b2=b2) & b3=b3) & b4=b4) =: (b*=b*),在Minecraft中至少需要4个与门。这样我们可以把识别通过的信号存到RS锁存器/A\中。Key[2]和Key[3]具有同样的验证比较过程。

我们必须确认如果第二输入位是错的话状态会被清除。因此我们采用了一个按键触发事件(--/b1 OR b2 OR b3 OR b4\--/dt-\--/dt-\--)。请在图中找到包括两个"dt-"的那三个方框。工作原理是:任意键按下就会产生信号,然后再加上一个小延迟。为了在第二个输入位错误时复位/A\,我们进行逻辑运算(有键按下) “与” (非B),即“任何键按下且第二位输入错误”。这样如果我们正输入第一位,/A\不会被复位;如果/A\已经被激活,那么只有/A\应当被复位。因此在第二位输入错误而且第一位已经输入时继续逻辑运算(B* & A) =: (AB*),这样/AB*\就复位了记忆单元/A\。为了避免如果按按钮时间过长从而使/A\错误地被复位的问题,我们加入了主延迟元件/dt+\。/AB*\后面的非门是为了人工复位而设计的(例如可以连接一个压力板)。

然后,把整个复位电路复制到Key[2]上去,除了人工复位端由(非A)引出,自动复位端(即错误输入后的)从C引出。从A接来的人工复位阻止在第一位未输入前B就被激活。所以这一系列线路保证了本装置密码的顺序敏感特性。

问题是为什么我们要使用短延迟方块/dt-\。如果/A\激活后,第二位也成功输入,那么B激活,(非B)变为低电平。但当(非B)仍然为高电平时,按键触发事件也被激活,A会被错误地复位——但这一切没有发生。/dt-\方块的应用使得在按键触发事件被激活之前/B\可以有充足的时间作出反应。

对于/C\来说,只需要引自B的人工复位端即可以防止C在B激活之前被错误激活,同时也能保证在人工复位端复位/A\与/B\时,/C\也可以被复位。

优缺点:

+ 您可以在不改变电路的前提下改变每一位密码。
+ 您可以依据同样原理扩展比较模块电路以使密码锁支持更多位数的密码。
+ 您可以通过将除了最后一位之外的任何位为(0000)二进制来减少密码位数。
+ 您可以将最后一位设为(0000)二进制来直接使门打开。
- 想要支持越多的位数,输入栏就越长。您可以选择被编码的按键以保持电路的小规模——但要小心,事实上输入编码电路比起由于位数增加而使背后巨大的装置规模变得更大来说,是微不足道的。

严格来说不算缺点的缺点:本电路中当密码是311时可能会出现刚输入到第二位,密码锁就打开了。为了防止这种情况,用中继器在(非A)与(复位B)之间加一个延迟即可。

如果您修复了这一点,电路会因密码长度差异而具有以下的加密强度:( ||位数|| = 2n-1,密码组合数:||位数||长度 )

长度 1位数 2位数 3位数 4位数 5位数
2 位 3 9 27 81 243
3 位 7 49 343 2401 16807
4 位 15 225 3375 50625 759375
5 位 31 961 29791 923521 28629151

杂项

对顺序不敏感的密码门

只要特定组合的拉杆拉下或是按钮按下,门就会打开。 (注:您需要对逻辑门有一定的了解才能理解本设备的构造)
教程[1](十分易学)

RS或非锁具

把一系列的按钮连接到RS锁存器阵列的S端。Feed the Q or Q (choose which one for each latch to set the combination) outputs of the RS Latches into a series of AND gates, and connect the final output to an iron door. Finally, connect a single button to all the R-inputs of the RS Latches. The combination is configured by using either Q or Q for each button (Q means that the button would need to be pressed, Q don't press) Example:

RSnorlatchlock

With the automated reset it causes the correct combo to cause a pulse instead of a "always on" until reset.

与门锁具

The AND based combo lock uses switches and NOT gate inverters instead of the RSNOR latches in the previous design. This makes for a simpler design but becomes less dynamic in complicated systems and it also lacks an automated reset. The AND design is configured by adding inverters to the switches. Example: Combolockredstone

或门锁具

The OR combo lock is actually an AND combo lock without unnecessary repeaters, override lever and last inverter. Output is off when the code is correct.

Due to its compact size and fast response time, this combination lock is also ideal for use as an address decoder in the construction of addressable memory (RAM)

Design A. Code is set by torches on inputs (1001):

Or-lock

It is possible to remove the spacing between the levers by replacing redstone wire behind the levers with delay 1 repeaters.

You can expand on this by creating a new level on top of the first and using the same principle as the first level, keep creating them.

Design B. Code is set by inverters in the blue area (001001):

File:Compact or-lock.JPG


N - number of inputs. K - number of 1's in code.

Design A B
Size 2N-1x3x1 Nx6x2
Torches K 2N-K
Redstone 3N-K-1 2.5N + 2K

分类设备

Sorting DeviceThis is a device which sorts the inputs, putting 1's at the bottom and 0's at the top. In effect counting how many 1s and how many 0s there are. The diagram is designed so that it is easily expandable, as shown in the diagram. The bright squares shows how to expand it, and also where the in- and outputs are.


Truth table for a three-bit sorting device:

A B C 1 2 3
0 0 0 0 0 0
1 0 0 1 0 0
0 1 0 1 0 0
0 0 1 1 0 0
1 1 0 1 1 0
0 1 1 1 1 0
1 0 1 1 1 0
1 1 1 1 1 1

顺序敏感的RS或非锁具

A door that opens when buttons are pressed in certain order.

(Note: A moderate understanding of logic gates is needed for this device.)

Make a series of buttons, and connect only one to an RSNOR latch. Then connect both the RSNOR latch and a second button to an AND Gate, which feeds to another RSNOR latch. Do this continually until you have either filled all of the buttons or are satisfied with the lock. Connect the final RSNOR latch to a separate AND Gate with a signal from an enter button. Feed that to the output RSNOR latch. Then connect any of the left-over buttons to the enter button and send reset signals to all of the RSNOR latches. A pressure plate next to a door can reset the door. This type of lock has severe limitations its security. For example, not all the buttons could be used in the pin or there would be nothing to reset the system.

For a lock that can have a combination of any size, using all the buttons, and still have a wrong entry reset the system, you need a different way for it to reset. To construct this, hook up a panel of buttons (any number, but four or more is preferred) to a parallel series of adjacent repeaters. Invert as necessary so that all the repeaters are powered and are unpowered by the press of the corresponding button. These repeaters power a row of blocks. On top of the blocks, place a torch corresponding to the incorrect buttons for the fist number in the PIN. For the correct button/number, place dust under the powered block which leads to a RS NOR Latch. Place a row of blocks above the torches for the incorrect buttons, with redstone dust on top. Then connect this dust to the reset of the first RS NOR Latch. Only the correct button will set the RS NOR Latch and all others will reset it. Connect the output of the RS NOR LATCH to half of an AND gate. After the first row of blocks with the reset torches, place another row of repeaters and another row of blocks. Again place torches for the incorrect buttons and dust under the correct button's line. Power will be fed from the buttons through the rows of repeaters and blocks for as many rows as there are digits in the PIN number. Connect the dust from the correct button to the other half of the AND gate coming from the first RS NOR Latch. Only if the two conditions are met, that the first button was pushed correctly, setting the first RS NOR Latch, and the second button is pushed correctly will the AND gate send a signal to set the second RS NOR Latch. Again, connect a reset line from the incorrect button's torches to the reset of the second RS NOR Latch. NOTE: Delay the reset signals by one full repeater to give time for the next RS NOR Latch to be set before the reset happens. Continue building the array in the same manner until you reach the desired number of digits. In operation, when a button is hit, each RS NOR Latch checks (through the AND gate) to see if the previous RS NOR Latch is set, and the correct button for this RS NOR Latch has been pushed. Only when the correct buttons are pressed in order, will the signal progress through the conditional RS NOR Latches to the end. Connect the output of the last RS NOR Latch to a door and attach a line to a pressure plate inside the door to reset the last RS NOR Latch. See the video demonstration linked below. (Where?) (Yes where? A video would be very helpful)

相关页面

引用

Advertisement