戦闘モジュール
(let* ((es (make-hash-table :size 11 :test 'equal)) (p1 "p1") (p2 "p2") (p3 "p3") (turn 0) (s "turn over....") (pl (list p1 p2 p3)) (bn "*simu*") (svvp (lambda (x) (<= (gethash x es) 0)))) (setf (gethash p1 es) 20) (setf (gethash p2 es) 22) (setf (gethash p3 es) 24) (make-random-state) (with-output-to-temp-buffer (bn nil) (block f (while (< (incf turn) 100) (format t "~%turn ~d p1 ~A / p2 ~A / p3 ~A~%" turn (gethash p1 es) (gethash p2 es) (gethash p3 es)) (dolist (p pl) (if (< 0 (gethash p es)) (let* ((lst (remove-if svvp (remove p pl))) (tg (elt lst (random (length lst)))) (d (random 6))) (format t "~A attacked ~A! " p tg) (if (< 0 d) (format t "~A damaged ~A!~%" tg d) (format t "~A didn't damage~%" tg)) (decf (gethash tg es) d)))) (dolist (p pl) (if (find-if-not svvp (remove p pl)) t (return-from f (setq s (format nil "~A win!!!" p)))) (if (funcall svvp p) (format t "~A was down...~%" p))))) (format t "~A~%" s)) (set-buffer (find-buffer bn)) (make-local-variable 'regexp-keyword-list) (setq regexp-keyword-list (compile-regexp-keyword-list '(("turn [0-9]+" t (:color 0 0 :underline) nil) ("[0-9]+" t (:keyword 0) nil) ("p[123]" t (:keyword 1 :bold) nil))))s)
最低限度のDARK KINGDOMみたいなの。xyzzyにはこっちの方が向いてるね。今作ろうとしてるのは、これを発展させたものにシナリオを付けたもの。