In order照順序
Watch the lit line move down the program. Do you see a group of four instructions that keeps coming back?
看亮起來的那一行一路往下走。你有沒有發現,有四條指令一直重複出現?
How Computers Work · Unit 3 · Lesson 9 · 電腦概論 單元三 第九課
A small robot on a floor of squares does exactly what its program says, one instruction at a time. Watch it walk a staircase in fifteen instructions, then in five. Leave one instruction out and see where it ends up. Then write your own programs for three levels: in order, with a repeat, and with a question.
格子地板上的一台小機器人,完全照程式說的做,一次一條指令。看它用十五條指令走一段階梯,再看它只用五條;漏掉一條,看它最後停在哪裡。接著自己寫程式闖三關:照順序、用重複、會問問題。
A program is a list of instructions, in order, with nothing left unclear. The computer does exactly what the program says. It does not guess what you meant. Three ideas are enough to build one: do things in order, repeat things, and choose what to do by asking a question.
程式是一串照順序排好、沒有任何含糊地方的指令。電腦完全照程式說的做,不會去猜你的意思。組出一個程式只需要三個觀念:照順序做、重複做、先問一個問題再決定做什麼。
3D Model · 3D 模型
The robot understands only a few instructions: forward, turn left, turn right, repeat, and “if there is a wall ahead.” Choose one of the four programs on the right and press Run. The line the robot is carrying out lights up. Compare the first two programs: they do the same walk. Then run the third, which has one line missing, and the fourth, which works in two different rooms.
機器人只聽得懂幾種指令:前進、左轉、右轉、重複,還有「如果前面是牆」。在右邊四個程式裡選一個,按「執行」,機器人正在做的那一行會亮起來。比一比前兩個程式:它們走的是同一段路。再跑第三個(漏了一行),和第四個(在兩個不同的房間都走得到)。
Drag to turn · 拖曳旋轉
This 3D model needs WebGL, which this browser does not support. The program list and the buttons below still work, and so do the reading and the games.
這個瀏覽器不支援 WebGL,無法顯示 3D 模型;下面的程式清單和按鈕照樣能用,課文和小遊戲也都能用。
A teaching model. The robot’s instructions are a tiny language we made up for this lesson; it is not a real programming language. Real programs are written in languages such as Python and are then translated, in several stages, into machine instructions like the ones in Lesson 6. In the model a mistake is easy to see, because the robot ends up in the wrong place. In a real program a mistake can be much harder to notice.
這是教學用的示意模型。機器人的指令是我們為這一課自己設計的小語言,不是真的程式語言。真的程式是用 Python 這類語言寫的,再分好幾個階段翻譯成第六課那種機器指令。在模型裡,錯誤很容易看出來,因為機器人停在不對的地方;真的程式裡,錯誤可能難發現得多。
Model and code are drawn and programmed by My Culture Connect. The robot’s rules and every program on this page are tested in tools/computers/test/robot.test.mjs.
模型與程式由人師教育協會自行繪製、撰寫;機器人的規則和這一頁每一個程式都有自動測試(tools/computers/test/robot.test.mjs)。
Reading · 英文閱讀
In Lesson 6 you watched a processor fetch an instruction, carry it out, and fetch the next one. But where do the instructions come from? People write them. A list of instructions written for a computer is called a program. An encyclopedia describes a program as an unambiguous, ordered sequence of instructions. Two words there matter most: ordered, and unambiguous.
Think of a small robot on a floor of squares. It understands only three instructions: forward, turn left, and turn right. To send it to a flag, you write the instructions one under another, and the robot carries them out from top to bottom. The order matters. “Forward, then turn left” and “turn left, then forward” end on different squares.
The robot does exactly what is written. If you leave out one “turn right,” it does not notice. It carries on and finishes somewhere else. If you tell it to go forward when a wall is in the way, it walks into the wall. A mistake in a program is called a bug, and finding and fixing it is called debugging. When a program goes wrong, it is usually because the computer did just what it was told.
Often a program does the same thing again and again. To climb four stairs, the robot does “forward, turn left, forward, turn right” over and over. Written out one by one, that is a long list. It is better to write those four once and say “repeat 4 times.” This is called a loop. The program becomes shorter, and it is easier to read and to change.
Sometimes the right move depends on what the robot finds. So a program can ask a question: “If there is a wall ahead, turn left.” The robot checks, and it does the inside part only when the answer is yes. A program with a question in it can work in rooms its writer has never seen. In the same way, a real program can wait to see which key you press.
These are the three building blocks: doing things in order, repeating, and choosing. Real programs are written in programming languages such as Python, and then they are translated, in several stages, into the machine language of Lesson 6. A game or a web browser may have millions of lines. But line by line, it is still someone’s instructions, carried out exactly.
Questions · 閱讀理解
What is a program, and which two words in the encyclopedia’s description matter most?
The robot ends up in the wrong place. Whose mistake is it, and why?
What are the three building blocks of a program? Give an example of each from the robot.
Words & Phrases · 生字及片語
Quick Check · 小測驗
1. What is a program?
2. You leave out one instruction. What does the robot do?
3. What is a loop for?
4. “If there is a wall ahead, turn left.” When does the robot turn left?
5. What is debugging?
Try It in the Model · 在模型裡試試
Use “One step” to go through any program slowly, one instruction at a time.
想慢慢看的話,用「一次一步」,一條指令一條指令地走。
Watch the lit line move down the program. Do you see a group of four instructions that keeps coming back?
看亮起來的那一行一路往下走。你有沒有發現,有四條指令一直重複出現?
The robot takes the same fifteen steps. How many instructions did someone have to write this time?
機器人走的是一樣的十五步。這一次,寫的人要寫幾條指令?
One “turn right” was left out. Where does the robot finish? Can you tell which line is missing?
有一條「右轉」被漏掉了。機器人最後停在哪裡?你看得出漏的是哪一行嗎?
Before each step the robot checks for a wall. After it reaches the flag, send the same program into the other room.
機器人每走一步之前都先看看有沒有牆。它走到旗子之後,把同一個程式換到另一個房間再跑一次。
Game · 小遊戲
Three levels, one for each building block. Tap the blocks to add instructions to your program. Tap an instruction in your program to take it out. Then press Run and watch the robot do exactly what you wrote.
一共三關,三種積木各一關。點積木,把指令加進你的程式;點程式裡的指令,可以把它拿掉。然後按「執行」,看機器人完全照你寫的做。
Your program · 你的程式 (0 instructions · 條指令)
Blocks · 積木
The robot stops as soon as it reaches the flag, so repeating a few more times than needed does no harm. If it walks into a wall, the whole program stops there.機器人一走到旗子就會停下來,所以重複的次數比需要的多幾次沒有關係。如果它撞到牆,整個程式就停在那裡。
Game · 小遊戲
Be the computer. Eight tiny programs made only of turns. Carry out each one in your head, exactly as written, and say which way the robot faces at the end.
換你當電腦。八個只有轉彎的小程式。在腦子裡一條一條照著做,說出機器人最後面向哪一邊。
Right on the first try · 第一次就答對 0 / 0
Stories Behind Programs · 程式的故事
Four short stories about writing instructions for machines.
關於「寫指令給機器」的四個小故事。
1843
In 1843 the English mathematician Ada Lovelace translated an article about Charles Babbage’s Analytical Engine and added long notes of her own. According to Britannica, they included a description of how the machine could be programmed to compute a series of numbers called Bernoulli numbers. Babbage built only a small part of the engine, but Lovelace has been called the first computer programmer, and a programming language, Ada, was named for her.
1843 年,英國數學家愛達・勒芙蕾絲(Ada Lovelace)翻譯了一篇介紹巴貝奇「分析機」的文章,還加上自己寫的長篇註解。根據大英百科,註解裡描述了怎麼替這台機器寫程式,算出一串叫做白努利數的數。巴貝奇只造出分析機的一小部分,但勒芙蕾絲被稱為第一位電腦程式設計師,後來還有一種程式語言以她的名字命名,叫 Ada。
Logo
The robot in this lesson has a famous ancestor. Britannica explains that the language Logo began in the late 1960s, and that Seymour Papert and others used it at MIT to teach mathematical thinking to schoolchildren. It featured “turtle graphics”: an object was moved around the screen by commands such as “left 90” and “forward,” which describe moves from where the turtle is and the way it is facing. The name came from an early project to program a turtle-like robot.
這一課的機器人有個有名的前輩。大英百科說,Logo 這種語言誕生於 1960 年代後期,派普特(Seymour Papert)等人在麻省理工學院用它教小學生數學思考。它的特色是「海龜繪圖」:用「left 90」「forward」這樣的指令讓一個東西在螢幕上移動,這些指令說的是從海龜現在的位置、面向的方向出發要怎麼動。這個名字來自早期一個替像海龜的機器人寫程式的計畫。
September 9, 1947
The Computer History Museum tells this story. On September 9, 1947, a team working on the Harvard Mark II computer found a moth caught between the contacts of a relay. They taped it into the logbook, and someone wrote beside it: “First actual case of bug being found.” The programmer Grace Hopper was there and later made the story famous in her lectures. The word was not new: the museum notes that “bug” had been used for a fault in a machine since the 1800s.
這個故事出自電腦歷史博物館。1947 年 9 月 9 日,操作哈佛馬克二號電腦的團隊發現一隻飛蛾卡在繼電器的接點之間。他們把牠用膠帶貼進工作日誌,旁邊有人寫了一句:「第一次真的找到蟲(bug)。」程式設計師葛麗絲・霍普(Grace Hopper)當時在場,後來在演講裡把這個故事講得家喻戶曉。這個詞並不是那時才有的:博物館指出,用 bug 來稱呼機器的毛病,從 1800 年代就開始了。
Translation · 翻譯
A processor understands only machine language, the kind of simple instructions you met in Lesson 6. Britannica explains that a program is first written in a language suited to the task, and is then translated, commonly in several stages, into a coded program the computer can carry out directly. The translating is done by other programs. There are even programs called debuggers, which run a program a little at a time so that the programmer can check whether it is working correctly.
處理器只懂機器語言,也就是第六課那種簡單的指令。大英百科說,程式會先用適合那件工作的語言寫出來,再翻譯(通常分好幾個階段)成電腦可以直接執行的編碼程式。做翻譯的,是別的程式。甚至還有一種叫除錯器(debugger)的程式,可以把一個程式一小段一小段地執行,讓程式設計師檢查它運作得對不對。
Myth vs. Fact · 常見迷思
✗ Myth · 迷思A computer understands what you mean.電腦懂你的意思。
✓ Fact · 事實It carries out the instructions it is given, exactly. That is why a program has to be unambiguous: every instruction must have only one meaning.它只是一絲不差地執行拿到的指令。所以程式不能有含糊的地方:每一條指令都只能有一個意思。
✗ Myth · 迷思When a program gives the wrong result, the computer made a mistake.程式的結果不對,是電腦弄錯了。
✓ Fact · 事實Usually the computer did just what it was told, and the mistake is in the instructions. That is what a bug is.通常是電腦完全照指示做了,錯在指令本身。這就是 bug。
✗ Myth · 迷思A longer program is a better program.程式越長越厲害。
✓ Fact · 事實The robot’s staircase takes fifteen instructions written out one by one, and five with a repeat. The short one is easier to read, to check, and to change.機器人走階梯,一條一條寫要十五條指令,用「重複」只要五條。短的那個比較好讀、好檢查、也好改。
✗ Myth · 迷思Programs began with electronic computers.有了電子電腦,才有程式。
✓ Fact · 事實Ada Lovelace described how to program a machine in 1843, about a hundred years before electronic computers. A program is an idea: ordered, unambiguous instructions.愛達・勒芙蕾絲在 1843 年就描述了怎麼替一台機器寫程式,比電子電腦早了大約一百年。程式是一個觀念:照順序、不含糊的指令。
Remember It · 記憶口訣
The computer does what you wrote, not what you meant.
電腦做的是你寫的,不是你想的。
Three building blocks.
三種積木。
A loop saves writing the same lines again.
迴圈讓你不必把同樣的幾行再寫一遍。
A bug is in the instructions, not in the machine.
bug 在指令裡,不在機器裡。
Before You Start · 動手之前
Classroom Activity 1 · 課堂活動一
You need · 準備材料
Steps · 步驟
The rule that makes this work is that the robot may not think. Students quickly find how much they leave unsaid when they give instructions. In Taiwan’s junior high Information Technology curriculum, this lesson matches “Program design”: 資 P-IV-1, basic concepts of programming languages, and 資 P-IV-2, structured programming, whose notes list sequence, selection, and repetition.
這個活動成立的關鍵,是機器人「不可以動腦」。學生很快會發現,自己下指令的時候有多少話沒說出口。對照十二年國教國中「資訊科技」的學習內容,這一課對應「程式設計」主題:資 P-IV-1 程式語言基本概念、功能及應用,以及資 P-IV-2 結構化程式設計(說明列有循序、選擇結構與重複結構)。
Classroom Activity 2 · 課堂活動二
You need · 準備材料
Steps · 步驟
If the coin goes wrong, do not explain what you meant. Fix the program on the paper and let your friend run it again. That is debugging. Then play Level 2 on this page and compare: a staircase takes 5 instructions with a repeat.
硬幣走錯的時候,不要用嘴巴解釋你的意思。把紙上的程式改好,請朋友再跑一次——這就是除錯。接著玩這一頁的第二關比一比:階梯用「重複」只要 5 條指令。
Go Further · 延伸閱讀
Sources · 資料出處
Facts on this page were checked against these sources (October 2026); the robot and its small language are our own, and every program on the page is tested · 本頁的事實依下列資料查證(2026 年 10 月);機器人和它的小語言是我們自己設計的,頁面上每一個程式都有測試