(IN-PACKAGE "NISP") (defvar scaling-factor* 0.004) (setf scaling-factor* 0.004) (defvar unit* 0.015) (setf unit* 0.015) (defvar draw-grid* nil) (setf draw-grid* nil) (defvar picture-dimension-x* 480) (setf picture-dimension-x* 480) (defvar picture-dimension-y* 250) (setf picture-dimension-y* 250) (defvar grid-factor* 10.0) (setf grid-factor* 40.0) (defvar arrow-factor* 1) (setf arrow-factor* 100) (defvar data-dir-name* '()) (setf data-dir-name* '()) (defvar number-of-colors 32) (defvar number-of-colors-f 32.0) (setf number-of-colors 256) (setf number-of-colors-f 256.0) (defvar text-dir-name* "~/PRAK-ROBOT/TEXT") (setf text-dir-name* "~/PRAK-ROBOT/TEXT") (defun show-sit (file-name &optional features) (let ((dir (excl:current-directory))) (soccer-sit->pstricks file-name features) (excl:chdir text-dir-name*) (excl:shell (format nil "latex ~a" file-name)) (excl:shell (format nil "dvips -o ~a.ps ~a" file-name file-name)) (excl:shell (format nil "gv ~a.ps &" file-name)) (excl:chdir dir) t)) (defun soccer-sit->pstricks (file-name features) (let ((file-name-exp (format nil "~a/~a.tex" text-dir-name* file-name))) (with-open-file (ofile file-name-exp :direction :output :if-exists :supersede) (write-pstricks-header ofile) (soccer-field->pstricks ofile) (draw-game-situation OFILE) (write-end-pspicture ofile) (cond ((not (null features)) (features->pstricks features ofile))) (write-pstricks-trailer ofile) t))) (DEFUN DRAW-GAME-SITUATION (STR) (MAPELTDO (\\ (ROBOT) (DRAW-ROBOT ROBOT STR)) GAME-SITUATION*) 'T) (DEFPROC draw-robot - boolean (rob - robot str - stream) '#T)) (defun features->pstricks (features str) (format str "~%~%\\begin{tabular}{|l|l|}") (format str "~%\\hline \\hline") (format str "~%feature & feature value \\\\") (format str "~%\\hline \\hline") (mapcar (lambda (feature-value) (format str "~%~a & ~a \\\\ \\hline" (first feature-value) (second feature-value))) features) (format str "~% \\hline") (format str "~%\\end{tabular}")) (defun write-pstricks-header (str) (format str "\\documentclass{article} ~%\\usepackage{fullpage,pstricks,pst-node,pstcol,graphicx,epsf}") (define-latex-cmds str) (format str "~%\\begin{document} ~%\\pagestyle{empty} ~%\\psset{unit=~acm} ~%\\begin{pspicture}(-~a,-~a)(~a,~a)" unit* picture-dimension-x* picture-dimension-y* picture-dimension-x* picture-dimension-y*) t) (defun define-latex-cmds (str) (format str "\\newcommand{\\pioneerrobot}[5]{\\rput{#4}(#2,#3){\\pspolygon[linewidth=1pt,fillcolor=#5,fillstyle=solid](-32.5,15)(-7.5,20)(7.5,20)(12.5,10)(22.5,20)(15,5)(15,-5)(22.5,-20)(12.5,-10)(7.5,-20)(-7.5,-20)(-32.5,-15)} \\rput{0}(#2,#3){\\makebox[0ex]{#1}}}") (format str "\\newcommand{\\nomadrobot}[5]{\\rput{#4}(#2,#3){\\pspolygon[linewidth=1pt,fillcolor=#5,fillstyle=solid](-20,15)(20,15)(15,10)(15,-10)(20,-15)(-20,-15)} \\rput{0}(#2,#3){\\makebox[0ex]{#1}}}")) (defun write-end-pspicture (str) (format str "~%\\end{pspicture}") t) (defun write-pstricks-trailer (str) (format str "~%\\end{document}") t) (defun players->pstricks (str pls rob-type) (mapcar (lambda (pl) (draw-robot pl rob-type str)) pls)) (defun soccer-field->pstricks (str) (format str "~%\\psframe[fillstyle=solid,fillcolor=green](-450,-250)(450,250)") ;(format str ; "~%\\psgrid(0,0)(-4.5,-2.5)(4.5,2.5)") (format str "~%\\psframe[fillstyle=solid,fillcolor=yellow](-480,-100)(-450,100)") (format str "~%\\psframe[fillstyle=solid,fillcolor=blue](450,-100)(480,100)") (format str "~%\\pscircle[linewidth=2pt,linecolor=white](0,0){120}") (format str "~%\\psline[linewidth=2pt,linecolor=white](0,-250)(0,250)") (format str "~%\\psline[linewidth=2pt,linecolor=white](-450,140)(-320,140)(-320,-140)(-450,-140)") (format str "~%\\psline[linewidth=2pt,linecolor=white](450,140)(320,140)(320,-140)(450,-140)") )