;;; world.ss for DrScheme ;;; Use Textual Language (MzScheme, includes R5RS) (require (lib "include.ss")) (define false #f) (define true #t) (define nil '()) (include "game.ss") ;;;============================================================================ ;;; You can extend this file to make more stuff part of your world. ;;;============================================================================ ;;;============================================================================ ;;; *CAVEAT* To keep your world consistent, whenever you change a procedure or ;;; redefine a person/place/etc you should reload this entire file ;;; into Scheme. This prevents you from having old-moldy folks running ;;; around who have not evolved to adhere to your modifications. To ;;; make this work out well, you should create little scripts at the ;;; end of this file to make the game evolve as you work through it. ;;; [See the bottom of this file for an example.] ;;;============================================================================ (initialize-clock-list) ;; Here we define the places in our world... ;;------------------------------------------ (define conf-room (make-place 'conf-room)) (define tom-office (make-place 'tom-office)) (define dept-office (make-place 'dept-office)) (define east-hall (make-place 'east-hall)) (define ken-office (make-place 'ken-office)) (define elevator-lobby (make-place 'elevator-lobby)) (define computer-lab (make-place 'computer-lab)) (define systems-lab (make-place 'systems-lab)) (define west-hall (make-place 'west-hall)) (define robot-lab (make-place 'robot-lab)) (define network-closet (make-place 'network-closet)) (define dungeon (make-place 'dungeon)) ;; The following isolated place is defined in GAME.SCM too but redefined ;; here so you can just "zap" altered definitions there then re-evaluate this ;; file w/o worrying about forgetting to update any places. ;; ;; Consequently, to be consistent, if you find it appropriate to define any new ;; places in GAME.SCM, you should likewise duplicate their definitions here. (define heaven (make-place 'heaven)) ; The point of no return ;; One-way paths connect individual places in the world. ;;------------------------------------------------------ (define (can-go from direction to) (ask from 'add-neighbor direction to)) (define (can-go-both-ways from direction reverse-direction to) (can-go from direction to) (can-go to reverse-direction from)) (can-go-both-ways conf-room 'south 'north tom-office) (can-go-both-ways dept-office 'east 'west tom-office) (can-go-both-ways east-hall 'south 'north dept-office) (can-go-both-ways ken-office 'south 'north east-hall) (can-go-both-ways east-hall 'east 'west conf-room) (can-go-both-ways east-hall 'west 'east elevator-lobby) (can-go-both-ways elevator-lobby 'north 'south computer-lab) (can-go-both-ways elevator-lobby 'south 'north systems-lab) (can-go-both-ways elevator-lobby 'west 'east west-hall) (can-go-both-ways west-hall 'south 'north network-closet) (can-go-both-ways west-hall 'north 'south robot-lab) (can-go dungeon 'up network-closet) (can-go network-closet 'secretly systems-lab) ;; The important critters in our world... ;;--------------------------------------- (define holly (make&install-person 'holly robot-lab 3)) (define chris (make&install-person 'chris computer-lab 2)) (define grendel (make&install-troll 'grendel dungeon 4)) ;; And some things for the world... ;;--------------------------------- (define computer-manual (make&install-thing 'computer-manual computer-lab)) (define chalk (make&install-thing 'schedule-book dept-office)) (define magic-password (make&install-thing 'magic-password ken-office)) (define holly-card (make&install-id-card 'holly-card dept-office '2003-42)) (define chris-card (make&install-id-card 'chris-card dept-office '2003-43)) ;; The beginning of an ever-expanding game script ;;------------------------------------------------ (define (play-game) (display (ask holly 'go 'south)) (display (ask holly 'go 'east)) (display (ask grendel 'move)) (display (ask grendel 'move)) true) ;; ...now whenever you re-load this file, you can bring things up to ;; date by invoking PLAY-GAME.