User Tools

Site Tools


public:t-622-arti-11-1:lab_1_materials

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:t-622-arti-11-1:lab_1_materials [2011/01/12 11:09] angelopublic:t-622-arti-11-1:lab_1_materials [2024/04/29 13:33] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
   * Material:   * Material:
 +    * [[http://www-formal.stanford.edu/jmc/history/lisp/lisp.html|The history of Lisp]] written by its author John McCarthy (interesting read)
     * Lisp Tutorial: [[http://cs.gmu.edu/~sean/lisp/LispTutorial.html|Part I]], [[http://cs.gmu.edu/~sean/lisp/LispTutorial2.html|Part II]] and [[http://cs.gmu.edu/~sean/lisp/LispTutorial3.html|Part III]].     * Lisp Tutorial: [[http://cs.gmu.edu/~sean/lisp/LispTutorial.html|Part I]], [[http://cs.gmu.edu/~sean/lisp/LispTutorial2.html|Part II]] and [[http://cs.gmu.edu/~sean/lisp/LispTutorial3.html|Part III]].
     * Lisp cheat sheet: ([[http://www.apl.jhu.edu/~hall/Lisp-Notes/Introductory-Lisp-Overview.ps|PS Format]]) or ({{:public:t-622-arti-09-1:introductory-lisp-overview.pdf|PDF Format}}).     * Lisp cheat sheet: ([[http://www.apl.jhu.edu/~hall/Lisp-Notes/Introductory-Lisp-Overview.ps|PS Format]]) or ({{:public:t-622-arti-09-1:introductory-lisp-overview.pdf|PDF Format}}).
Line 8: Line 9:
      * A freely available book on Lisp: [[http://gigamonkeys.com/book/|Practical Common Lisp]].      * A freely available book on Lisp: [[http://gigamonkeys.com/book/|Practical Common Lisp]].
   * IDE and Lisp Implementations:   * IDE and Lisp Implementations:
-    * [[http://common-lisp.net/project/lispbox/|Lispbox]], an Emacs + SLIME + Common Lisp easy to install package: ([[http://common-lisp.net/project/lispbox/test_builds/lispbox-0.7-sbcl-1.0.38.tar.gz|Linux 32-bit]], [[http://common-lisp.net/project/lispbox/test_builds/lispbox-0.7-x64-sbcl-1.0.38.tar.gz|Linux 64-bit]]), ([[http://common-lisp.net/project/lispbox/test_builds/lispbox-0.7-ccl-1.5-windowsx86.zip|Win32]]) or ([[http://common-lisp.net/project/lispbox/test_builds/Lispbox-0.7-with-ccl-1.5-darwinx86.dmg|MAC OS X]]).+    * Lispbox 0.7 (Stable Release), an Emacs + SLIME + Common Lisp easy to install package ([[http://www.ru.is/faculty/hannes/share/lispbox07.exe|Win32]]) or ([[http://www.ru.is/faculty/hannes/share/Lispbox-0.7-with-acl81_express.dmg|MAC OS X]]). 
 +      * [[http://common-lisp.net/project/lispbox/|Lispbox]] (Latest Unstable Beta Version): ([[http://common-lisp.net/project/lispbox/test_builds/lispbox-0.7-sbcl-1.0.38.tar.gz|Linux 32-bit]], [[http://common-lisp.net/project/lispbox/test_builds/lispbox-0.7-x64-sbcl-1.0.38.tar.gz|Linux 64-bit]]), ([[http://common-lisp.net/project/lispbox/test_builds/lispbox-0.7-ccl-1.5-windowsx86.zip|Win32]]) or ([[http://common-lisp.net/project/lispbox/test_builds/Lispbox-0.7-with-ccl-1.5-darwinx86.dmg|MAC OS X]]).
     * Eclipse Lisp Plugin (Win32, MAC OS X and Linux): [[http://sourceforge.net/projects/dandelion-ecl/|Dandelion]].     * Eclipse Lisp Plugin (Win32, MAC OS X and Linux): [[http://sourceforge.net/projects/dandelion-ecl/|Dandelion]].
     * Emacs reference card: ([[http://refcards.com/docs/wingb/xemacs/xemacs-refcard-a4.pdf|PDF Format]]).     * Emacs reference card: ([[http://refcards.com/docs/wingb/xemacs/xemacs-refcard-a4.pdf|PDF Format]]).
Line 14: Line 16:
 To work through these exercises, refer to the above material for more information. To work through these exercises, refer to the above material for more information.
  
-  - **Emacs and REPL:**\\ Install [[http://common-lisp.net/project/lispbox/|LispBox]] on your computer and start it up. The upper window is the Lisp REPL (read-eval-print loop) where you can enter Lisp expressions and have them evaluated.+  - **Emacs and REPL:**\\ Install [[http://common-lisp.net/project/lispbox/|LispBox]] on your computer and start it up. The lower window is the Lisp REPL (read-eval-print loop) where you can enter Lisp expressions and have them evaluated.
   - **Hello World:**\\ Type an expression that prints "Hello World!" on the screen. \\ <code lisp>   - **Hello World:**\\ Type an expression that prints "Hello World!" on the screen. \\ <code lisp>
 ;; HINT: A typical print expression ;; HINT: A typical print expression
Line 62: Line 64:
 '(:x 0 :y 0 :dirty T) '(:x 0 :y 0 :dirty T)
 </code> Here, **'':x''** and **'':y''** are the location of the agent and **'':dirty''** tells us if the current square has dirt or not. \\  </code> Here, **'':x''** and **'':y''** are the location of the agent and **'':dirty''** tells us if the current square has dirt or not. \\ 
-    - Write a new agent program called **''random-agent-program''**, that has two options: Walk around the environment randomly or remain idle when it finds a clean square; Suck up dirt when it finds it. \\ Your agent program should return one of the symbols **''LEFT''**, **''RIGHT''**, **''UP''**, **''DOWN''**, **''SUCK''** or **''IDLE''**.  You can either write your function directly in the REPL or add it to the file. If you add it to the file, you have to save the file (keyboard shortcut is Ctrl+X, Ctrl+S in emacs) and then reload the file in the REPL (recommended option). Instead of typing the load command again, you can reload the file by hitting Ctrl+C, Ctrl+L while the file window is active.\\ <code lisp>+    - Write a new agent program called **''random-agent-program''**, that has two options: Walk around the environment randomly or remain idle when it finds a clean square; Suck up dirt when it finds it. \\ Your agent program should return one of the symbols **''LEFT''**, **''RIGHT''**, **''UP''**, **''DOWN''**, **''SUCK''** or **''IDLE''**.  You can either write your function directly in the REPL or add it to the file. If you add it to the file, you have to save the file (keyboard shortcut is Ctrl+X, Ctrl+S in emacs) and then reload the file in the REPL (recommended option).\\ <code lisp>
 ;; HINT: Getting a random value. ;; HINT: Getting a random value.
 ;; This function returns a random nonnegative number less than number, and of the same type (either integer or floating-point) ;; This function returns a random nonnegative number less than number, and of the same type (either integer or floating-point)
Line 85: Line 87:
     </code>        </code>   
     - Use the **''SIMULATE''** and **''SIMULATE-QUIET''** functions from the last step to test your new agent program. Remember to  Does it give better performance evaluation than the old one? \\     - Use the **''SIMULATE''** and **''SIMULATE-QUIET''** functions from the last step to test your new agent program. Remember to  Does it give better performance evaluation than the old one? \\
-  - **Writing a performance evaluation function:** \\ The function **''EXAMPLE-MEASURE''** shows how simple performance evaluation functions look. This function takes an environment and an agent as parameters, and returns a number indicating the performance of the agent so far. \\ Both the agent and the environment are so called **''structures''**. Their fields are defined in the file **''agents.lisp''** with calls to the **''DEFSTRUCT''** macro. This macro defines a function for constructing an instance of the structure, e.g. for the **''ENV''** structure, this function is called **''MAKE-ENV''**. \\ The macro also defines functions for accessing the fields of a structure, e.g. the **''width''** field of an '**'ENV''** structure in the variable **''env''** can be accessed using **''(env-width env)''**. \\ Write a performance evaluation function called random-agent-measure that awards 10 points for every clean square but deducts one point for every move the agent makes. The number of moves is stored in the **''moves-so-far''** field. Now run the simulations again. How does this change the evaluation score? Can you think of ways to change the agent program so that it scores better with this new evaluation function?+  - **Writing a performance evaluation function:** \\ The function **''EXAMPLE-MEASURE''** shows how simple performance evaluation functions look. This function takes an environment and an agent as parameters, and returns a number indicating the performance of the agent so far. \\ Both the agent and the environment are so called **''structures''**. Their fields are defined in the file **''agents.lisp''** with calls to the **''DEFSTRUCT''** macro. This macro defines a function for constructing an instance of the structure, e.g. for the **''ENV''** structure, this function is called **''MAKE-ENV''**. \\ The macro also defines functions for accessing the fields of a structure, e.g. the **''width''** field of an **''ENV''** structure in the variable **''env''** can be accessed using **''(env-width env)''**. \\ Write a performance evaluation function called **''random-agent-measure''** that awards 10 points for every clean square but deducts one point for every move the agent makes. The number of moves is stored in the **''moves-so-far''** field. Now run the simulations again. <code lisp> 
 +;; HINT: counting the number of times an object appears in a sequence: (count object sequence keywords...) 
 +;; For example, we can count the number of times the character 'l' appears in the Sequence "Hello World" 
 +(count #\l "hello world"
 +</code> <code lisp> 
 +;; The count function also has count-if and count-if-not variants. 
 +;; (count-if test-predicate sequence keywords...) counts the number of times in which test-predicate (a function pointer) returns true  
 +;; for the elements in the sequence.  
 +;; Counting the number of clean squares (in agents.lisp) 
 +;; Note: the not function has the following syntax (not x) and returns T if x is NIL, otherwise returns NIL 
 +(count-if #'not (env-dirt-vector env))) 
 +</code> How does this change the evaluation score? Can you think of ways to change the agent program so that it scores better with this new evaluation function?
/var/www/cadia.ru.is/wiki/data/attic/public/t-622-arti-11-1/lab_1_materials.1294830584.txt.gz · Last modified: 2024/04/29 13:32 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki