Plaster

common-lisp
(defun random-select (L) (nth (random (length L)) L)) (defun random-select-non-mafia (L) (nth (random (length (remove 'm L))) (remove 'm L))) (let ((fool-winning 0) (mafias-winning 0) (townies-winning 0)) (loop repeat 100 do (case (loop for citizens = '(f m m t t t t t) for tmp = nil do (setq citizens (remove (random-select-non-mafia citizens) citizens :count 1)) ; ^ It's night. Mafias kill someone (setq tmp (random-select citizens)) ; selecting someone random to lynch (when (eq tmp 'f) ; Is it fool that we are lynching? (return 0)) (setq citizens (remove tmp citizens :count 1)) ; lynch (when (eql (/ (length citizens) 2) (count 'm citizens)) (return 1)) (when (eql 0 (count 'm citizens)) (return 2))) (0 (incf fool-winning)) (1 (incf mafias-winning)) (2 (incf townies-winning)))) (format t "F: ~a~%M: ~a~%T: ~a~%" fool-winning mafias-winning townies-winning))