请双击下面的英文字幕来播放视频。
翻译人员: Yolanda Zhang
校对人员: Carol Wang
00:21
Their fall from the tower sends
Ethic and Hedge
0
21734
3050
Ethic 和 Hedge 从高塔坠落,
00:24
spinning into the rapids
of a river of pure energy.
1
24784
4240
翻滚着掉进了纯能量激流中,
00:30
This torrent flows from the Bradbarrier
all the way to Huxenborg.
2
30944
5937
这条来自 Bradbarrier 的激流
通向 Huxenborg。
00:36
There an entire city’s worth of factories
3
36881
3100
那里整个城市的工厂
都在制造机器人,
00:39
build the robots
and house the Node of Memory,
4
39981
3080
也是记忆节点的存放地点。
00:43
the last of the three powerful artifacts
Ethic needs to collect.
5
43061
4372
三件强力神器中,记忆节点
是 Ethic 需要收集的最后一件。
00:47
After a long day and a longer night
6
47433
2510
度过了漫长的一天
和更漫长的夜晚后,
00:49
they find themselves
in a canyon of brick and steel.
7
49943
3720
他们发现自己正身处
由砖块和钢铁构成的峡谷中。
00:58
Just when they’re about to reach
the end of the line,
8
58918
2655
正当他们快到达激流的尽头时,
01:01
a rope catches them.
9
61573
1750
一条绳索套住了他们,
01:07
Their savior, Lemma,
has been waiting for them.
10
67023
4114
他们的救世主 Lemma 已等候多时。
01:11
When Ethic claimed the Node of Creation
from the forest tower,
11
71137
3952
当 Ethic 从森林高塔取得创造节点后,
01:15
radios all across the land
came back to life.
12
75089
3900
陆地上所有的无线装置
都恢复了正常运作。
01:18
Adila, the resistance leader,
immediately started contacting her allies,
13
78989
4776
反抗军领袖 Adila
立即开始联系盟友,
01:23
none more important than Lemma,
14
83765
2610
首推在 Huxenborg 工作的
杰出科学家 Lemma,
01:26
a brilliant scientist working from within
Huxenborg to bring down the machines.
15
86375
5893
由她从内部协助打败机器人。
01:32
Unfortunately, the radios
also tipped off the robots.
16
92268
4000
不料,无线电波也惊动了守卫。
01:36
So they’ve taken defensive measures
17
96268
2260
守卫因此采取了防御措施,
01:38
to protect the final artifact in its home
in the very heart of the city.
18
98528
4828
来保护位于城市中心
关键区域的最后神器。
01:43
There’s only one way to get there:
the gauntlet of forking paths.
19
103356
5155
要到达那里,只有一种办法:
战胜分叉路径的严酷挑战。
01:48
It’s a deadly series of luminous conveyors
that wind underneath Huxenborg.
20
108511
6386
这是一系列致命的发光传送带,
在 Huxenborg 地下蜿蜒而行。
01:54
Starting from the current position,
21
114897
1820
从当前位置开始,
01:56
each section runs for a distance,
then splits in two.
22
116717
4395
每条路延伸一段后就分为两条;
02:01
Every branch does the same thing,
again and again.
23
121112
3430
每个分支不断重复此过程,
02:04
There are thousands of branches.
24
124542
2400
从而产生了成千上万的分支。
02:06
Only one path leads to the artifact;
all the others to destruction.
25
126942
5942
通往神器的路只有一条;
其他的路径只会通向毁灭。
02:12
Fortunately, the Node of Creation
has granted Hedge a strange power:
26
132884
4619
幸运的是,创造节点
赋予了 Hedge 一种神秘力量:
02:17
he can produce slightly smaller versions
of himself.
27
137503
3720
能生成比自身略小的两个复制体。
02:21
Each version can do only two things:
radio information back to its parent,
28
141223
5210
每个复制体只能做两件事:
02:26
and produce slightly smaller
versions of itself…
29
146433
3740
通过无线电向父级传回信息,
并复制两个更小的自己 ... ...
02:30
which can do the same two things,
as can their children,
30
150173
3690
这些复制体与其子级复制体
也会做同样的这两件事,
02:33
for as many generations as needed.
31
153863
2940
不断复制直至满足数量。
02:36
A patrol is closing in on their position,
so Ethic’s time is limited.
32
156803
5051
一支巡逻队正在接近他们,
Ethic 的时间很有限。
02:41
What instructions should she give
Hedge to find the one safe path?
33
161854
5203
为了找到安全路径,
她该给 Hedge 下达什么指令?
02:47
Pause the video to figure it out yourself.
34
167057
6778
[ 可暂停视频,自行解题 ]
02:53
Hint in 3
35
173835
990
[ 答案揭晓:3 ]
02:54
Hint in 2
36
174825
1200
[ 答案揭晓:2 ]
02:56
Hint in 1
37
176025
960
[ 答案揭晓:1 ]
02:57
Programmers have an elegant tool
in their arsenal called recursion.
38
177825
5162
程序员的装备库中
有一件强大的工具叫递归,
03:02
Recursion is when you have a set of
instructions that refers back to itself.
39
182987
5341
它是一组不断进行自引用的指令,
03:08
It’s like using a word
in its own definition,
40
188328
2960
就像用一个词本身来定义这个词,
03:11
except where that’s frowned upon,
this is incredibly effective.
41
191288
4560
除了让人觉得怪异之外,
这种方式本身非常有效。
03:15
Recursion involves repetition,
but in a different way than loops.
42
195848
4512
递归涉及重复,但与循环不同。
03:20
Where a loop takes one action
and repeats it again and again,
43
200360
4000
循环在执行一次操作后,
会重复执行这个过程,
03:24
recursion will start an action,
and before it’s finished, use it again,
44
204360
4302
而递归在开始执行一次操作后 ,
会在完成之前再次执行操作,
03:28
and before that’s finished,
use it again, and so on.
45
208662
4000
完成前再次执行同样动作,
以此类推下去 ... ...
03:32
It keeps doing this until
some end state is reached.
46
212662
4000
一直重复此操作,
直到满足某种条件,
03:36
It then passes the information back up,
layer after layer,
47
216662
4162
然后将信息一层层传递回去,
03:40
until it reaches the top
and ends the cycle.
48
220824
3620
直到传回起点,最后结束循环。
03:44
Recursion is ideal for problems
that involve self-similarity,
49
224444
4662
递归非常适合解决
涉及自相似性的问题,
03:49
where each part resembles
the larger whole.
50
229106
2860
其中每个部分都与整体高度相似。
03:51
Like, for example, a deadly defense
system designed to end any person or thing
51
231966
6004
例如,一个致命的防御系统,
03:57
who dares tread upon it.
52
237970
1890
设计用来终结任何大胆的闯入者。
03:59
Pause the video to figure it out yourself.
53
239860
2060
[ 可暂停视频,自行解题 ]
04:01
Solution in 3
54
241920
793
[ 答案揭晓:3 ]
04:02
Solution in 2
55
242713
920
[ 答案揭晓:2 ]
04:03
Solution in 1
56
243633
1080
[ 答案揭晓:1 ]
04:04
Ethic’s conundrum seems sprawling
on the surface,
57
244993
3041
Ethic 的难题表面看起来很难,
04:08
but there’s a remarkably simple
solution to it using recursion.
58
248034
4366
但使用递归就特别简单了。
04:12
In order to find it, let’s first look
at the simplest version of this puzzle:
59
252400
4750
为了找到这个方法,
先来看看谜题的最简版本:
04:17
what if the entire maze
were just two paths?
60
257150
3270
如果整个迷宫只有两条路呢?
04:20
If Hedge copies himself, the copy
that goes the wrong way will be destroyed.
61
260420
4618
如果 Hedge 复制两个自己,
走入错路的复制体将被毁灭。
04:25
So the other one,
which will reach the artifact,
62
265038
2719
另一个复制体会抵达神器,
04:27
can radio back the path it took,
and then no matter which way is correct,
63
267757
4700
并用无线电发回其路径信息,
不需要考虑其他路径,
04:32
that’s the answer Hedge will receive.
64
272457
2401
那就是 Hedge 接收到的答案。
04:34
This is called the "base case"
of the recursion.
65
274858
3580
这就是 “递归的基本情况”。
04:38
Now, suppose the maze
branches twice from the starting point,
66
278438
3340
现在,假设迷宫由起点分为两支,
04:41
and at every intersection,
Hedge’s copies—
67
281778
2982
在每个分支的节点
Hedge 进行自我复制 ——
04:44
let’s call them Twig 1 and Twig 2—
68
284760
2860
我们称为 分支 1 和 分支 2——
04:47
make more copies—
let’s call them Leaves 1 through 4.
69
287620
5007
它们继续进行复制,
得到 叶片 1 至叶片 4,
04:52
Three Leaves will be destroyed.
70
292627
3120
三条分支会被摧毁。
04:55
The one that reaches the artifact
will radio back the right answer,
71
295747
4116
到达神器的那条路径
将传回正确答案,
04:59
but only to its parent.
72
299863
1980
但只回传给父级。
05:01
So if Twig 1 or 2 is waiting
at an intersection
73
301843
3880
如果分支 1 或 2 在节点等待
05:05
and hears something over the radio,
74
305723
1990
并从无线电收到回传信息,
05:07
that’s the right way to go
to the artifact from where it is.
75
307713
3560
即从其所在位置
通往神器的正确道路。
05:11
To tell Hedge the right answer
from his perspective,
76
311273
3290
要从分支的角度
告诉 Hedge 正确答案,
05:14
the Twig should say which way it went,
77
314563
2440
分支会报告自己走过的路径,
05:17
and then the route
it just heard over the radio.
78
317003
3600
以及刚从无线电收到的路径信息。
05:20
This same process will work no matter
how many times the maze branches.
79
320603
4790
不管迷宫分支多少次,
同样的过程都会奏效,
05:25
Any answer a copy hears on the radio
80
325393
2960
复制体在无线电上接收到的答案
05:28
must be the way to the control room
from its location,
81
328353
3300
必然是从它的位置到控制室的路径,
05:31
and if it then adds the branch it took,
82
331653
2350
然后,如果加上它走的分支,
05:34
it can tell its parent
how to get there as well.
83
334003
3220
也就能告诉父级
如何从它的位置到控制室。
05:37
We can sum up the instructions
in an action called Pathfinder
84
337223
4000
在这次名为“探路者”的行动中,
我们总结出 Hedge 的每个复制体
需要遵循的指令如下:
05:41
that every version of Hedge will follow:
85
341223
3130
05:44
1. If you’ve reached the artifact,
86
344353
2290
1. 如果到达神器地点,
05:46
radio to your parent whether
you got there by going left or right.
87
346643
4094
通过无线电告知父级
选左边或右边的路径。
05:50
2. When you reach an intersection,
move off the conveyor
88
350737
3830
2. 到达节点后,离开传送带,
05:54
and send new copies down the left
and right paths.
89
354567
3980
并向左右两条路发送复制体。
05:58
Have them each run Pathfinder.
90
358547
2280
让它们各自运行“探路者”,
06:00
This is where recursion comes in,
91
360827
2040
这就是递归的过程,
06:02
and this may happen many times before
the last instruction triggers, which is:
92
362867
5094
在最终指令触发前,这个过程
可能会发生很多次。最终指令是:
06:07
3. If you hear anything over the radio,
you should radio to your parent
93
367961
4987
3. 如果无线接收到任何信息,
都应当传递回父级——
06:12
whether you got to your spot
by going left or right,
94
372948
3629
不管你走左边还是右边的路
到达你所在位置,
06:16
then repeat everything you just heard.
95
376577
2850
然后重复刚接收到的一切信息。
06:19
Pathfinder is an example
of what programmers call functions,
96
379427
3996
”探路者“是程序员调用函数、
06:23
subroutines, or procedures.
97
383423
2690
子程序或过程的一个例子。
06:26
No matter the terminology,
the idea is the same—
98
386113
3390
不管用什么术语来形容,
其本质都是一样的——
06:29
it’s a set of instructions given a label
so that it can be easily reused—
99
389503
4794
这只是一组带有标签的指令,
可以方便地重复使用——
06:34
perhaps even by itself.
100
394297
2310
甚至可以被其自身调用。
06:36
And in our case that’ll work perfectly—
101
396607
2976
在我们的案例中,
这一方法将非常有效——
06:39
an entire network of paths mapped
using just three instructions.
102
399583
5230
仅仅使用三条指令
就能映射出整个路径网络。
06:46
So here's what happens.
103
406257
1630
这就是接下来所发生的事情:
07:09
By the time the patrol rounds the corner,
Ethic and Lemma have improvised disguises.
104
429760
5777
在巡逻队正要经过拐角时,
Ethic 和 Lemma 及时伪装了自己。
07:15
They try to confuse the bots
long enough to buy Hedge time.
105
435537
4120
她们试图迷惑机器人,
以便为 Hedge 争取时间,
07:31
Finally, Hedge’s radio crackles to life
with a series of directions.
106
451473
4778
终于,Hedge 的无线电响起,
收到了正确路径信息。
07:36
The three dive onto the conveyor
and flee for their lives,
107
456251
3850
他们三个跳上了传送带,
07:40
with a squadron of enforcer bots
in hot pursuit.
108
460101
3720
逃离了紧追不舍的一队机械守卫。
New videos
关于本网站
这个网站将向你介绍对学习英语有用的YouTube视频。你将看到来自世界各地的一流教师教授的英语课程。双击每个视频页面上显示的英文字幕,即可从那里播放视频。字幕会随着视频的播放而同步滚动。如果你有任何意见或要求,请使用此联系表与我们联系。