From 717fc1bce7d62591302f7b67f5d26278c321d40c Mon Sep 17 00:00:00 2001 From: Alexandru Palade Date: Mon, 20 Apr 2020 02:36:27 +0300 Subject: [PATCH] killer is chased by *closest* police officer --- src/killer.lisp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/killer.lisp b/src/killer.lisp index e761008..de8788f 100644 --- a/src/killer.lisp +++ b/src/killer.lisp @@ -27,16 +27,13 @@ (defmethod lose-disguise ((game sil-game) (killer killer)) (when (disguised killer) - (let ((all-police (get-all-persons-of-type game 'police)) - (chaser nil)) - (setf all-police (remove-if (lambda (x) (state-p x 'chasing)) all-police)) - (when all-police - (setf chaser (random-nth all-police)) + (let ((chaser (get-closest-police game (row killer) (col killer)))) + (when chaser (setf (target chaser) killer) (setf (state chaser) 'chasing) + (setf (rest-time chaser) 0) (setf (destination chaser) (list (row killer) (col killer))) (update-path-person game chaser)))) - (setf (disguised killer) nil)) (defmethod time-since-last-kill ((this killer))