Pathfinding.htm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  1. <html xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xanx="http://schemas.microsoft.com/developer/xanx/2005"><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"><META NAME="save" CONTENT="history"><title>Pathfinding Sample</title>
  2. <style><!--
  3. /***********************************************************
  4. * SCRIPT-SUPPORTING STYLES
  5. ***********************************************************/
  6. /* Defines the userData cache persistence mechanism. */
  7. .userDataStyle
  8. {
  9. behavior: url(#default#userData);
  10. }
  11. /* Used to save the scroll bar position when navigating away from a page. */
  12. div.saveHistory
  13. {
  14. behavior: url(#default#saveHistory);
  15. }
  16. /* Formats the expand/collapse images for all collapsible regions. */
  17. img.toggle
  18. {
  19. border: 0;
  20. margin-right: 5;
  21. }
  22. /* Formats the Language filter drop-down image. */
  23. img#languageFilterImage
  24. {
  25. border: 0;
  26. margin-left: 0;
  27. vertical-align: middle;
  28. }
  29. /* Formats the Members Options filter drop-down image. */
  30. img#membersOptionsFilterImage
  31. {
  32. border: 0;
  33. margin-left: 0;
  34. vertical-align: middle;
  35. }
  36. /* Formats the Collapse All/Expand All images. */
  37. img#toggleAllImage
  38. {
  39. margin-left: 0;
  40. vertical-align: middle;
  41. }
  42. /* Supports XLinks */
  43. MSHelp\:link
  44. {
  45. text-decoration: underline;
  46. color: #0000ff;
  47. hoverColor: #3366ff;
  48. filterString: ;
  49. }
  50. body
  51. {
  52. background: #FFFFFF;
  53. color: #000000;
  54. font-family: Verdana;
  55. font-size: medium;
  56. font-style: normal;
  57. font-weight: normal;
  58. margin-top: 0;
  59. margin-bottom: 0;
  60. margin-left: 0;
  61. margin-right: 0;
  62. width: 100%;
  63. /*font-size: 110%;*/
  64. }
  65. div.section
  66. {
  67. margin-left: 15px;
  68. }
  69. div.hxnx5
  70. {
  71. margin-left: 1.5em;
  72. }
  73. /* Font for all headings */
  74. h1, h2, h3, h4, h5, h6
  75. {
  76. font-family: Verdana, Arial, Helvetica, sans-serif;
  77. margin-top: 18;
  78. margin-bottom: 8;
  79. font-weight: bold;
  80. }
  81. h1
  82. {
  83. font-size: 130%;
  84. color: #003399;
  85. }
  86. div#scrollyes h1 /* Changes font size for full-scrolling topic */
  87. {
  88. font-size: 150%;
  89. }
  90. h2
  91. {
  92. font-size: 125%;
  93. }
  94. h3
  95. {
  96. font-size: 115%;
  97. margin-top: 9;
  98. margin-bottom: 4;
  99. }
  100. h4
  101. {
  102. font-size: 115%;
  103. margin-top: 9;
  104. margin-bottom: 4;
  105. }
  106. h5
  107. {
  108. font-size: 100%;
  109. margin-top: 9;
  110. margin-bottom: 4;
  111. }
  112. h6
  113. {
  114. font-size: 100%;
  115. margin-top: 9;
  116. margin-bottom: 4;
  117. }
  118. ul p, ol p, dl p
  119. {
  120. margin-left: 0em;
  121. }
  122. p
  123. {
  124. margin-top: .6em;
  125. margin-bottom: .6em;
  126. }
  127. td p
  128. {
  129. margin-top: 0.0em;
  130. margin-bottom: 0.6em;
  131. }
  132. dd p
  133. {
  134. margin-top: 0.0em;
  135. margin-bottom: 0.6em;
  136. }
  137. .image
  138. {
  139. text-align: center;
  140. }
  141. dl
  142. {
  143. margin-top: 0em;
  144. margin-bottom: 1.3em;
  145. }
  146. dd
  147. {
  148. margin-bottom: 0em;
  149. margin-left: 0;
  150. }
  151. dl.glossary dd
  152. {
  153. margin-bottom: 0em;
  154. margin-left: 1.5em;
  155. }
  156. dt
  157. {
  158. margin-top: .6em;
  159. margin-bottom: 1;
  160. }
  161. ul, ol
  162. {
  163. margin-top: 0.6em;
  164. margin-bottom: 0.6em;
  165. }
  166. ol
  167. {
  168. margin-left: 2.5em;
  169. }
  170. ul
  171. {
  172. margin-left: 1.9em;
  173. }
  174. li
  175. {
  176. margin-bottom: 0.4em;
  177. }
  178. ul ol, ol ol
  179. {
  180. list-style-type: lower-alpha;
  181. }
  182. pre
  183. {
  184. margin-top: .6em;
  185. margin-bottom: .6em;
  186. }
  187. pre
  188. {
  189. font: 105% Lucida, mono;
  190. color: #000066;
  191. }
  192. code
  193. {
  194. font-family: Monospace, Courier New, Courier;
  195. font-size: 105%;
  196. color: #000066;
  197. }
  198. table.userdata td
  199. {
  200. background: #ffffff;
  201. background-color: #F5F5F5;
  202. border-color: #ffffff;
  203. border: none;
  204. }
  205. table.clsWarning
  206. {
  207. background: #ffffff;
  208. padding: 0px;
  209. margin: 0px;
  210. border: none;
  211. }
  212. table.clsWarning td
  213. {
  214. padding: 0px;
  215. margin: 0px;
  216. background: #ffffff;
  217. vertical-align: middle;
  218. font-size: 70%;
  219. }
  220. div#mainSection table
  221. {
  222. width: 98%;
  223. background: #ffffff;
  224. margin-top: 5px;
  225. margin-bottom: 5px;
  226. }
  227. div#mainSection table th
  228. {
  229. padding: 5px 6px;
  230. background: #EFEFF7;
  231. text-align: left;
  232. font-size: 70%;
  233. vertical-align: bottom;
  234. border-bottom: 1px solid #C8CDDE;
  235. }
  236. div#mainSection table td
  237. {
  238. padding: 5px 5px;
  239. background: #F7F7FF;
  240. vertical-align: top;
  241. font-size: 70%;
  242. border-bottom: 1px solid #D5D5D3;
  243. }
  244. div#syntaxCodeBlocks table th
  245. {
  246. padding: 1px 6px;
  247. color: #000066;
  248. }
  249. div#syntaxCodeBlocks table td
  250. {
  251. padding: 1px 5px;
  252. }
  253. /* Applies to the running header text in the first row of the upper table in the
  254. non-scrolling header region. */
  255. span#runningHeaderText
  256. {
  257. color: #003399;
  258. font-size: 90%;
  259. padding-left: 13;
  260. }
  261. /* Applies to the topic title in the second row of the upper table in the
  262. non-scrolling header region. */
  263. span#nsrTitle
  264. {
  265. color: #003399;
  266. font-size: 120%;
  267. font-weight: 600;
  268. padding-left: 13;
  269. }
  270. /* Applies to everything below the non-scrolling header region. */
  271. div#mainSection
  272. {
  273. font-size: 70%;
  274. width: 100%;
  275. }
  276. /* Applies to everything below the non-scrolling header region, minus the footer. */
  277. div#mainBody
  278. {
  279. font-size: 90%;
  280. margin-left: 15;
  281. margin-top: 10;
  282. padding-bottom: 20;
  283. }
  284. /* Adds right padding for all blocks in mainBody */
  285. div#mainBody p, div#mainBody ol, div#mainBody ul, div#mainBody dl
  286. {
  287. padding-right: 5;
  288. }
  289. div#mainBody div.alert, div#mainBody div.code, div#mainBody div.tableSection
  290. {
  291. width:98.9%;
  292. }
  293. div.alert p, div.code p
  294. {
  295. margin-top:5;
  296. margin-bottom:8;
  297. }
  298. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Begin Note Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  299. div#mainSection div.alert table
  300. {
  301. border: 0;
  302. }
  303. div#mainSection div.alert table th
  304. {
  305. padding-top: 0;
  306. padding-bottom: 0;
  307. padding-left: 5;
  308. padding-right: 5;
  309. }
  310. div#mainSection div.alert table td
  311. {
  312. padding-left: 5;
  313. padding-right: 5;
  314. }
  315. img.note
  316. {
  317. border: 0;
  318. margin-left: 0;
  319. margin-right: 3;
  320. }
  321. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - End Note Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  322. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Begin Non-scrolling Header Region Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  323. /* Applies to the entire non-scrolling header region. */
  324. div#header
  325. {
  326. background-color: #D4DFFF;
  327. padding-top: 0;
  328. padding-bottom: 0;
  329. padding-left: 0;
  330. padding-right: 0;
  331. width: 100%;
  332. }
  333. /* Applies to both tables in the non-scrolling header region. */
  334. div#header table
  335. {
  336. margin-top: 0;
  337. margin-bottom: 0;
  338. border-bottom-color: #C8CDDE;
  339. border-bottom-style: solid;
  340. border-bottom-width: 1;
  341. background: #D4DFFF;
  342. width: 100%;
  343. }
  344. /* Applies to cells in both tables in the non-scrolling header region. */
  345. div#header table td
  346. {
  347. color: #0000FF;
  348. font-size: 70%;
  349. padding-right: 20;
  350. padding-top: 1;
  351. padding-bottom: 1;
  352. border: none;
  353. background: #D4DFFF;
  354. }
  355. /* Applies to the last row in the upper table of the non-scrolling header region. Text
  356. in this row includes See Also, Constructors, Methods, and Properties. */
  357. div#header table tr#headerTableRow3 td
  358. {
  359. padding-bottom: 2;
  360. padding-top: 5;
  361. padding-left: 15;
  362. }
  363. /* Applies to the lower table in the non-scrolling header region. Text in this table
  364. includes Collapse All/Expand All, Language Filter, and Members Options. */
  365. div#header table#bottomTable
  366. {
  367. border-top-color: #FFFFFF;
  368. border-top-style: solid;
  369. border-top-width: 1;
  370. text-align: left;
  371. padding-left: 15;
  372. }
  373. blockquote
  374. {
  375. margin-left: 3.8em;
  376. margin-right: 3.8em;
  377. margin-top: .6em;
  378. margin-bottom: .6em;
  379. }
  380. sup
  381. {
  382. text-decoration: none;
  383. font-size: smaller;
  384. }
  385. a:link
  386. {
  387. color: #0000FF;
  388. /* font-weight: bold */
  389. }
  390. a:visited
  391. {
  392. color: #0000AA;
  393. /* font-weight: bold */
  394. }
  395. a:hover
  396. {
  397. color: #3366FF;
  398. /* font-weight: bold */
  399. }
  400. .label
  401. {
  402. font-weight: bold;
  403. margin-top: 1em;
  404. margin-left: -26px;
  405. }
  406. .tl
  407. {
  408. margin-bottom: .75em;
  409. }
  410. .atl
  411. {
  412. padding-left: 1.5em;
  413. padding-bottom: .75em;
  414. }
  415. .cfe
  416. {
  417. font-weight: bold;
  418. }
  419. .mini
  420. {
  421. font-size: smaller;
  422. }
  423. .dt
  424. {
  425. margin-bottom: -.6em;
  426. }
  427. .indent
  428. {
  429. margin-left: 1.9em;
  430. margin-right: 1.9em;
  431. }
  432. .product
  433. {
  434. text-align: right;
  435. color: #333333;
  436. font-size: smaller;
  437. font-style: italic;
  438. }
  439. .buttonbarshade
  440. {
  441. position: relative;
  442. margin: 0;
  443. left: 0px;
  444. top: 2;
  445. width: 50%;
  446. height: 40px;
  447. }
  448. .buttonbartable
  449. {
  450. position: absolute;
  451. margin: 0;
  452. padding:0;
  453. border:0;
  454. left:0px;
  455. top: 2;
  456. width: 100%;
  457. height: 40px;
  458. }
  459. /* background color, font for header */
  460. table.buttonbartable td, table.buttonbarshade td
  461. {
  462. background: #ffffff; /*#5177B8; #80C615;*/
  463. border-left: 0px solid #80C615;
  464. margin: 0;
  465. padding: 0px 0px 0px 0px;
  466. font-family: Impact, sans-serif;
  467. font-size: 14pt;
  468. }
  469. table.buttonbartable td.button1
  470. {
  471. background: #5177B8; /*#80C615;*/;
  472. padding: 0;
  473. font-weight: bold;
  474. text-align: center;
  475. cursor: hand;
  476. }
  477. table.buttonbartable td.button2
  478. {
  479. background: #5177B8; /*#80C615;*/;
  480. font-weight: bold;
  481. text-align: center;
  482. }
  483. table.buttonbartable td.button3
  484. {
  485. background: #5177B8; /*#80C615;*/;
  486. font-weight: bold;
  487. text-align: center;
  488. }
  489. table.buttonbartable td.runninghead
  490. {
  491. padding-left: 0px;
  492. font-style: italic;
  493. text-align: left;
  494. }
  495. .version
  496. {
  497. text-align: left;
  498. color: #000000;
  499. margin-top: 3em;
  500. margin-left: -26px;
  501. font-size: smaller;
  502. font-style: italic;
  503. }
  504. .lang, .ilang
  505. {
  506. color: #0000ff;
  507. font: normal 7pt Arial, Helvetica, sans-serif;
  508. }
  509. div.langMenu
  510. {
  511. position: absolute;
  512. z-index: 1;
  513. width: 96pt;
  514. padding: 8pt;
  515. visibility: hidden;
  516. border: 1px solid #000000;
  517. background: #ffffd0;
  518. }
  519. div.langMenu ul
  520. {
  521. padding-left: 2em;
  522. margin-left: 0;
  523. }
  524. div.filtered
  525. {
  526. margin: 4pt 0 8pt -26px;
  527. padding: 4px 4px 8px 26px;
  528. width: 100%;
  529. border: 2px solid #aaaacc;
  530. background: #ffffff;
  531. }
  532. div.filtered2
  533. {
  534. margin: 4pt 0 8pt -26px;
  535. padding: 4px 4px 8px 26px;
  536. width: 100%;
  537. border: none;
  538. background: #ffffff;
  539. }
  540. div.filtered h1, div.filtered h2, div.filtered h3, div.filtered h4
  541. {
  542. margin-left: -22px;
  543. }
  544. div.filtered span.lang
  545. {
  546. position: relative;
  547. left: -22px;
  548. }
  549. div.reftip
  550. {
  551. position: absolute;
  552. z-index: 1;
  553. padding: 8pt;
  554. visibility: hidden;
  555. border: 1px solid #000000;
  556. background: #ffffd0;
  557. }
  558. a.synParam
  559. {
  560. color: #0000FF;
  561. /*color: #3F7800;*/
  562. /*color: #8DC54F;*/
  563. text-decoration: none;
  564. font-weight: normal;
  565. }
  566. a.synParam:hover
  567. {
  568. text-decoration: underline;
  569. font-weight: normal;
  570. }
  571. div.sapop
  572. {
  573. position: absolute;
  574. z-index: 1;
  575. left: 26px;
  576. width: 100%;
  577. padding: 10px 10px 10px 36px;
  578. visibility: hidden;
  579. border: 1px solid #000000;
  580. background: #ffffd0;
  581. }
  582. div.footer
  583. {
  584. width: 100%;
  585. border: none;
  586. background: #ffffff;
  587. margin-top: 18pt;
  588. padding-bottom: 12pt;
  589. color: #0000FF;
  590. /*color: #228B22; */
  591. text-align: center;
  592. font-size: 76%;
  593. }
  594. div.preliminary
  595. {
  596. margin-top: 8pt;
  597. padding-bottom: 12pt;
  598. color: #A0A0A0;
  599. }
  600. /* A procedure section. eg. 'To create a file', 'To add a value' */
  601. div.proc
  602. {
  603. margin-left: 0.5em;
  604. }
  605. /* The title of a 'procedure' section. */
  606. div.proc h3
  607. {
  608. font-family: Verdana, Arial, Helvetica, sans-serif;
  609. font-weight: bold;
  610. font-size: 115%;
  611. margin-top: 1em;
  612. margin-bottom: 0.4em;
  613. margin-left: -0.5em;
  614. color: #003399;
  615. }
  616. div.proc ul
  617. {
  618. margin-left: 1.5em;
  619. }
  620. div.proc ol
  621. {
  622. margin-left: 2.0em;
  623. }
  624. .note
  625. {
  626. margin-left: 14pt;
  627. margin-right: 12pt;
  628. }
  629. .indent1
  630. {
  631. margin-left: 12pt;
  632. }
  633. .indent2
  634. {
  635. margin-left: 24pt;
  636. }
  637. .indent3
  638. {
  639. margin-left: 36pt;
  640. }
  641. p.proch
  642. {
  643. padding-left: 16px;
  644. }
  645. p.proch img
  646. {
  647. position: relative;
  648. vertical-align: top;
  649. left: -18px;
  650. margin-right: -14px;
  651. margin-bottom: -18px;
  652. }
  653. div.clsPlatSpec
  654. {
  655. background-color:#FFF8DC;
  656. border-style:solid;
  657. border-width:1pt 0pt 0pt 1pt;
  658. border-color:#ffE4C4;
  659. margin-top:0.6em;
  660. width:100%;
  661. }
  662. /* Applies to the language labels in the Language Filter drop-down list. */
  663. .languageFilter
  664. {
  665. color: #0000FF;
  666. cursor:hand;
  667. text-decoration:underline;
  668. padding-bottom:4;
  669. }
  670. /* Dropdown areas */
  671. #languageSpan {
  672. position: absolute;
  673. visibility: hidden;
  674. border-style: solid;
  675. border-width: 1px;
  676. border-color: #C8CDDE;
  677. background: #d4dfff;
  678. padding: 4px;
  679. font-size: 70%;
  680. }
  681. #membersOptionsSpan {
  682. position: absolute;
  683. visibility: hidden;
  684. border-style: solid;
  685. border-width: 1px;
  686. border-color: #C8CDDE;
  687. background: #d4dfff;
  688. padding: 4px;
  689. font-size: 70%;
  690. }
  691. .auto-style1 {
  692. font-family: Verdana, Arial, Helvetica, sans-serif;
  693. font-weight: bold;
  694. font-size: 115%;
  695. }
  696. --></style>
  697. <xml>
  698. <MSHelp:TOCTitle Title="Pathfinding Sample" />
  699. <MSHelp:RLTitle Title="Pathfinding Sample" />
  700. <MSHelp:Keyword Index="A" Term="O:Microsoft.Xna.Pathfinding" />
  701. <MSHelp:Keyword Index="A" Term="398f9c2c-f42f-5ea8-9bb4-ed2e946c5012" />
  702. <MSHelp:Keyword Index="K" Term="Pathfinding Sample" />
  703. <MSHelp:Attr Name="ProjType" Value="LocalProj" />
  704. <MSHelp:Attr Name="ProjType" Value="XNA_30" />
  705. <MSHelp:Attr Name="DocSet" Value="XNA" />
  706. <MSHelp:Attr Name="DocSet" Value="ExpressLibVS" />
  707. <MSHelp:Attr Name="DocSet" Value="C#" />
  708. <MSHelp:Attr Name="Locale" Value="en-us" />
  709. <MSHelp:Attr Name="CommunityContent" Value="1" />
  710. <MSHelp:Attr Name="AssetID" Value="398f9c2c-f42f-5ea8-9bb4-ed2e946c5012" />
  711. <MSHelp:Attr Name="TopicType" Value="kbOrient" />
  712. </xml>
  713. </head><body><div id="mainSection"><div id="mainBody">
  714. <h1>Pathfinding Sample</h1>
  715. This sample demonstrates how AIs can use algorithms to navigate a map using
  716. waypoints.
  717. <a name="ID2EK"></a><h1 class="heading">Sample Overview</h1><div id="ID2EK" class="hxnx1">
  718. <p>
  719. To create realistic enemy movement AI, implementing Pathfinding algorithms
  720. becomes necessary. The goal of pathfinding is to explore possible routes
  721. to get from one point, or node, to another, often with the goal of finding
  722. the quickest route. To get started, this sample demonstrates three common
  723. pathfinding algorithms: Breadth-First, Best-First and A* (A-Star). To
  724. illustrate the logic behind these algorithms, the searched nodes are
  725. represented as red dots, while the nodes available to search are
  726. represented as green dots. Once the algorithm has found the end, the tank
  727. travels the path to its destination.</p>
  728. <p>This sample uses the following controls.</p>
  729. <table>
  730. <tr>
  731. <th>Action</th>
  732. <th style="width: 192px">Windows Phone</th>
  733. <th>Windows - Keyboard Control</th>
  734. <th>Windows/Xbox - Gamepad Control</th>
  735. </tr>
  736. <tr>
  737. <td>Start the pathfinding algorithm</td>
  738. <td style="width: 192px"><strong>TAP</strong> &quot;Start/Stop&quot; button</td>
  739. <td>A</td>
  740. <td>A</td>
  741. </tr>
  742. <tr>
  743. <td>Reset the map</td>
  744. <td style="width: 192px"><strong>TAP</strong> &quot;Reset&quot; button</td>
  745. <td>B</td>
  746. <td>
  747. B</td>
  748. </tr>
  749. <tr>
  750. <td>Switch the map</td>
  751. <td style="width: 192px"><strong>TAP</strong> &quot;Next Map&quot; button</td>
  752. <td>Y</td>
  753. <td>
  754. Y</td>
  755. </tr>
  756. <tr>
  757. <td>Switch the pathfinding algorithm</td>
  758. <td style="width: 192px"><strong>TAP</strong> &quot;Pathfinding Mode:&quot; button</td>
  759. <td>X</td>
  760. <td>X</td>
  761. </tr>
  762. <tr>
  763. <td>Change the time step</td>
  764. <td style="width: 192px"><strong>DRAG</strong> &quot;Time Step&quot; slider</td>
  765. <td>LEFT ARROW, RIGHT ARROW</td>
  766. <td>
  767. D-Pad LEFT, D-Pad RIGHT</td>
  768. </tr>
  769. <tr>
  770. <td style="height: 26px">Exit the game.</td>
  771. <td style="width: 192px; height: 26px;"><strong>BACK</strong></td>
  772. <td style="height: 26px">ESC or ALT+F4</td>
  773. <td style="height: 26px">
  774. <b>BACK</b>
  775. </td>
  776. </tr>
  777. </table>
  778. </div>
  779. </div>
  780. <a name="ID2EHE"></a><h1 class="heading">How the Sample Works</h1><div id="ID2EHE" class="hxnx1">
  781. <p>
  782. &nbsp;</p>
  783. <h2 class="subHeading">Pathfinding Behavior</h2>
  784. <div id="ID2E1D" class="hxnx2">
  785. <p>All of the pathfinding algorithms below rely on searching a graph
  786. of nodes, named waypoints for the purposes of our sample, to get
  787. from a start point to a goal. The algorithms described below can be
  788. useful in different situations, and so it is important to understand
  789. the way in which your algorithm will be used. Adding cost to your
  790. nodes is a prime example. For instance, if you had a game where
  791. traveling over mountains resulted in a slower movement speed than
  792. traveling over a plain, the cost of a particular mountain node might
  793. be 5, where a plain node would be 1. This will allow certain
  794. pathfinding algorithms to determine whether it is more efficient to
  795. over the mountain or around it. A brief description of each of the
  796. supplied algorithms is listed below:</p>
  797. <p>&nbsp;</p>
  798. <a name="ID2ECE"></a>
  799. <span class="auto-style1">Breadth-First</span><div id="ID2EEF" class="hxnx3">
  800. <p>The Breadth-First algorithm uses a graph search that explores
  801. all nodes neighboring a given root node. It then searches the
  802. neighbors of the neighbors and continues in this manner until
  803. the goal has been found or all available neighbors from the root
  804. have been searched. This algorithm is useful if you want to
  805. exhaustively search the map for every possible path, but also
  806. results in the slowest implementation.</p>
  807. </div>
  808. <h4 class="subHeading">Best-First</h4>
  809. <div id="ID2ECE" class="hxnx3">
  810. <p>The Best-First algorithm searches through the node graph in
  811. an attempt to find the shortest distance to the goal. This
  812. algorithm will always find the shortest distance to the goal,
  813. but does not take the cost into account. Best-First is best used
  814. in scenarios where nodes have a uniform cost.</p>
  815. </div>
  816. <a name="ID2EUE"></a>
  817. <h4 class="subHeading">A*</h4>
  818. <div id="ID2EUE" class="hxnx3">
  819. <p>A* pathfinding combines a Best-First search with a heuristic,
  820. or educated guess, that searches for the lowest cost route. A*
  821. will always return the route with the lowest cost to the goal.
  822. This algorithm is most useful where nodes have varying costs
  823. associated with them.</p>
  824. </div>
  825. <a name="ID2EEF"></a>
  826. <a name="ID2EYF"></a>
  827. </div>
  828. </div>
  829. <a name="ID2EAH"></a><h1 class="heading">Extending the Sample</h1><div id="ID2EAH" class="hxnx1">
  830. <ul>
  831. <li>Add cost to the different nodes to support different types of
  832. terrain</li>
  833. <li>Add the ability to move the goal at runtime and have the path
  834. change dynamically </li>
  835. <li>Add additional algorithms</li>
  836. </ul>
  837. </div>
  838. </div><div class="footer" id="footer"><p>© 2010 Microsoft Corporation. All rights reserved.<br>Send feedback to
  839. <a href="mailto:[email protected]?subject=Documentation Feedback: Pathfinding Sample">
  840. [email protected]</a>.</p></div></div></body></html>