The Furnace Bots | Think Like A Coder, Ep 3

593,092 views ・ 2019-11-18

TED-Ed


请双击下面的英文字幕来播放视频。

翻译人员: Sicheng Lu 校对人员: Jiasi Hao
[ 像程序员一样思考 ]
[ 地点:BRADBARRIER ]
[ 第三集 炉膛机器人 ]
[ 音乐 ]
00:35
Ethic and her robot Hedge agree to help the resistance leader, Adila,
0
35753
5043
艾斯克和她的机器人海吉 同意帮助反对运动的领袖,埃迪拉,
00:40
sabotage the art-incinerating furnace-bots.
1
40796
3770
密谋破坏 焚毁艺术品的炉膛机器人。
00:44
In exchange,
2
44566
996
作为交换,
00:45
Adila promises to lead them to the first object of Ethic’s quest,
3
45562
4784
埃迪拉保证会带领他们 前往艾斯克要寻找的第一个物品——
00:50
an artifact called the Node of Power.
4
50346
4331
一个名为“能量晶石”的神器。
00:54
Years ago, there was just one furnace-bot.
5
54677
3051
几年之前,只有一个炉膛机器人,
00:57
It had a 0 inside its furnace and an unknown,
6
57728
3489
在它的炉膛里有一个数字 0 ,
和另一个未知的、任意生成的编码。
01:01
randomly generated serial number.
7
61217
3000
01:04
Over time, the original self-replicated to produce more identical furnace-bots.
8
64217
6557
随着时间的推移,
原始的机器人自我复制, 制造了更多一样的炉膛机器人。
01:10
Each child inherited the original’s unknown serial number within its furnace,
9
70774
5268
每一个子机器人的熔炉内 都继承了初始机器人未知的编码,
01:16
and had a random, unique serial number of its own inscribed on its shell.
10
76042
5467
并且有一个属于自己的 独一无二的任意编码刻于其外壳。
01:21
The second generation of furnace- bots also self-replicated in the same way,
11
81509
4931
第二代炉膛机器人 也通过同样的方法自我复制,
01:26
always passing their own serial numbers to their offspring’s furnaces.
12
86440
5003
永远将属于自己的编码 传承给自己子机器人的熔炉。
01:31
This continued on for many generations.
13
91443
3710
就这样传承了很多代。
01:35
Today, each furnace-bot receives its orders from its parent.
14
95153
4479
如今,每一个炉膛机器人 都从自己的母机器人那接收指令。
01:39
So if Ethic can find the original 0 bot and somehow change its instructions,
15
99632
6115
所以,如果艾斯克可以找到 初始零号机器人并改变它的指令,
01:45
she could take over the entire army, all at once.
16
105747
4429
她就可以一次性掌控 整个机器人军队。
01:50
Adila has the perfect solution:
17
110176
2695
埃迪拉有个完美的解决办法:
01:52
a data crystal that she’s been carrying for years,
18
112871
3554
一个她带在身上很多年的数据水晶
01:56
waiting for the right moment to activate it.
19
116425
2941
正等待着合适的时机被激活。
01:59
It contains a program designed to gain control of a bot
20
119366
4094
水晶内包含一个程序,
这个程序能操控一个机器人 并且给它新指令。
02:03
and give it new instructions.
21
123460
2355
02:05
But if it’s uploaded to any furnace- bot other than the original,
22
125815
4056
但是如果它被上传到 任何除 0 之外的炉膛机器人上,
02:09
the 0 bot will override the instructions
23
129871
2870
零号机器人就会覆盖这个指令,
02:12
and destroy the data crystal in the process.
24
132741
3624
同时摧毁数据水晶。
02:16
The feeding is just a few minutes away,
25
136365
2395
离喂食开始只有几分钟,
02:18
and there’s only one chance to get this right.
26
138760
3559
成功的机会只有一次。
02:22
Fortunately, Hedge’s ability to store data can help.
27
142319
4249
幸运的是,海吉存储数据的能力 可以派上用场。
02:26
In programming,
28
146568
1205
在编程的时候,
02:27
a piece of information gets stored in something called a variable.
29
147773
4344
信息被储存在 一个称为变量的东西里。
02:32
Variables are basically containers that hold onto numbers, words, or other values.
30
152117
6490
变量就是保存数字、单词 和其他量数的容器。
02:38
How does Ethic program Hedge to find the original 0 bot as quickly as possible?
31
158607
6695
艾斯克要如何为海吉编写程序, 让它最快地找到零号机器人呢?
02:45
Pause now to figure it out for yourself.
32
165302
2790
[ 可暂停播放自行解题 ]
02:49
Here’s a hint.
33
169956
1353
提示如下:
02:51
Programs can be written to have as many variables as you need,
34
171309
4220
程序可以被编写成 包含任意数量的变量,
02:55
but you can solve this problem with just one.
35
175529
3341
但你只需要用一个变量 就能解决这个问题。
02:58
Hedge can use it to store a serial number
36
178870
2794
海吉可以用这个变量储存一个编码,
03:01
and replace it with a new one as often as he needs.
37
181664
3606
然后随时用新的编码将其替换。
03:05
Pause now to figure it out for yourself.
38
185270
2444
[ 可暂停播放自行解题 ]
03:10
A key insight here is that Hedge doesn’t need to map out the entire
39
190129
4439
一个重要的切入点是
海吉不需要画出整张关系图 来寻找原始机器人。
03:14
set of relationships to find the original furnace-bot.
40
194568
3923
03:18
If, for example, he gets lucky and picks the original one right away,
41
198491
4449
假设,如果它幸运地 一下就选中了原始零号机器人,
03:22
he’ll be done.
42
202940
1080
它的任务就完成了。
03:24
But if he starts with any other bot,
43
204020
2418
但如果他从其他任何一个机器人开始,
03:26
he can still find a path that leads straight back to the 0-bot
44
206438
4273
通过执行一组简单的指令,
03:30
by following a simple set of instructions.
45
210711
3720
它仍然能找到 一条直通零号机器人的途径。
03:34
To help craft them, let’s first simplify the problem.
46
214431
3620
为生成这个指令, 首先我们需要简化这个问题。
假设只有三个炉膛机器人: 一个母机器人和两个子机器人,
03:38
Let’s say there were only three furnace-bots;
47
218051
2772
03:40
a parent and two children, but you don’t know which is which.
48
220823
3809
但你不知道谁是谁,
03:44
You could have Hedge pick one at random and look inside its furnace.
49
224632
4777
你可以让海吉 任意选择一个检查它的熔炉。
03:49
Now, you know the family tree looks like this.
50
229409
3840
现在,你知道系谱图长这个样子:
03:53
If the number inside the furnace is a 0, you’ve found the parent.
51
233249
3954
如果熔炉内的编码是 0 , 那么你找到了母机器人。
03:57
If not, then no matter which child you chose,
52
237203
3345
如果不是, 那么不论你选择哪一个,
04:00
it must have the parent’s serial number in its furnace.
53
240548
3810
它的熔炉内必定都有母机器人的编码。
04:04
So in this scenario, you’re guaranteed to find the parent in one or two moves.
54
244358
6315
所以在这种情况下, 你必定会在两步之内找到母机器人。
04:10
In actuality, there are many furnace-bots,
55
250673
2890
现实情况中,有无数的炉膛机器人,
04:13
and you don’t know how many generations there are
56
253563
2683
而且你也不知道现在有多少代机器人,
04:16
nor what the family tree looks like.
57
256246
2605
也不知道系谱图的样子。
04:18
But you don’t need to,
58
258851
1589
但其实你不需要知道,
04:20
because Hedge can just keep repeating the same sequence of actions
59
260440
3921
因为海吉可以 一直重复执行相同的动作
04:24
until he gets to the original.
60
264361
2242
直到它找到初始的零号机器人。
04:26
How? With a loop.
61
266603
2409
如何办到?使用循环指令。
04:29
Hedge can pick any bot at random, look inside its furnace,
62
269012
3880
海吉可以选择任意一个机器人, 检查它的熔炉,
04:32
and store that serial number as a variable.
63
272892
3318
并且将其的编码作为变量储存。
04:36
Then he’ll begin the following loop that will repeat
64
276210
3405
然后它将执行以下循环指令 直到储存变量等于 0 ,
04:39
until the stored variable equals 0,
65
279615
2706
即,初始机器人的编码:
04:42
the furnace number of the original bot:
66
282321
3270
04:45
1. Find the bot whose shell serial number matches the stored number.
67
285591
5428
1、找到外壳上的编码 等于储存编码的机器人。
04:51
2. Look inside its furnace.
68
291019
2960
2、检查它的熔炉。
04:53
3. Store that new number, overwriting the old one.
69
293979
5120
3、储存这个新的编码,覆盖旧的编码。
04:59
Once the loop ends, we’ll know that Hedge has found the 0 bot,
70
299099
4340
一旦这个循环指令结束, 我们就知道海吉找到了零号机器人,
05:03
so he should upload the control program.
71
303439
2685
随后它就应该立刻上传控制程序。
05:06
So here’s what happens:
72
306124
1628
情况是这样的:
05:07
Hedge only takes 5 repetitions to find the original:
73
307752
3729
海吉只用 5 个循环就找到了初始机器人;
05:11
robot 733 has the 0 in its furnace.
74
311481
4100
733 号机器人的熔炉内有编码 0 。
05:15
In a blink of a mechanical eye,
75
315581
2094
一眨眼的时间,
05:17
the program spreads through the entire army, and Adila takes control.
76
317675
5136
程序散播到整个机器人军团, 埃迪拉因此获得了控制权。
05:22
She has the furnace-bots give off theatrical bouts of flame
77
322811
3449
她让炉膛机器人假装放出火焰
05:26
to hide the fact that they’re now secretly safe-guarding
78
326260
3343
来掩饰它们其实在暗中
05:29
all of that artistic output.
79
329603
3040
保护所有的文艺作品的事实。
05:32
Now that Ethic’s delivered the furnace-bots,
80
332643
2397
现在,艾斯克交出了炉膛机器人,
05:35
Adila honors her end of the deal.
81
335040
3460
埃迪拉也信守承诺,
05:38
She leads Ethic and Hedge to the location of the first artifact,
82
338500
3901
她带领艾斯克和海吉 去了第一件神器——
05:42
the Node of Power.
83
342401
2579
“能量晶石”的存放地。
05:44
There, one thing is immediately clear:
84
344980
3016
在那,他们立即了解到一件事:
05:50
they’ll have to steal it.
85
350086
1720
他们得将它偷出来。
关于本网站

这个网站将向你介绍对学习英语有用的YouTube视频。你将看到来自世界各地的一流教师教授的英语课程。双击每个视频页面上显示的英文字幕,即可从那里播放视频。字幕会随着视频的播放而同步滚动。如果你有任何意见或要求,请使用此联系表与我们联系。

https://forms.gle/WvT1wiN1qDtmnspy7