The Factory | Think Like A Coder, Ep 9

384,782 views ・ 2020-06-23

TED-Ed


Please double-click on the English subtitles below to play the video.

00:32
After a harrowing chase, Ethic, Hedge, and their new ally Lemma
0
32447
4555
00:37
find themselves in a cavernous control room.
1
37002
7504
00:44
Here the last artifact— the Node of Memory—
2
44506
3320
00:47
is suspended within a force field and powering a supercomputer.
3
47826
4838
00:52
Ethic is about to deactivate the force field when Lemma stops her.
4
52664
4809
00:57
She explains, a decade ago, she was assigned a research task:
5
57473
4909
01:02
to use the world machine to create something that would make everyone happy.
6
62382
4927
01:07
After many failed attempts, Lemma discovered a compound that, when ingested,
7
67309
5048
01:12
made people motivated, happy, creative, loving… in short, their best selves.
8
72357
6677
01:19
It was rushed into production.
9
79034
2040
01:21
Soon, the entire nation’s food supply came from Huxenborg,
10
81074
3670
01:24
with the compound mixed in.
11
84744
2790
01:27
The first year was paradise.
12
87534
1970
01:29
The second, not so much.
13
89504
2150
01:31
Side-effects began to emerge: memory-loss, listlessness, and self-absorption.
14
91654
5298
01:36
In the third year, the government dissolved,
15
96952
2840
01:39
leaving the robots running everything in a self-sustaining loop.
16
99792
4588
01:44
By this point things were too far gone for Lemma to reverse.
17
104380
3890
01:48
People had become dependent on the compound,
18
108270
2850
01:51
and the few who refused it formed a resistance to try to fix things.
19
111120
4364
01:55
It took 10 years for Lemma to find a cure.
20
115484
3100
01:58
This factory contains everything she’ll need to make it,
21
118584
3890
02:02
but the second they take the Node of Memory,
22
122474
2240
02:04
the security system will alert the robots, and they’ll have to run.
23
124714
4242
02:08
If, instead, they first reconfigure the factory to manufacture the cure,
24
128956
5183
02:14
the people can be saved.
25
134139
2210
02:16
Lemma has the whole factory redesign planned out.
26
136349
3460
02:19
The problem is… it’s a little hard to read.
27
139809
2820
02:22
Her schematic shows all the steps in the manufacturing process
28
142629
3620
02:26
needed to make the cure.
29
146249
1680
02:27
An arrow from “add nitric acid” to “shake vigorously”
30
147929
3880
02:31
means that the acid addition has to happen before shaking.
31
151809
3870
02:35
If a single step is performed out of order,
32
155679
2670
02:38
the cure won’t work, or worse.
33
158349
2710
02:41
There aren’t any circular references, where step A requires step B
34
161059
4652
02:45
and step B eventually requires step A.
35
165711
4434
03:04
Here’s where Ethic and Hedge come in.
36
184771
2660
03:07
Lemma needs Hedge to translate the tangled diagram
37
187431
3528
03:10
into a sequence of steps.
38
190959
2220
03:13
That’ll be the order that things happen in the factory.
39
193179
2990
03:16
Once input into the central computer,
40
196169
2280
03:18
the factory will reassemble itself as instructed.
41
198449
3700
03:22
Hedge’s ability to store information in a table will help here.
42
202149
3830
03:25
So how does Ethic program Hedge to turn out a correct sequence
43
205979
4557
03:30
that can reconfigure the factory?
44
210536
2335
03:32
Pause now to figure it out yourself.
45
212871
1872
03:34
Rules in 3
46
214743
850
03:35
Rules in 2
47
215593
968
03:36
Rules in 1
48
216561
920
03:39
Hint in 3
49
219470
1021
03:40
Hint in 2
50
220491
975
03:41
Hint in 1
51
221466
1145
03:42
It may help to first think about this problem as a human,
52
222611
3899
03:46
rather than a machine.
53
226510
1650
03:48
Given this diagram, it’s clear to start with getting a bowl,
54
228160
4161
03:52
since no arrows point to it.
55
232321
2780
03:55
How might you mark up the diagram to figure out what to do next?
56
235101
4540
03:59
Pause now to figure it out yourself.
57
239641
1970
04:01
Solution in 3
58
241611
880
04:02
Solution in 2
59
242491
1020
04:03
Solution in 1
60
243511
1126
04:04
Diagrams like the one Lemma has drawn are called directed acyclic graphs.
61
244637
6603
04:11
A graph is a representation of data that shows different elements
62
251240
4000
04:15
and how they’re related to each other.
63
255240
2257
04:17
Directed means that direction matters— as indicated by the arrows.
64
257497
5734
04:23
Here A leads to B, but B doesn’t lead to A.
65
263231
4198
04:27
And acyclic means that there aren’t any loops.
66
267429
3720
04:31
Which is fortunate, because if there were, this problem wouldn’t be solvable.
67
271149
5079
04:36
There’s a simple way to navigate the graph as a human:
68
276228
3480
04:39
start with a step that doesn’t have any arrows pointing to it.
69
279708
3710
04:43
Once you do that, cross out that step and all arrows leading from it.
70
283418
4890
04:48
Choose another step with no arrows pointing to it,
71
288308
3230
04:51
and repeat until you’ve hit every step.
72
291538
3680
04:55
There are two things here that are tricky to translate for a robot.
73
295218
4000
04:59
First, how do you keep track of the information?
74
299218
2960
05:02
And second, what do you do if there are multiple options at the same time?
75
302178
5321
05:07
For the first challenge,
76
307499
1250
05:08
a convenient way for machines to store information is in a table.
77
308749
4240
05:12
In this case, you can have Hedge list every step in the headers
78
312989
4000
05:16
of both the rows and columns.
79
316989
2750
05:19
Then he can go through the rows one at a time.
80
319739
2910
05:22
On the schematic, what points to mix?
81
322649
2861
05:25
Both shake and titrate.
82
325510
2350
05:27
So Hedge should make a mark in both of their columns.
83
327860
3540
05:31
He can do the same for every row, one at a time, to make a table like this.
84
331400
5158
05:36
Of course the full table will be much bigger.
85
336558
4000
05:40
Like a human, Hedge will also want to start
86
340558
2490
05:43
from one of the steps that has no arrows pointing to it—
87
343048
3480
05:46
which is the same as having no marks in its row.
88
346528
4215
05:50
If there’s more than one,
89
350743
1290
05:52
a convenient way to choose is to pick the one that’s alphabetically earliest,
90
352033
4762
05:56
though other selection methods can work just as well.
91
356795
4065
06:00
Next, Hedge can add that step to his running-order list,
92
360860
4000
06:04
delete its entire column from the table—
93
364860
2450
06:07
thus removing all the times it was a dependency––
94
367310
3030
06:10
and loop back to the start.
95
370340
2650
06:12
Because there are no circular references in the graph,
96
372990
3300
06:16
each time we get here there’ll be at least one step with no remaining dependencies.
97
376290
5574
06:21
Hedge can add the alphabetically earliest to his running-order list,
98
381864
4692
06:26
remove it from the table, and loop back to the start again.
99
386556
4665
06:31
So now we have a working loop,
100
391221
2020
06:33
and it’ll run through all the elements in our table until none are left.
101
393241
4842
06:38
Hedge drifts back and forth over the schematics,
102
398083
3010
06:41
and soon he starts spitting out instructions,
103
401093
2970
06:44
which Ethic uses to configure the assembly lines.
104
404063
3230
06:55
With the three working together,
105
415794
1760
06:57
they churn out thousands of doses of the cure in no time.
106
417554
3710
07:14
Ethic finally plucks the Node of Memory
107
434285
2400
07:16
from its holding field and trips the alarm.
108
436685
2970
07:19
Within seconds bots are everywhere.
109
439655
2870
08:02
As Ethic falls in shock, the Node restores not only her own memories,
110
482272
5037
08:07
but reveals the last, missing pieces of the puzzle.
111
487309
4085
08:11
Ethic built Hedge with a singular purpose:
112
491394
2870
08:14
to construct a maze that would protect the world machine
113
494264
3422
08:17
from a corrupt government.
114
497686
1800
08:19
But in her haste, she made a critical mistake.
115
499486
3081
08:22
She forgot to set the condition that would end the loop
116
502567
3220
08:25
which told Hedge how large the maze should be.
117
505787
3429
08:29
So Hedge built and built until he could build no longer.
118
509216
4617
08:33
And then he was conflicted.
119
513833
1760
08:35
He had to build a maze.
120
515593
1700
08:37
But he couldn’t build further without hurting people
121
517293
3220
08:40
or flying over the Bradbarrier,
122
520513
2310
08:42
both forbidden by his programming.
123
522823
2500
08:45
So he wandered the land and searched for a solution,
124
525323
3330
08:48
until he happened upon the Node of Power, the Node of Creation,
125
528653
4130
08:52
and the Node of Memory.
126
532783
2340
08:55
He recognized their true, collective power
127
535123
2730
08:57
to grant self-awareness to those who lack it.
128
537853
3010
09:00
With all three he’d be able to change his programming
129
540863
2910
09:03
and fulfill his drive to transform the entire world into a giant maze.
130
543773
5251
09:09
It wouldn’t be easy:
131
549024
1650
09:10
the Nodes had safeguards to prevent robots from taking and using them.
132
550674
4745
09:15
But if Hedge could find the right human
133
555419
2770
09:18
and manipulate her with the promise of a heroic quest…
134
558189
4000
09:22
well that would be a different story.
135
562189
2290
09:24
A very different story.
136
564479
2560
About this website

This site will introduce you to YouTube videos that are useful for learning English. You will see English lessons taught by top-notch teachers from around the world. Double-click on the English subtitles displayed on each video page to play the video from there. The subtitles scroll in sync with the video playback. If you have any comments or requests, please contact us using this contact form.

https://forms.gle/WvT1wiN1qDtmnspy7