2 (chicken process-context)
4 mars visualizer parser)
6 (define (make-color-map progs colors)
7 (let loop ((entries '())
10 (if (null? progs-left)
12 (let ((this-prog (car progs-left))
13 (this-col (car colors-left)))
14 (loop (cons (cons (prog-name this-prog) this-col) entries)
16 (cdr colors-left))))))
18 (define (run-mars-with-vis files iters core-size)
19 (print "Iters: " iters ", core size: " core-size "\n")
22 (string->prog (with-input-from-file fname read-string)))
24 (colors '("red" "blue" "green" "magenta" "cyan"))
25 (color-map (make-color-map progs colors))
26 (vis (make-vis 640 480 core-size color-map))
27 (core (make-core 8000 (make-instr 'DAT 'F 'immediate 0 'immediate 0)
29 (vis 'update-owner i n))))
30 (queues (run-mars core (install-progs core progs) iters)))
32 (print "Final queue for " (queue-owner q) ":")
36 (print* "Press enter to finish...")
41 (print "Usage: run-mars [-h|--help]\n"
42 " run-mars [-c|--core size] [-i|--iterations n] warrior1.red [warrior2.red [...]]"))
45 (let loop ((args (cdr (argv)))
49 ((or () ((or "-h" "--help")))
51 (((or "-i" "--iterations") istr rest ...)
52 (loop rest (string->number istr) core-size))
53 (((or "-c" "--core-size") cstr rest ...)
54 (loop rest iters (string->number cstr)))
56 (run-mars-with-vis files iters core-size)))))