Our world is built by the setup procedure that you will find in the file setup.scm. You are the deity of this world. When you call setup with your name, you create the world. It has rooms, corridors, and people from building NE43, and it has an avatar (a manifestation of you, the deity, as a person in the world). The avatar is under your control. It goes under your name and is also the value of the globally-accessible variable me. Each time the avatar moves, simulated time passes in the world, and the various other creatures in the world take a time step. The way this works is that there is a clock that sends a clock-tick message to all autonomous persons. (The avatar is not an autonomous person; it is directly under your control.) In addition, you can cause time to pass by explicitly calling the clock. If the global variable *deity-mode* is true you will see everything that happens in the world; if *deity-mode* is false you will only see things happening in the same place as the avatar.
To make it easier to use the simulation we have included a convenience procedure, thing-named for referring to an object at the location of the avatar. This procedure is defined at the end of the file setup.scm.
Here is a sample run of the system. Rather than describing what's happening, we'll leave it to you to examine the code that defines the behavior of this world and interpret what is going on.
(setup 'George-Spelvin) ---Tick 0--- You are in a wild long corridor You see nothing in here. The exits are: up in-408 in-430 in-429 in-428 . ;Value: ready (ask (ask me 'location) 'name) ;Value: ne43-4th (ask me 'go 'in-428) george-spelvin says -- Hi gjs ---Tick 1--- You are in a cluttered laboratory office You see: gjs sicp chalk . The exits are: south out . ;Value: ok (ask (thing-named 'chalk) 'owner) ;Value: nobody (ask me 'take (thing-named 'chalk)) george-spelvin says -- I take chalk ;Value: #t (ask me 'go 'out) george-spelvin says -- Hi becky ---Tick 2--- You are in a wild long corridor You see: chalk becky . The exits are: up in-408 in-430 in-429 in-428 . ;Value: ok (ask me 'go 'in-429) george-spelvin says -- Hi hal ---Tick 3--- You are in a carefully arranged office You see: chalk hal sicp chalk quiz2 . The exits are: north out . ;Value: ok (ask (thing-named 'quiz2) 'owner) ;Value: #[compound-procedure 12] (ask (ask (thing-named 'quiz2) 'owner) 'name) ;Value: hal (ask me 'take (thing-named 'quiz2)) hal says -- I lose quiz2 hal says -- Yaaaah! I am upset! george-spelvin says -- I take quiz2 ;Value: #t (run-clock 5) ---Tick 4--- gjs says -- Hi george-spelvin hal ---Tick 5--- ---Tick 6--- ---Tick 7--- ---Tick 8--- ;Value: done (set! *deity-mode* #t) ;Value: () (run-clock 3) ---Tick 9--- ---Tick 10--- eric moves from ne43-7th to ne43-4th At ne43-4th : eric says -- Hi gjs jim gjs moves from ne43-4th to ne43-7th ---Tick 11--- becky moves from ne43-430 to ne43-4th At ne43-4th : becky says -- Hi eric jim jill moves from ne43-711 to ne43-7th At ne43-7th : jill says -- Hi gjs ;Value: done
We have provided you with an interesting kind of autonomous person, a robot. A robot can be created at any place that you have access to. The robot will sit around, and do nothing in particular, unless it is given a method to execute on clock ticks. In the file search-rooms.scm we provide the kernel of a program that will direct a robot to explore a world, looking for a thing with a given name. At the end of the file is an example where the robot is constructed at the location of the avatar, and it is programmed to look for an object whose name is the-goal.