chickadee » aima » simulate-vacuum

simulate-vacuum world agentprocedure
simulate-vacuum world agent stepsprocedure
simulate-vacuum world agent steps make-environmentprocedure

Simulate the two-square vacuum-world.

world
The two-square vacuum world (see `make-world')
agent
The agent to inhabit the world
steps
The number of steps to simulate (default: 1000)
make-environment
The environment constructor (default: `make-environment')
(define simulate-vacuum
  (case-lambda
    ((world agent) (simulate-vacuum world agent (default-steps)))
    ((world agent steps) (simulate-vacuum world agent steps make-environment))
    ((world agent steps make-environment)
     (simulate
       (compose-environments
         (make-step-limited-environment steps)
         (make-performance-measuring-environment
           (make-performance-measure world)
           (make-score-update! agent))
         (make-debug-environment
           agent
           (lambda (agent)
             (vector
               (let ((location (agent-location agent)))
                 (if (left? location) 'left 'right))
               (agent-score agent))))
         (make-debug-environment world)
         (make-environment world agent)))
     (agent-score agent))))