chickadee » aima » write-world-as-gif

write-world-as-gif world agent frame gifprocedure
write-world-as-gif world agent frame gif width height font-size titleprocedure

Output the graph-world as gif via Graphviz (useful for e.g. animations).

world
The graph-world to output
agent
The agent inhabiting the graph-world
frame
The frame-number
gif
The base-name of the gif to write to
width
Width of the output
height
Height of the output
font-size
Font-size of the output
title
Title of the output
(define write-world-as-gif
  (case-lambda
    ((world agent frame gif)
     (write-world-as-gif
       world
       agent
       frame
       gif
       (default-width)
       (default-height)
       (default-font-size)
       (default-title)))
    ((world agent frame gif width height font-size title)
     (receive
       (input output id)
       (process "neato" `("-Tgif" "-o" ,gif))
       (with-output-to-port
         output
         (lambda ()
           (write-world-as-dot
             world
             agent
             frame
             width
             height
             font-size
             title)))
       (flush-output output)
       (close-output-port output)
       (close-input-port input)))))