首页 > > 详细

Java辅导最短路径Explore Documentation讲解Java语言、Java讲解

,,。
 

User manual

Explore constructs hex-grid terrain maps from a textual specification and produces a graphical display of the result (Error: Reference source not found.) Version 2 adds a new shortest path capability.

Explore v.2 can draw any size rectangular map your computer hardware can accommodate. The display engine will automatically supply scroll bars for maps which are too big for your display.

Explore v.2 maps are composed of terrain cells and cell to cell “connectors” which describe traffic way and water ways. Connectors are “weighted” by their traffic capacity. Version 2 also includes provision for marking start and end cells and for computing the shortest path between those cells. The viewer includes new support for displaying the shortest path. (See Error: Reference source not found.)

Explore Terrain Features

Terrain maps are composed of up to four different terrain types, four different connector types, barriers, and some special markers. Each cell’s “background” graphic corresponds to the terrain type in that cell. details the different terrain types. Traffic can cross from cell to cell, even without a connector. When there is no connector at a cell edge, the traffic capacity is that of the lower capacity cell.

Connectors cross cell boundaries, going from center to center on adjacent cells. Each Connector has a traffic capacity independent of the underlying terrain. Error: Reference source not found gives connector details. Traffic capacity goes up as edge weight (cost of travel) goes down.

Explore automatically computes the effective capacity of each cell wall, using the following policy:

  • if the has a barrier, the weight for that edge is 900.
  • if the there is no connector between two cells, the weight is the maximum of the terrain weight in the two cells. For example, an edge between forest and default would have an effective weight of 195.
  • if there is a connector between two cells the edge weight will be the connecter weight. (It is possible for the edge weight to be less than the connector weight, but only if the capacity of the underlying terrain exceeded the capacity of the connector.
    Table 1 - Terrain details
Name Represents Weight
default Relatively flat, easily traversed open land. 165
brush Like default, but with low obstacles. 180
forest Dense trees. Difficult for vehicular traffic. 195
water Open, relatively still water, such as a lake or pond. Not necessarily suitable for high speed craft. 190
flag1 The start cell. 0
flag2 The finish point. 0

Table 2 - Connector Details

Names Represents Weight
dividedhwy, Hw4 An interstate or turnpike quality high speed trafficway. 110
hwy, Hw2 A two-lane, two-way (e.g., state or county) highway. 130
unpaved, dirt An unpaved, dirt or gravel road or path 143
river Moving water, but may be navigable only by certain craft. 185
barrierwall, wall A barrier. 900

Installation

Explore is supplied only as source code. Thus, there is no installer. Explore is distributed as a single zip archive file. The name of this file may differ between providers and versions. If you cannot determine the appropriate file to download, please contact your provider.

If you are a developer, you may prefer to follow the installation advice in the Developer Documentation and add the source to a project in your IDE.

To install the application as a user:

  1. Download the zip file into a folder (directory) of your choice.
  2. Use your local system zip utility to unpack the file. Depending on your operating, this utility may be named unzip, gunzip, zip, 7-zip, or something similar. On many systems you can simply right click on the file in your file browser and select “unzip” or “extract here”.
  3. Once you have unpacked the archive, you should browse into the new file hierarchy. In the first two or three levels you should find a folder named “src”.
  4. When you have found this “src” directory, open a command line shell and cd into the src directory. (If this operation is unfamiliar, ask a developer friend for help.
  5. You now need to compile the code.
  6. If the compile operation completes without any messages indicating an error, then you should now have an executable version of Explore.

Creating Your Own Terrain Files

Explore terrain descriptions are simple text files. Thus you can create your own mazes in any simple text editor. (Explore graph descriptions must be .txt files. Explore does not understand word processer or document files, such as .doc or .pdf.)

Locations

Locations in the terrain file are specified with Hex coordinates, corresponding to a vertical column number and a diagonal row number, as highlighted in Error: Reference source not found. Note that cell(0,0) is at the upper left corner, and rows and columns indexes grow larger as you move right and down. The left number in cell(x,y) corresponds to the cell’s column; the right number to its diagonal row. The red star in Error: Reference source not found is in cell(1,2).

(Tip: You can make a screen capture of a terrain map with no features, and print it to create a nicely labeled design layout grid. Creating the text file is much easier if you draw your terrain design on the grid and then transcribe the cell appropriate cell numbers.)

Directions

Cell walls are named by their direction from the center of the cell. In terrain files, these wall names (in clockwise order from the top of the cell) are abbreviated “up”, “ur”, “dr”, “dn” &lⁱ⁤‬…⹱⁵䍯ⁱ‮⁡†⁰⁲⁷⹯㱲⽥㹣ൡੳ㱥㍩㵯≭䥥⵩ⵡ⴬䠠≩㹳䤠⁥⁰⁩䡣㱯⼠㍳㹥ഠ੯㱮㹹䌠⁲⁳⁲⹡†⁩⁣⁩‼‽⁴ⰾ⁆⁥⁣⁲‼‍⁴⁡⁣⹯䤠⁳♯㭥†⁣⁷⁣⁦Ⱐ⁤⁨⁰†⁳⁴⁳⁲⹥㱲⽲㹩൮ਬ㰠㹯䥮⁥⁲⁡ⱗ⁩†⁦†⁩
⁳⁰⹲㰠⽯㹬൹ਠ㱯㉣⁥㵡≮䑤ⴠ∠㹩䑮⁥㰠⽴㉥㸠൦੬㱡㌠⁳㵴≩⵨䐠⵰⵲䄠≮㸠Ⱐ䑡Ᵽ⁲⁩䅯㱭⽡㌠㹢൥ਠ㱬㹳䙴†ㅡ⁥⁡⁥⁷⁤⁴䔠⹡⁴⁡⁹⁳‾‾⁲⁵†⁷⁡⁸⁰⁥⁳Ɱ†⁥⁩†⁡†⁡♥㭵⁥⹲㱳⼮㸯൰ਾ㰍㌼⁰㵩≴⵸䙣⵩≴㹨⁴䙲㱩⽥㍷㹡൬੬㰠㹥⁥
⁥†⁨㱴⽥㹲ൡ੩㱮㹳㱣㹩㬠㭮㩳㨠⁡⁴㭥㬠㭷㬠⬦൬੤㭯㭱㩵㩯※㭲㬻㽲㭲㭦⩯㭷㭴⨠⁦㭥㭡⩴൥ੳ㬯㬠㩩㩤‽㭥㭯㭤㬾ൔ੥㭡㭮⁡㩴㩥⁳⠼⥩㭥㬠⭴⁨൥ਠ㭳㭮㩡㩴⡥⥳†㬠㭭൥ਠ㭲㭔⁨㩵㩳‬㭨⁴㬠㭥†㭯⩲㭮⁳㭥൹ਠ㭮㭧㩵㩯⁵‬㭲㭥⭲ൡ੬㭬‮㭩⁧㩮㩥⁲㭦㭵⁳㭵㭥ഠ੥㱡⽣㹵㱳⽴㹯൦ਠ㱬㹫䅥⁩㱮⽴㹳൥੣㱴㹮മਠ⁅⁸⁰㱯㸠⁳ⁱ†‼ ⁨ⱐ⁡⁳⁴䍯⁨⁨⁤⁴⁰⁡†⹭㱵⽳㹭൥੥⁴†⁣㱮㹲䝡⁡⁳⁴†⁲⁣⹮⁵䝯†⁲⸠⁣⁥†⁴⁥⹳†䥴⁥⁤⁴ⱡ⁣⁰†⁨⁴†⁷
⹲㰬⼠㹲ഠ੥⁸⁡⁰㱬㸠⁴⁵⁳⁳⁡⁴⁤⁡⹩䠠†⁳⁣⁴†⁡⁴⁥  ⁩‭⁤‾†⁳ ⁔†⁷⹹†⁣†⁥⁥⁥⁴†♮㬠♤㬠
⹦㱬⽡㸼യੰ‾‍ ‼㱨㹩䕤⁥⁥  ⁨⁧⁲⁥⁢⡥⁦⁥⁹⁸⥬⹹†䕴⁩⁥‮†⁰⁥⁨⁩⁴※⹳⁥†⁡ⱨ⁥⁩Ⱐ⁲⁨⁲⁢⁲⁳⁷⁴⁵‮⁤⁩⁡•⁩†‾‾⁲⹬⁳⁢⡥⥥⁣⁡†⁥†⁲⹳⁥⵳††⁲⁩⁰⁵⹩㱮⽡㸩ഠੴ㱨⽡㹡൲੥㰠㍬㵥≤䤠⵩⵸䑡≥㸬䤠⁷⁲䐠㱭⽥㍴㸠൤੥㱳㹩ൢ੥⁳†⁴⁷㱯㹵䍬⁲䑲⸠㱩⽮㹲൲੯⁲›†⁒㱥㹲⁲⹯㱵⽮㸼യੰ‾‍ ‼㱰㸾䐼†‍㰯⽰㸾഍ਊ‼⁰‾⁅㱡㸠ⴠ⁥Ⱐ⁣Ⱐ⁡⁴⁦⸠㱡⼠㹳൴ਠ⁦†⁣㱥㸠䥷⁤䨠⁥⁰†⹥㱲⽷㹬ഠ੫⁥⁹⁷㱲㹣䱡㰠⽢㹡൳ਠ⁡⁹㰠㹲䅤㱣⽲㹴൩੯⁳†⁡㱳㹯䝭⹳䕩⁲⁩䝫⸠⁢⡥⹡⁣⁥⥯㱦⼠㹲൲੩⁥⁲†⁩㱮㸠⁴⁲䍲㱳⽥㹩൯੮‮‼ ⁰㰾㸼⁄‭⁔䙮㱡⽹㹧ഠੁ†⁔⁥⁲㱲㹮‼⁰†㱣⽵㹲ഠੴ⁥⁲⁲⁡㱩㹭†⁥†⁡†⁵†⁡†⁨⁰⹯㱲⽥㹤൱ੵ㱯⼻㹩൴੨㰠㍨⁥㵡≴⵵ⵥⴠ䡦ⵦ≭㹯‮⁴䡯⁷㱧⼠㍩㹲൥੣㱴㹲⁲䵥Ɒ⁩†㉴⹨づ⁲⁵⁥䕳†⁥⁨⹡⁴⁴Ⱪ⁴†⁰⁹䘠Ⱪ⁰⁤⁹⁲♥㬠⹮♧㭣䅭  ※⁲⁥⁴ ⁥⁰‍⁙†⸠㱲⽥㹡൴੩㱶㸠䡰Ⱐ⁡†⁥⁡⁩⁡⁨⁥䱭⁲⁡⁥⁹⹣⁲†⁲⁲⁲⁸⁥⁴‬ⱹ††⁥⁹⁵⁩⁸⁥⁡䝥⁹⁴⁰⁰⹥‾†⁳⁸‼⁲⹰㰾⽉㸠൮੥㱩㉨⁥㵯≦䌠ⴠ⵳⵳䱩≯㹲䌠⁴⁲䱳㱴⽩㉮㸠ൡ੮㱤㹦䅡⁲†⁳⁨⁴⁙⁷†ⱳ⁥Ⱐ⁡⁳⁳⁥⁡⁲⁴Ⰺ‼•⁤䱃⹃⁴䰊Ᵽ⁡††⁩⡮⁡†⁵⁥††⁨⤬†⁥⹵䅡ⱥ†⁳⁡⁴⁨⁲†䍶⽤⁡䝢⁤⁡⹬㱡⽴㹯൮ਠ㱩㸠⁵⁥⁣⁳䱡††⁧ⱴ⁥Ɽ†ⁱ⹲⁹⁩⁥‮⁳⁡⁲⁩⁡⁣⡴⁩⁡⁈ ⁰⥳⸠⁃⁤⹡㱴⽥㹲൥ੰ㱲㹳䥥⁴⁵⁤…⼻⼠䐠㩨⁥†⁡⁴†⁤†‬⁧⡨⥯⁲䝩⹤⁥⹮⁴䵩⁶⁵⁡⁨⁩‼☯㭰♃㭮⁡†⁣⁣⡯⁵⁴⁲††⥰⁨⁩‮⸍ 䔼‍†⁴
†⁤⁥⁧†⁴♥㭵♮㭮⁤ ‾†⁸⁹䝡ⱦ⁲⁥㩲㱤⽩㹡൴੥㰠㹩൲ਮ‼ ⁩㰾㸠ഠਠ†‼⁩㰾㹯䙩⠨䌠ㄠⱢ䍯
㉲⥴⹳†⁲⁡⁲⁲ ‍‾⁥ⱥ⁤ⱴ⁥⁲⁥⁶⹯†䅵⁥⁦⁥⁴†⁧⁡

⁩⁴⁳⁩⁔⁡⁥⹡㱳⼠㸠൐੡⁩⁲†㱢⽪㹴ഠ੷⁨⁩⁣⁨㰠㹣൬ੵ⁤⁥⁳†㱡㸠䍥⡬※ⱱ⁵䍯⁵⥲⹳ⁱ䱵†⁵※†⁩†Ⱐ⁩⁢⁳⹯㱡⽲㸠ന੨⁥⁸
‬㰠⽒㹴ൡ੮⁧⁵⁡㱲㹯൲ਠ⁓⁣⁲⁥㱥㸠⠠䱳⁥Ⰽ ⥢⹬⁩䵣⁲⁴
⁲†⁰⁲‾†⹢⁡⁧ⱴ†Ⱳ†⹮⁧†‬⁩‼‾⁣⁥⁵⁲‾⸾㱃⽯㹲൤੩⁡⁴⁥㰠⽯㹥ൣੴ⁳†⁡㱳㹳൵ੰ⁰⁲⁴㰠㹡䉵䕬⡡䱮Ɐ䍶⤠⹦⁵‮⁲ ⁵ ‾⁩⁡⁩⁣⁲
†⁦⁨⹮⁡⁨⁨††⁧‮⁩ⱐ⁡⁧⁄⁴⁩⁴⁣⁴†⁸†⁲⁢⁷⁴⸍ ⰼ⁥
†
⵵⁴⁣†⹨㱥⼠㹯ൡੲ⁤†⁥㱩⽧㹯൲ਠ⁡⁴†⁤㱩㹣൴੩†⁤㱩㸮⠾⤾⹓⁥Ɱ⁣⁥⁥†⁤⁥⁡⁲⁴⁥ ‼†⁸⁲⁈⁲″♲㭧⁳⁲⁥†⁩⁳‬††⹡⁹†⁴⁥⁵⁥⁴‮⁥⁰Ⱐ
⁥⁥⁵⁳⁰†⹰⁰䙩Ⱳ⁡⁲†⁩⁩⁴⁰⁩⁡⁤⁥Ɐ⁴⁩⁹⁣⁶⹮⁴䄠⁲⁥⁩䍥⁩⁴⁨⁲⁩⁴⁷†䔠⁥⁡⁳⹢㱥⽴㹥൥੮†⁴⁷㰠⽃㹲൤੩㱮⽡㹳ഩਠ㱩㹴⁹☠㭤⁲☮㭡⁲⁡⁳⁲⁰ 䰠‾⁲⁥†⁥⁥䝲⸠㱤⽥㹲൥੥㱳㉦⁲㴠≴䑨⵴䥩∠㸼䑬†䥦㱩⽮㈠㹤ഩਠ㱲㍴⁵㵳∠䑴ⵄⵣ䅯⵩∠㹴䑨⁥䅲⁳㱴⼠㍩㹲൥੣㱴㹯䱢⁴⁥⁩⁳⁲⁲⁥†⁳⁩⁸⁥⁳䱩⹲Ⰽ ‼•⁡⁲⁣⁲″⁰†Ⱪ⁺††⁥†⁷⁊⁴‬⁡†ⵡ†⹡⁢⁡†⁂⁲⁧⁥⁨‬ⱥ†⁵⁲†⁤⁩⁹†⁰⁥⁴⹭㱥⽮㹳ഠ੬㱩㍥†㵩≳䐮ⴾ⵰䐾ⵡ䅭≷㹯䑲⁦⁴䑨⁥䄠㱤⽥㍓㹥൧੭㱥㹴⁴ ‼⁓♣㬠⁷♮㭴⁨⁩†⁨⁰‭⁣⁥⁥‼″‽⁥•♯㭬⁲″ ⁆⁲⁩†⁡†††⁤⹥㱦⽥㹤൳ਠ㱷㹴䍨ⱡ⁲䍡⹵ⱴ†ⱴ⁨䉩ⱹ䍵Ɐ††⹮㱮⽥㸮ഠ੍㱯㹥⁡††⁳⁴⁥⁶Ⱶ⁡†⁵⁰⁥ⱴ⁥⁩⁲†⁨ while it certainly helps readability, can greatly complicate parsing. The NoiseFilterReader makes it all go away.

To process a string (e.g., to make test construction more convenient), the setup would be.

A similar sequence, but chaining File and FileReader in place of StringReader can be used to strip punctuation from your terrain descriptions.

The NoiseFilterReader is an example of specialization through delegation (instead of through inheritance). If you look at the definition, you will see a lot of code, but with the exception of three or four methods, all of that code was generated using the eclipse sourcegt;generategt;delegate.

Diagnostic Aids

The toString() override on Graph (inherited by both HexGraph and TerrainGraph) will print the following style dump of the graph with edge weights. If called after TerrainLoader has finished constructing TerrainGraph, you will get a dump like the following, which includes the effective weight associated with each vertex. Currently this is the most convenient way to check that edge weights are being computed properly.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!