emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/pacmacs e12ed88fe7 298/472: Generalize run-away-direction


From: ELPA Syncer
Subject: [nongnu] elpa/pacmacs e12ed88fe7 298/472: Generalize run-away-direction function (#153)
Date: Thu, 6 Jan 2022 21:59:33 -0500 (EST)

branch: elpa/pacmacs
commit e12ed88fe7c3d2da2c1c31d6f5346cd281e9c5e3
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>

    Generalize run-away-direction function (#153)
    
    Parametrize it with blocked-tile-predicate
---
 pacmacs.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pacmacs.el b/pacmacs.el
index faa3111f9e..8c4369139e 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -372,7 +372,7 @@
     (pacmacs--track-object ghost)
     (pacmacs--step-object ghost)))
 
-(defun pacmacs--run-away-direction (runner bogey)
+(defun pacmacs--run-away-direction (runner bogey blocked-tile-predicate)
   (plist-bind ((runner-row :row)
                (runner-column :column))
       runner
@@ -384,7 +384,7 @@
              (possible-ways
               (->> (pacmacs--possible-side-ways runner-row runner-column)
                    (-remove (-lambda ((row . column))
-                              (or (pacmacs--wall-at-p row column)
+                              (or (funcall blocked-tile-predicate row column)
                                   (> current-distance
                                      (pacmacs--squared-distance row column
                                                                 bogey-row 
bogey-column))))))))
@@ -396,7 +396,8 @@
   (dolist (terrified-ghost pacmacs--terrified-ghosts)
     (-when-let (direction (pacmacs--run-away-direction
                            terrified-ghost
-                           pacmacs--player-state))
+                           pacmacs--player-state
+                           #'pacmacs--wall-at-p))
       (pacmacs--switch-direction terrified-ghost direction))
     (pacmacs--step-object terrified-ghost)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]