Return to Video

The Furnace Bots | Think Like A Coder, Ep 3

  • 0:36 - 0:41
    Ethic and her robot Hedge agree
    to help the resistance leader, Adila,
  • 0:41 - 0:45
    sabotage the art-incinerating
    furnace-bots.
  • 0:45 - 0:46
    In exchange,
  • 0:46 - 0:50
    Adila promises to lead them
    to the first object of Ethic’s quest,
  • 0:50 - 0:55
    an artifact called the Node of Power.
  • 0:55 - 0:58
    Years ago, there was just
    one furnace-bot.
  • 0:58 - 1:01
    It had a 0 inside its furnace
    and an unknown,
  • 1:01 - 1:04
    randomly generated serial number.
  • 1:04 - 1:11
    Over time, the original self-replicated
    to produce more identical furnace-bots.
  • 1:11 - 1:16
    Each child inherited the original’s
    unknown serial number within its furnace,
  • 1:16 - 1:22
    and had a random, unique serial
    number of its own inscribed on its shell.
  • 1:22 - 1:26
    The second generation of furnace-
    bots also self-replicated in the same way,
  • 1:26 - 1:31
    always passing their own serial
    numbers to their offspring’s furnaces.
  • 1:31 - 1:35
    This continued on for many generations.
  • 1:35 - 1:40
    Today, each furnace-bot receives
    its orders from its parent.
  • 1:40 - 1:46
    So if Ethic can find the original 0 bot
    and somehow change its instructions,
  • 1:46 - 1:50
    she could take over
    the entire army, all at once.
  • 1:50 - 1:53
    Adila has the perfect solution:
  • 1:53 - 1:56
    a data crystal that she’s
    been carrying for years,
  • 1:56 - 1:59
    waiting for the right moment
    to activate it.
  • 1:59 - 2:03
    It contains a program designed
    to gain control of a bot
  • 2:03 - 2:06
    and give it new instructions.
  • 2:06 - 2:10
    But if it’s uploaded to any furnace-
    bot other than the original,
  • 2:10 - 2:13
    the 0 bot will override
    the instructions
  • 2:13 - 2:16
    and destroy the data crystal
    in the process.
  • 2:16 - 2:19
    The feeding is just
    a few minutes away,
  • 2:19 - 2:22
    and there’s only one
    chance to get this right.
  • 2:22 - 2:27
    Fortunately, Hedge’s ability
    to store data can help.
  • 2:27 - 2:28
    In programming,
  • 2:28 - 2:32
    a piece of information gets
    stored in something called a variable.
  • 2:32 - 2:39
    Variables are basically containers that
    hold onto numbers, words, or other values.
  • 2:39 - 2:45
    How does Ethic program Hedge to find
    the original 0 bot as quickly as possible?
  • 2:45 - 2:48
    Pause now to figure it out for yourself.
  • 2:50 - 2:51
    Here’s a hint.
  • 2:51 - 2:56
    Programs can be written to have
    as many variables as you need,
  • 2:56 - 2:59
    but you can solve this problem
    with just one.
  • 2:59 - 3:02
    Hedge can use it to store
    a serial number
  • 3:02 - 3:05
    and replace it with a new one
    as often as he needs.
  • 3:05 - 3:08
    Pause now to figure it out for yourself.
  • 3:10 - 3:15
    A key insight here is that Hedge
    doesn’t need to map out the entire
  • 3:15 - 3:18
    set of relationships to find
    the original furnace-bot.
  • 3:18 - 3:23
    If, for example, he gets lucky and picks
    the original one right away,
  • 3:23 - 3:24
    he’ll be done.
  • 3:24 - 3:26
    But if he starts with any other bot,
  • 3:26 - 3:31
    he can still find a path that leads
    straight back to the 0-bot
  • 3:31 - 3:34
    by following a simple set of instructions.
  • 3:34 - 3:38
    To help craft them, let’s first
    simplify the problem.
  • 3:38 - 3:41
    Let’s say there were only
    three furnace-bots;
  • 3:41 - 3:45
    a parent and two children, but you don’t
    know which is which.
  • 3:45 - 3:49
    You could have Hedge pick one
    at random and look inside its furnace.
  • 3:49 - 3:53
    Now, you know the family tree
    looks like this.
  • 3:53 - 3:57
    If the number inside the furnace is a 0,
    you’ve found the parent.
  • 3:57 - 4:01
    If not, then no matter
    which child you chose,
  • 4:01 - 4:04
    it must have the parent’s serial
    number in its furnace.
  • 4:04 - 4:11
    So in this scenario, you’re guaranteed
    to find the parent in one or two moves.
  • 4:11 - 4:14
    In actuality, there are many
    furnace-bots,
  • 4:14 - 4:16
    and you don’t know how
    many generations there are
  • 4:16 - 4:19
    nor what the family tree looks like.
  • 4:19 - 4:20
    But you don’t need to,
  • 4:20 - 4:24
    because Hedge can just keep repeating
    the same sequence of actions
  • 4:24 - 4:27
    until he gets to the original.
  • 4:27 - 4:29
    How? With a loop.
  • 4:29 - 4:33
    Hedge can pick any bot at random,
    look inside its furnace,
  • 4:33 - 4:36
    and store that serial
    number as a variable.
  • 4:36 - 4:40
    Then he’ll begin the following
    loop that will repeat
  • 4:40 - 4:42
    until the stored variable equals 0,
  • 4:42 - 4:46
    the furnace number of the original bot:
  • 4:46 - 4:51
    1. Find the bot whose shell serial number
    matches the stored number.
  • 4:51 - 4:54
    2. Look inside its furnace.
  • 4:54 - 4:59
    3. Store that new number,
    overwriting the old one.
  • 4:59 - 5:03
    Once the loop ends, we’ll know
    that Hedge has found the 0 bot,
  • 5:03 - 5:06
    so he should upload the control program.
  • 5:06 - 5:08
    So here’s what happens:
  • 5:08 - 5:11
    Hedge only takes 5 repetitions
    to find the original:
  • 5:11 - 5:16
    robot 733 has the 0 in its furnace.
  • 5:16 - 5:18
    In a blink of a mechanical eye,
  • 5:18 - 5:23
    the program spreads through the entire
    army, and Adila takes control.
  • 5:23 - 5:26
    She has the furnace-bots
    give off theatrical bouts of flame
  • 5:26 - 5:30
    to hide the fact that they’re now secretly
    safe-guarding
  • 5:30 - 5:33
    all of that artistic output.
  • 5:33 - 5:35
    Now that Ethic’s delivered
    the furnace-bots,
  • 5:35 - 5:38
    Adila honors her end of the deal.
  • 5:38 - 5:42
    She leads Ethic and Hedge
    to the location of the first artifact,
  • 5:42 - 5:45
    the Node of Power.
  • 5:45 - 5:48
    There, one thing is immediately clear:
  • 5:50 - 5:52
    they’ll have to steal it.
Title:
The Furnace Bots | Think Like A Coder, Ep 3
Speaker:
Alex Rosenthal
Description:

View full lesson: https://ed.ted.com/lessons/the-furnace-bots-think-like-a-coder-ep-3

This is episode 3 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:
05:56

English subtitles

Revisions Compare revisions