summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-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))