練習目標:
1. A natural similarity exists between navigating the directories in a file system as compared to navigating the "rooms" in a text-based adventure game.
一個文件夾就像文字形冒險遊戲裡的一間房間一樣
2. 寫一個遊戲
3.本次練習重點有二:'alias' command 和 conditional execution of commands (via the && and || method)
練習細節:
1. 嘗試由 emacs-based game called dunnet 寫出一個修改版本
2. 如果想玩玩看,在終端機打command $ emacs -batch -l dunnet 就可以開啟遊戲
3. room中可能會包含object,而每個object會有一個敘述
4. 只有第一次進入某 room 後會有該room的長敘述,之後出去再重新進入房間就不會再有長敘述了,除非 > l 否則不會再敘述一次(長敘述內容大概有room是哪裡,以及裡面有哪些物件)
5. 如何實作物件敘述 "x [object]": 一個房間為一個 directory,而此房間中的物件為directory下的一個file(一個物件一個file),file中放此物件的敘述,並將 "cat" alias 為 "x"
we will place files named "garbage" and "disposal" into this directory. These files will contain the text "I see nothing special about that.". Second, we will implement the "x" command as an alias for "cat".
當沒有次物件時,會顯示"cat: trash: No such file or directory",而不是 "I don't know what that is.",但第一次練習還不用在意
6. 當room中有可以撿起來的物件時,不管是第幾次進入room中,都會出現此物件之敘述,例如: "There is a valuable amethyst here.",本次練習不會實作撿起來,但需要實作此種敘述
7. 有些房間當進入房間時會鎖住,此種房間不會有長敘述,只會顯示"Classroom",若想出去則顯示"The door is locked."
8. 265-288看不懂,當經過房間時不會顯示詳細訊息,但是可以透過"l"指令去察看詳細訊息,這是因為老師已經經過過這些區域了,因為先前必須要先經過這區域才能夠去捷運站
9. 有些物件會有兩個名字,例如:dinosaur skeleton,可以叫dinosaur 或 skeleton
10. 366-396有時候,當走出門時,可能會有牆擋住回去的路 (a gate blocks the way back to the Museum.)
11. 396我們需要實做一條向south的路
12. bin = bins 單複數相同
13. quit離開遊戲
14. 528行開始講解如何實作
如何實作:
534有一張地圖
1. south為右邊
2. 起點為X,其餘地點按照經過順序由A開始標註
3. first step of implementing the game is to create the directories for the rooms 為每個房間創一個檔案夾做為代表
4. In each directory, we will also place two types of files. 每個檔案夾是一個房間,且包含兩種檔案
(1) One type of file is for objects. for example, since the classroom contains a blackboard, there will be a file called "blackboard" in that directory. 描述物件的檔案
(2) The other type of file is for display information.(hidden files)The display information includes room descriptions. and these descriptions have two parts: 描述房間的檔案,有兩個
● the part that displays every time you enter the room, 每次進入房間都會有的描述
● and the part that displays only the first time you enter the room (or when you use the "l" command). 第一次或是指令l才會有的描述
These two parts will be stored in separate text files. 此兩個房間描述放在不同檔案裡
5. there are two special rooms that have another display message. 有兩種房間會一直提示訊息
(1) The computer room always displays the message: "The panel lights are flashing in a seemingly organized pattern."
(2) the bottom of the subway stairs displays the message: "There is a valuable amethyst here."
These two messages will be produced by additional hidden files put into those two directories.
6. 595 是實作例子
7. 檔案夾名稱是能走的方向n e s t u d
8. 676 如何使走過的門關上,不能回頭,回頭路的方向不是資料夾,而是一個可執行的文件
9. chmod設定個文件與資料夾權限
10. 755 : there were dotted lines connecting rooms J and H. You must create symbolic links between these two directories.
So as to test your understanding, I require you to make one of the links as an absolute path, and the other as a relative path (the choice of which is to be which is up to you).
11.物件 Each of these needs to copy into one of your directories.
But the three files "computer", "cabinet", and "vax" need to copy into two
directories.
12. TempDir.
This will be a convenient place to store the temporary data you will be making
13. Once you have created these directories with their files, create a tar file of
it all, named <your student ID>.tar. This is one of the files that you will
need to submit.
14.
I will give you a helpful hint. If you accidentally missed creating one of the
directories, it is helpful to know that directories can be moved like files:
% mkdir F1
% mkdir F1/F2
% mkdir F1/F2/F3
% mkdir G1
% cd G1
% mv ../F1/F2 .
% cd F2/F3
% pwd
~/G1/F2/F3
創建完目錄部分,接下來是指令部分:
1. 移動方法: 搞懂description以及done何時呈現
(1)creating aliases for the 10 directions.These aliases are, at their core, "cd" commands.
alias e='cd e;cat .description?1'
(2)display the description for the new room. This is accomplished by using "cat" with a properly chosen wildcard pattern.
alias l='cat .description?2'
alias x*='cat 物件'
(3) keeping track of which rooms have been visited.
當已經走過房間後,需要把description檔案改成done檔案(刪除description?建立done??更改指令alias? cat .d*2)
The other aspect of movement is keeping track of which rooms have been visited.
As we have seen, this is achieved by moving the .description?2 file to .done?2.
From the above, we see a difference. Instead of a file named ".descriptionG2",
the file is named ".doneG2". The reason for this is that this room has already
been visited.
是把description?2(比較長的描述)改掉而已,改成done?2
description0:物件描述
description1:每次都有的房間描述
description2:第一次才會有的房間描述
而某些檔案夾中會有原本就有的done檔案
那是代表,只有進入過此房間,才能夠看到描述
(避免鎖住的房間訊息看到)
新的done檔案上其實不需要有房間號,因為我們自己知道房間號,但本來就有的done檔案的房間號不用改掉
看到這裡 798
實作移動方法、SCRIPT FOR 別名、開始玩
開始練習:
首先,轉bash為tcah,cygwin.bat檔中的
bash --login -i
改為
tcsh -l
然後再termal裡打 $ tcsh -l
人情似乎有它固定的型態
太多要求
看似合理,理所當然
因此我苛責我自己
甚至苛責也是一種錯誤
-----------------------------
因為生為人
似乎總是有某些必須達到
"藉口"充斥我內心
接受輕飄的問罪
連自己都放不過自己
人情是否過於強大
道理是否過於綁架
----------------------------------
在我出生時就決定好的這些規則
我寧願爬回去
但要經過的那條線
卻令我恐懼
因此我寧願繼續徘徊
手足無措
卻總是錯
----------------------------------
與規則最相近的人
贏了人生
也輸了人生
---------------------------------
當我想放下
小是小事都是小事
在意在意何必在意
我以為妳怎麼了什麼嘛
害我這麼擔心
#那你問個屁
---------------------------------
一切都是小是因為世間有一套既定原理
超出規則的人
如何需要被問罪
誰該為誰負責
仔細問自己的心
卻發現大部分都由別人組成