Return to Video

The Factory | Think Like A Coder, Ep 9

  • 0:32 - 0:37
    After a harrowing chase,
    Ethic, Hedge, and their new ally Lemma
  • 0:37 - 0:45
    find themselves
    in a cavernous control room.
  • 0:45 - 0:48
    Here the last artifact—
    the Node of Memory—
  • 0:48 - 0:53
    is suspended within a force field
    and powering a supercomputer.
  • 0:53 - 0:57
    Ethic is about to deactivate the force
    field when Lemma stops her.
  • 0:57 - 1:02
    She explains, a decade ago,
    she was assigned a research task:
  • 1:02 - 1:07
    to use the world machine to create
    something that would make everyone happy.
  • 1:07 - 1:12
    After many failed attempts, Lemma
    discovered a compound that, when ingested,
  • 1:12 - 1:19
    made people motivated, happy, creative,
    loving… in short, their best selves.
  • 1:19 - 1:21
    It was rushed into production.
  • 1:21 - 1:25
    Soon, the entire nation’s food supply
    came from Huxenborg,
  • 1:25 - 1:28
    with the compound mixed in.
  • 1:28 - 1:30
    The first year was paradise.
  • 1:30 - 1:32
    The second, not so much.
  • 1:32 - 1:37
    Side-effects began to emerge: memory-loss,
    listlessness, and self-absorption.
  • 1:37 - 1:40
    In the third year,
    the government dissolved,
  • 1:40 - 1:44
    leaving the robots running everything
    in a self-sustaining loop.
  • 1:44 - 1:48
    By this point things were too far gone
    for Lemma to reverse.
  • 1:48 - 1:51
    People had become dependent
    on the compound,
  • 1:51 - 1:55
    and the few who refused it
    formed a resistance to try to fix things.
  • 1:55 - 1:59
    It took 10 years for Lemma to find a cure.
  • 1:59 - 2:02
    This factory contains everything
    she’ll need to make it,
  • 2:02 - 2:05
    but the second they take
    the Node of Memory,
  • 2:05 - 2:09
    the security system will alert the robots,
    and they’ll have to run.
  • 2:09 - 2:14
    If, instead, they first reconfigure
    the factory to manufacture the cure,
  • 2:14 - 2:16
    the people can be saved.
  • 2:16 - 2:20
    Lemma has the whole factory redesign
    planned out.
  • 2:20 - 2:23
    The problem is…
    it’s a little hard to read.
  • 2:23 - 2:26
    Her schematic shows all the steps
    in the manufacturing process
  • 2:26 - 2:28
    needed to make the cure.
  • 2:28 - 2:32
    An arrow from “add nitric acid”
    to “shake vigorously”
  • 2:32 - 2:36
    means that the acid addition
    has to happen before shaking.
  • 2:36 - 2:38
    If a single step is performed
    out of order,
  • 2:38 - 2:41
    the cure won’t work, or worse.
  • 2:41 - 2:46
    There aren’t any circular references,
    where step A requires step B
  • 2:46 - 2:50
    and step B eventually requires step A.
  • 3:05 - 3:07
    Here’s where Ethic and Hedge come in.
  • 3:07 - 3:11
    Lemma needs Hedge to translate
    the tangled diagram
  • 3:11 - 3:13
    into a sequence of steps.
  • 3:13 - 3:16
    That’ll be the order that things happen
    in the factory.
  • 3:16 - 3:18
    Once input into the central computer,
  • 3:18 - 3:22
    the factory will reassemble
    itself as instructed.
  • 3:22 - 3:26
    Hedge’s ability to store information
    in a table will help here.
  • 3:26 - 3:31
    So how does Ethic program Hedge
    to turn out a correct sequence
  • 3:31 - 3:33
    that can reconfigure the factory?
  • 3:33 - 3:35
    Pause now to figure it out yourself.
  • 3:35 - 3:36
    Rules in 3
  • 3:36 - 3:37
    Rules in 2
  • 3:37 - 3:37
    Rules in 1
  • 3:39 - 3:40
    Hint in 3
  • 3:40 - 3:41
    Hint in 2
  • 3:41 - 3:43
    Hint in 1
  • 3:43 - 3:47
    It may help to first think about
    this problem as a human,
  • 3:47 - 3:48
    rather than a machine.
  • 3:48 - 3:52
    Given this diagram, it’s clear to start
    with getting a bowl,
  • 3:52 - 3:55
    since no arrows point to it.
  • 3:55 - 4:00
    How might you mark up the diagram
    to figure out what to do next?
  • 4:00 - 4:02
    Pause now to figure it out yourself.
  • 4:02 - 4:02
    Solution in 3
  • 4:02 - 4:04
    Solution in 2
  • 4:04 - 4:05
    Solution in 1
  • 4:05 - 4:11
    Diagrams like the one Lemma has drawn
    are called directed acyclic graphs.
  • 4:11 - 4:15
    A graph is a representation of data
    that shows different elements
  • 4:15 - 4:17
    and how they’re related to each other.
  • 4:17 - 4:23
    Directed means that direction matters—
    as indicated by the arrows.
  • 4:23 - 4:27
    Here A leads to B,
    but B doesn’t lead to A.
  • 4:27 - 4:31
    And acyclic means that there
    aren’t any loops.
  • 4:31 - 4:36
    Which is fortunate, because if there were,
    this problem wouldn’t be solvable.
  • 4:36 - 4:40
    There’s a simple way to navigate
    the graph as a human:
  • 4:40 - 4:43
    start with a step that doesn’t have
    any arrows pointing to it.
  • 4:43 - 4:48
    Once you do that, cross out that step
    and all arrows leading from it.
  • 4:48 - 4:52
    Choose another step with no arrows
    pointing to it,
  • 4:52 - 4:55
    and repeat until you’ve hit every step.
  • 4:55 - 4:59
    There are two things here that are tricky
    to translate for a robot.
  • 4:59 - 5:02
    First, how do you keep track
    of the information?
  • 5:02 - 5:07
    And second, what do you do if there
    are multiple options at the same time?
  • 5:07 - 5:09
    For the first challenge,
  • 5:09 - 5:13
    a convenient way for machines
    to store information is in a table.
  • 5:13 - 5:17
    In this case, you can have Hedge
    list every step in the headers
  • 5:17 - 5:20
    of both the rows and columns.
  • 5:20 - 5:23
    Then he can go through
    the rows one at a time.
  • 5:23 - 5:26
    On the schematic, what points to mix?
  • 5:26 - 5:28
    Both shake and titrate.
  • 5:28 - 5:31
    So Hedge should make a mark
    in both of their columns.
  • 5:31 - 5:37
    He can do the same for every row,
    one at a time, to make a table like this.
  • 5:37 - 5:41
    Of course the full table
    will be much bigger.
  • 5:41 - 5:43
    Like a human,
    Hedge will also want to start
  • 5:43 - 5:47
    from one of the steps that has
    no arrows pointing to it—
  • 5:47 - 5:51
    which is the same as having no marks
    in its row.
  • 5:51 - 5:52
    If there’s more than one,
  • 5:52 - 5:57
    a convenient way to choose is to pick
    the one that’s alphabetically earliest,
  • 5:57 - 6:01
    though other selection methods
    can work just as well.
  • 6:01 - 6:05
    Next, Hedge can add that step
    to his running-order list,
  • 6:05 - 6:07
    delete its entire column from the table—
  • 6:07 - 6:10
    thus removing all the times
    it was a dependency––
  • 6:10 - 6:13
    and loop back to the start.
  • 6:13 - 6:16
    Because there are no circular
    references in the graph,
  • 6:16 - 6:22
    each time we get here there’ll be at least
    one step with no remaining dependencies.
  • 6:22 - 6:27
    Hedge can add the alphabetically earliest
    to his running-order list,
  • 6:27 - 6:31
    remove it from the table,
    and loop back to the start again.
  • 6:31 - 6:33
    So now we have a working loop,
  • 6:33 - 6:38
    and it’ll run through all the elements
    in our table until none are left.
  • 6:38 - 6:41
    Hedge drifts back and forth
    over the schematics,
  • 6:41 - 6:44
    and soon he starts spitting
    out instructions,
  • 6:44 - 6:47
    which Ethic uses to configure
    the assembly lines.
  • 6:56 - 6:58
    With the three working together,
  • 6:58 - 7:01
    they churn out thousands of doses
    of the cure in no time.
  • 7:14 - 7:17
    Ethic finally plucks the Node of Memory
  • 7:17 - 7:20
    from its holding field
    and trips the alarm.
  • 7:20 - 7:23
    Within seconds bots are everywhere.
  • 8:02 - 8:07
    As Ethic falls in shock, the Node
    restores not only her own memories,
  • 8:07 - 8:11
    but reveals the last, missing pieces
    of the puzzle.
  • 8:11 - 8:14
    Ethic built Hedge with a singular purpose:
  • 8:14 - 8:18
    to construct a maze that would protect
    the world machine
  • 8:18 - 8:19
    from a corrupt government.
  • 8:19 - 8:23
    But in her haste,
    she made a critical mistake.
  • 8:23 - 8:26
    She forgot to set the condition
    that would end the loop
  • 8:26 - 8:29
    which told Hedge
    how large the maze should be.
  • 8:29 - 8:34
    So Hedge built and built
    until he could build no longer.
  • 8:34 - 8:36
    And then he was conflicted.
  • 8:36 - 8:37
    He had to build a maze.
  • 8:37 - 8:41
    But he couldn’t build further
    without hurting people
  • 8:41 - 8:43
    or flying over the Bradbarrier,
  • 8:43 - 8:45
    both forbidden by his programming.
  • 8:45 - 8:49
    So he wandered the land
    and searched for a solution,
  • 8:49 - 8:53
    until he happened upon the Node of Power,
    the Node of Creation,
  • 8:53 - 8:55
    and the Node of Memory.
  • 8:55 - 8:58
    He recognized their true,
    collective power
  • 8:58 - 9:01
    to grant self-awareness
    to those who lack it.
  • 9:01 - 9:04
    With all three he’d be able
    to change his programming
  • 9:04 - 9:09
    and fulfill his drive to transform
    the entire world into a giant maze.
  • 9:09 - 9:11
    It wouldn’t be easy:
  • 9:11 - 9:15
    the Nodes had safeguards to prevent
    robots from taking and using them.
  • 9:15 - 9:18
    But if Hedge could find the right human
  • 9:18 - 9:22
    and manipulate her
    with the promise of a heroic quest…
  • 9:22 - 9:24
    well that would be a different story.
  • 9:24 - 9:27
    A very different story.
Title:
The Factory | Think Like A Coder, Ep 9
Speaker:
Alex Rosenthal
Description:

View full lesson: https://ed.ted.com/lessons/the-factory-think-like-a-coder-ep-9

This is episode 9 of our animated series "Think Like A Coder." This 10-episode narrative follows a girl, Ethic, and her robot companion, Hedge, as they attempt to save the world. The two embark on a quest to collect three artifacts and must solve their way through a series of programming puzzles.

Lesson by Alex Rosenthal, directed by Kozmonot Animation Studio.

more » « less
Video Language:
English
Team:
closed TED
Project:
TED-Ed
Duration:
09:45

English subtitles

Revisions Compare revisions