summaryrefslogtreecommitdiff
path: root/manuals/chickadee/Path-Finding.html
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-05-24 08:09:03 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-05-24 08:09:03 -0400
commit03072ef67af0623758a660e2cd3fb5e153133efa (patch)
treeeea30b2b8fd47aa7d1bd6494ed64b4313f03eb4a /manuals/chickadee/Path-Finding.html
parentbcccc363a3b814930856be06c52914fb88c2ece6 (diff)
Update chickadee manual.
Diffstat (limited to 'manuals/chickadee/Path-Finding.html')
-rw-r--r--manuals/chickadee/Path-Finding.html66
1 files changed, 33 insertions, 33 deletions
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 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
-<!-- Copyright (C) 2017-2021 David Thompson davet@gnu.org
+<!-- Copyright (C) 2017-2023 David Thompson dthompson2@worcester.edu
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
@@ -17,25 +17,25 @@ Foundation Web site at http://www.gnu.org/licenses/fdl.html.
The document was typeset with
http://www.texinfo.org/ (GNU Texinfo).
- -->
-<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
+ -->
+<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Path Finding (The Chickadee Game Toolkit)</title>
-<meta name="description" content="Path Finding (The Chickadee Game Toolkit)">
-<meta name="keywords" content="Path Finding (The Chickadee Game Toolkit)">
-<meta name="resource-type" content="document">
-<meta name="distribution" content="global">
-<meta name="Generator" content="makeinfo">
-<link href="index.html" rel="start" title="Top">
-<link href="Index.html" rel="index" title="Index">
-<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
-<link href="Data-Structures.html" rel="up" title="Data Structures">
-<link href="Copying-This-Manual.html" rel="next" title="Copying This Manual">
-<link href="Grids.html" rel="prev" title="Grids">
+<meta name="description" content="Path Finding (The Chickadee Game Toolkit)" />
+<meta name="keywords" content="Path Finding (The Chickadee Game Toolkit)" />
+<meta name="resource-type" content="document" />
+<meta name="distribution" content="global" />
+<meta name="Generator" content="makeinfo" />
+<link href="index.html" rel="start" title="Top" />
+<link href="Index.html" rel="index" title="Index" />
+<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents" />
+<link href="Data-Structures.html" rel="up" title="Data Structures" />
+<link href="Copying-This-Manual.html" rel="next" title="Copying This Manual" />
+<link href="Grids.html" rel="prev" title="Grids" />
<style type="text/css">
-<!--
+&lt;!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
@@ -72,9 +72,9 @@ ul.no-bullet {list-style: none}
}
}
--->
+--&gt;
</style>
-<link rel="stylesheet" type="text/css" href="https://dthompson.us/css/dthompson.css">
+<link rel="stylesheet" type="text/css" href="https://dthompson.us/css/dthompson.css" />
</head>
@@ -84,7 +84,7 @@ ul.no-bullet {list-style: none}
<p>
Previous: <a href="Grids.html" accesskey="p" rel="prev">Grids</a>, Up: <a href="Data-Structures.html" accesskey="u" rel="up">Data Structures</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
-<hr>
+<hr />
<span id="Path-Finding-1"></span><h4 class="subsection">5.6.6 Path Finding</h4>
<p>Most game worlds have maps. Often, these games have a need to move
@@ -101,19 +101,19 @@ map implementation!
<p>The example below defines a very simple town map and finds the
quickest way to get from the town common to the school.
</p>
-<div class="example">
-<pre class="example">(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)
+<div class="lisp">
+<pre class="lisp"><span class="syntax-open">(</span><span class="syntax-special">define</span> <span class="syntax-symbol">world-map</span>
+ <span class="syntax-symbol">'</span><span class="syntax-open">(</span><span class="syntax-open">(</span><span class="syntax-symbol">town-common</span> <span class="syntax-symbol">.</span> <span class="syntax-open">(</span><span class="syntax-symbol">town-hall</span> <span class="syntax-special">library</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+ <span class="syntax-open">(</span><span class="syntax-symbol">town-hall</span> <span class="syntax-symbol">.</span> <span class="syntax-open">(</span><span class="syntax-symbol">town-common</span> <span class="syntax-symbol">school</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+ <span class="syntax-open">(</span><span class="syntax-special">library</span> <span class="syntax-symbol">.</span> <span class="syntax-open">(</span><span class="syntax-symbol">town-common</span> <span class="syntax-symbol">cafe</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+ <span class="syntax-open">(</span><span class="syntax-symbol">school</span> <span class="syntax-symbol">.</span> <span class="syntax-open">(</span><span class="syntax-symbol">town-hall</span> <span class="syntax-symbol">cafe</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+ <span class="syntax-open">(</span><span class="syntax-symbol">cafe</span> <span class="syntax-symbol">.</span> <span class="syntax-open">(</span><span class="syntax-special">library</span> <span class="syntax-symbol">school</span><span class="syntax-close">)</span><span class="syntax-close">)</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+<span class="syntax-open">(</span><span class="syntax-special">define</span> <span class="syntax-open">(</span><span class="syntax-symbol">neighbors</span> <span class="syntax-symbol">building</span><span class="syntax-close">)</span>
+ <span class="syntax-open">(</span><span class="syntax-symbol">assq-ref</span> <span class="syntax-symbol">town-map</span> <span class="syntax-symbol">building</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+<span class="syntax-open">(</span><span class="syntax-special">define</span> <span class="syntax-open">(</span><span class="syntax-symbol">cost</span> <span class="syntax-symbol">a</span> <span class="syntax-symbol">b</span><span class="syntax-close">)</span> <span class="syntax-symbol">1</span><span class="syntax-close">)</span>
+<span class="syntax-open">(</span><span class="syntax-special">define</span> <span class="syntax-open">(</span><span class="syntax-symbol">distance</span> <span class="syntax-symbol">a</span> <span class="syntax-symbol">b</span><span class="syntax-close">)</span> <span class="syntax-symbol">1</span><span class="syntax-close">)</span>
+<span class="syntax-open">(</span><span class="syntax-special">define</span> <span class="syntax-symbol">pf</span> <span class="syntax-open">(</span><span class="syntax-symbol">make-path-finder</span><span class="syntax-close">)</span><span class="syntax-close">)</span>
+<span class="syntax-open">(</span><span class="syntax-symbol">a*</span> <span class="syntax-symbol">pf</span> <span class="syntax-symbol">'town-common</span> <span class="syntax-symbol">'school</span> <span class="syntax-symbol">neighbors</span> <span class="syntax-symbol">cost</span> <span class="syntax-symbol">distance</span><span class="syntax-close">)</span>
</pre></div>
<p>In this case, the <code>a*</code> procedure will return the list
@@ -159,7 +159,7 @@ number. <var>distance</var> is a procedure that accepts two nodes and
returns an approximate distance between them.
</p></dd></dl>
-<hr>
+<hr />
<div class="header">
<p>
Previous: <a href="Grids.html" accesskey="p" rel="prev">Grids</a>, Up: <a href="Data-Structures.html" accesskey="u" rel="up">Data Structures</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>