Académique Documents
Professionnel Documents
Culture Documents
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ---------------------------------------------------------------------------
(define (ask object message . args) ;; See your Scheme manual to explain `.'
(object message))
(define (method? x)
(define (no-method? x)
(if (pair? x)
#f))
;;; ----------------------------------------------------------------------------
;;; Persons, places, and things will all be kinds of named objects
(lambda (message)
(case message
;;; Persons and things are mobile since their places can change
(lambda (message)
(case message
((install)
(lambda (self)
;; it is a system-internal method.
((set-place)
'place-set))
(lambda (message)
(case message
;; it is a system-internal method.
((set-owner)
'owner-set))
thing))
(things '())
(lambda (message)
(case message
((neighbors)
((exits)
((neighbor-towards)
(if places
(cdr places)
#f))))
((add-neighbor)
direction name))
#f)
#t))))
((accept-person?)
#t))
((add-thing)
#f)
#t))))
((del-thing)
#f)
#t)))) ;; below
(lambda (list)
(helper list)))
(define find-object
((association-procedure
(lambda (message)
(case message
((list-possessions)
(lambda (self)
'("nothing")
possessions))))
possessions))
((say)
(lambda (self list-of-stuff)
(display-message
'("Oh, nevermind.")
list-of-stuff)))
'said))
((have-fit)
(lambda (self)
'I-feel-better-now))
((look-around)
(lambda (self)
(let ((other-things
'things))))) ;; below
'("nothing")
other-things)))
other-things)))
((take)
#f
'unowned)
#t)
(else
(display thing)
(display-message
#f))))
((lose)
#f
#t)
(else
#f))))
((move)
(lambda (self)
#t))))
((act)
(lambda (self)
(if new-place
((move-to)
#f)
possessions)
(display-message
#t)
(else
((go)
(cond (new-place
(else
#f))))))
((install)
(lambda (self)
(add-to-clock-list self)
person))
(lambda (message)
(case message
((act)
(lambda (self)
(go-to-heaven person)
"tastes yummy!"))
'*burp*))
troll))
'("
))
(remove-from-clock-list person)
'game-over-for-you-dude)
(define *the-time* 0)
(define (initialize-clock-list)
'initialized)
'added)
'removed)
(define (clock)
(newline)
(display "---Tick---")
*clock-list*)
'tick-tock)
(define (current-time)
*the-time*)
(define (run-clock n)
(else (clock)
(run-clock (- n 1)))))
;;; --------------------------------------------------------------------------
#f)))
'place-changed)
#f))
(cons "Hi"
people)))
'sure-is-lonely-in-here))
list-of-stuff)
'message-displayed)
#f
;;; -------------------------------------------------------------------
card))
(lambda (message)
(case message
;;; -------------------------------------------------------------------
(string->symbol (string-append
(symbol->string sym1)
(symbol->string sym2))))
;;; -------------------------------------------------------------------
; (environment->package frame))
; (lambda (port)
; (newline)
; (display name)
; (display value*))))
; 'global-environment
; parent)
; names values))))
; (fluid-let ((*unparser-list-depth-limit* 4)
; (*unparser-list-breadth-limit* 4))
; (newline)
; (display "Frame:")
; (newline)
; (newline)
; (display "Body:")
; (newline)
; (display thing)
; 'uninteresting)
; ((environment? thing)
; (show-frame thing))
; ((compound-procedure? thing)
; (show-procedure thing))
; (else 'uninteresting)))
; (print-nicely
; (object-unhash thing)
; thing)
; thing)))
;;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;
;;
;;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(initialize-clock-list)
;;------------------------------------------
;;------------------------------------------------------
;;---------------------------------------
(define beng-card
;;
;; Interactive game
;;
(define (tokenize s)
'()
(char-whitespace? char))
((char-whitespace? char)
(define (helper2 s)
(if (null? s)
'()
'()
(let* ((begin (car next-token))
'()
(helper2 s))))
(define (play-game-interactive)
(display-game-state)
(clock)
(play-game-interactive))
(display prompt-string)
(read-line))
(define (display-game-state)
(newline)
(newline)
(display (map (lambda (p) (ask p 'name)) (ask (ask you 'place) 'things)))
(newline)
(newline)
(newline))
;(play-game-interactive)
;; The beginning of an ever-expanding automatic game script
;;----------------------------------------------------------
(define (play-game)
;(play-game)
(define flip
(let ((count 0))
(lambda ()
(begin
(set! count (- 1 count))
count))))
(define (make-flip)
(let ((count 0))
(lambda ()
(begin
(set! count (- 1 count))
count))))