diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-10-02 17:12:44 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-10-03 07:45:33 -0400 |
commit | bbd1bd1392d482287936fde54cb2cea808eb2bae (patch) | |
tree | 7154ae413807ffebcd17ac888825e16e83c2f2bc | |
parent | 7955ab539b081814fa4406bea7821cbca889a2b2 (diff) |
Move pathfinding module to math directory.
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | chickadee/math/path-finding.scm (renamed from chickadee/path-finding.scm) | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am index 1ae2d24..2b27ba2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ SOURCES = \ chickadee/math/rect.scm \ chickadee/math/grid.scm \ chickadee/math/easings.scm \ + chickadee/math/path-finding.scm \ chickadee/render/color.scm \ chickadee/render/gl.scm \ chickadee/render/gpu.scm \ @@ -73,7 +74,6 @@ SOURCES = \ chickadee/scripting/script.scm \ chickadee/scripting/channel.scm \ chickadee/scripting.scm \ - chickadee/path-finding.scm \ chickadee.scm \ chickadee/sdl.scm diff --git a/chickadee/path-finding.scm b/chickadee/math/path-finding.scm index 9af01f8..d89c2fc 100644 --- a/chickadee/path-finding.scm +++ b/chickadee/math/path-finding.scm @@ -20,7 +20,7 @@ ;; ;;; Code -(define-module (chickadee path-finding) +(define-module (chickadee math path-finding) #:use-module (chickadee heap) #:use-module (srfi srfi-9) #:export (make-path-finder @@ -40,13 +40,13 @@ (make-hash-table) (make-hash-table))) -(define (a* path-finder start goal neighbors cost heuristic) +(define (a* path-finder start goal neighbors cost distance) "Return a list of nodes forming a path from START to GOAL using PATH-FINDER. NEIGHBORS is a procedure that accepts a node and returns a list of nodes that neighbor it. COST is a procedure that accepts -two neighboring nodes and the cost of moving from the first to the -second as a number. HEURISTIC is a procedure that accepts two nodes -and returns an approximate distance between them." +two neighboring nodes and returns the cost of moving from the first to +the second as a number. DISTANCE is a procedure that accepts two +nodes and returns an approximate distance between them." (let ((frontier (path-finder-frontier path-finder)) (came-from (path-finder-came-from path-finder)) (cost-so-far (path-finder-cost-so-far path-finder))) @@ -64,7 +64,7 @@ and returns an approximate distance between them." (when (or (not (hashq-ref cost-so-far next)) (< new-cost (hashq-ref cost-so-far next))) (hashq-set! cost-so-far next new-cost) - (let ((priority (+ new-cost (heuristic goal next)))) + (let ((priority (+ new-cost (distance goal next)))) (heap-insert! frontier (cons next priority))) (hashq-set! came-from next current)))) (neighbors current)) |