From 03072ef67af0623758a660e2cd3fb5e153133efa Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 24 May 2023 08:09:03 -0400 Subject: Update chickadee manual. --- manuals/chickadee/Path-Finding.html | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'manuals/chickadee/Path-Finding.html') diff --git a/manuals/chickadee/Path-Finding.html b/manuals/chickadee/Path-Finding.html index 40dc80e..150ef88 100644 --- a/manuals/chickadee/Path-Finding.html +++ b/manuals/chickadee/Path-Finding.html @@ -1,6 +1,6 @@ - - + --> + - + Path Finding (The Chickadee Game Toolkit) - - - - - - - - - - - + + + + + + + + + + + - + @@ -84,7 +84,7 @@ ul.no-bullet {list-style: none}

Previous: , Up: Data Structures   [Contents][Index]

-
+

5.6.6 Path Finding

Most game worlds have maps. Often, these games have a need to move @@ -101,19 +101,19 @@ map implementation!

The example below defines a very simple town map and finds the quickest way to get from the town common to the school.

-
-
(define world-map
-  '((town-common . (town-hall library))
-    (town-hall . (town-common school))
-    (library . (town-common cafe))
-    (school . (town-hall cafe))
-    (cafe . (library school))))
-(define (neighbors building)
-  (assq-ref town-map building))
-(define (cost a b) 1)
-(define (distance a b) 1)
-(define pf (make-path-finder))
-(a* pf 'town-common 'school neighbors cost distance)
+
+
(define world-map
+  '((town-common . (town-hall library))
+    (town-hall . (town-common school))
+    (library . (town-common cafe))
+    (school . (town-hall cafe))
+    (cafe . (library school))))
+(define (neighbors building)
+  (assq-ref town-map building))
+(define (cost a b) 1)
+(define (distance a b) 1)
+(define pf (make-path-finder))
+(a* pf 'town-common 'school neighbors cost distance)
 

In this case, the a* procedure will return the list @@ -159,7 +159,7 @@ number. distance is a procedure that accepts two nodes and returns an approximate distance between them.

-
+

Previous: , Up: Data Structures   [Contents][Index]

-- cgit v1.2.3