Körexempel
==============================================================
Starting image `/sw/allegro-4.2/bin/allegro-cl'
with no arguments
in directory `/home/stesv/lisp/Allegro/'
on machine `maj17.ida.liu.se'.
Allegro CL 4.2 [SPARC; R1] (6/2/95 16:20)
Copyright (C) 1985-1993, Franz Inc., Berkeley, CA, USA. All Rights Reserved.
;; Optimization settings: safety 1, space 1, speed 1, debug 2
;; For a complete description of all compiler switches given the current
;; optimization settings evaluate (explain-compiler-settings).
;; Starting socket daemon and emacs-lisp interface...
USER(1): :ld ~aid/labbar/aima/aima
; Loading /home/aid/labbar/aima/aima.lisp.
; Fast loading /home/aid/labbar/aima/utilities/utilities.fasl.
; Fast loading /home/aid/labbar/aima/utilities/binary-tree.fasl.
; Fast loading /home/aid/labbar/aima/utilities/queue.fasl.
; Fast loading /home/aid/labbar/aima/utilities/test.fasl.
; Fast loading /home/aid/labbar/aima/utilities/cltl2.fasl.
USER(2): (aima-load 'agents)
; Fast loading /home/aid/labbar/aima/agents/basic-env.fasl.
; Fast loading /home/aid/labbar/aima/agents/grid-env.fasl.
; Fast loading /home/aid/labbar/aima/agents/vacuum.fasl.
; Fast loading /home/aid/labbar/aima/agents/wumpus.fasl.
; Fast loading /home/aid/labbar/aima/agents/test.fasl.
t
USER(3): (test 'agents)
;;; Test agents in the vacuum and wumpus worlds.
;;; Here is how to create and print a vacuum world
> (setq vw (make-vacuum-world))
#<Vacuum World; Step: 0, Agents: a=0>
> (print-environment-map vw)
!---!---!---!---!---!---!---!---!
7 ! # ! # ! # ! # ! # ! # ! # ! # !
!---!---!---!---!---!---!---!---!
6 ! # ! * ! * ! ! ! ! ! # !
!---!---!---!---!---!---!---!---!
5 ! # ! * ! * ! ! * ! ! ! # !
!---!---!---!---!---!---!---!---!
4 ! # ! ! ! * ! ! * ! ! # !
!---!---!---!---!---!---!---!---!
3 ! # ! ! * ! ! ! * ! ! # !
!---!---!---!---!---!---!---!---!
2 ! # ! ! ! * ! ! ! ! # !
!---!---!---!---!---!---!---!---!
1 ! # ! a ! ! ! ! ! ! # !
!---!---!---!---!---!---!---!---!
0 ! # ! # ! # ! # ! # ! # ! # ! # !
!---!---!---!---!---!---!---!---!
0 1 2 3 4 5 6 7
nil
;;; Here's one way to run it
> (run-eval-environment vw)
#<Vacuum World; Step: 1, Agents: a=-1>
;;; We can also run random vacuum worlds with this:
> (run-vacuum)
#<Vacuum World; Step: 41, Agents: a=359>
;;; There are optional args to control execution and printing:
> (run-vacuum :display t :max-steps 10)
!---!---!---!---!---!---!---!---!
7 ! # ! # ! # ! # ! # ! # ! # ! # !
!---!---!---!---!---!---!---!---!
6 ! # ! ! ! ! ! ! ! # !
!---!---!---!---!---!---!---!---!
5 ! # ! ! ! ! ! ! ! # !
!---!---!---!---!---!---!---!---!
4 ! # ! ! ! * ! ! ! ! # !
!---!---!---!---!---!---!---!---!
3 ! # ! ! ! * ! * ! ! ! # !
!---!---!---!---!---!---!---!---!
2 ! # ! ! ! ! ! * ! ! # !
!---!---!---!---!---!---!---!---!
1 ! # ! a ! * ! * ! * ! ! ! # !
!---!---!---!---!---!---!---!---!
0 ! # ! # ! # ! # ! # ! # ! # ! # !
!---!---!---!---!---!---!---!---!
0 1 2 3 4 5 6 7
Time step 1:
Agent a=-1 perceives (nil nil home)
and does shut-off
#<Vacuum World; Step: 1, Agents: a=-1>
;;; VACUUM-TRIALS compares agents on random worlds. This takes a few seconds.
> (vacuum-trials)
-63.20 average for reactive-vacuum-agent
-405.00 average for random-vacuum-agent
(-63.2 -405.0)
;;; Now for the wumpus world
> (print-environment-map (make-wumpus-world))
!---!---!---!---!---!---!
5 ! # ! # ! # ! # ! # ! # !
!---!---!---!---!---!---!
4 ! # ! ! ! ! ! # !
!---!---!---!---!---!---!
3 ! # !O$ ! ! ! ! # !
!---!---!---!---!---!---!
2 ! # ! W ! ! ! ! # !
!---!---!---!---!---!---!
1 ! # ! A ! ! O ! ! # !
!---!---!---!---!---!---!
0 ! # ! # ! # ! # ! # ! # !
!---!---!---!---!---!---!
0 1 2 3 4 5
nil
> (run-wumpus)
#<Wumpus World; Step: 28, Agents: a=-10028>
0
USER(4):
24-Jan-96 11:29