|
1 | | -package aima.core.environment.map; |
2 | | - |
3 | | -/** |
4 | | - * Represents a simplified road map of Romania. The initialization method is |
5 | | - * declared static. So it can also be used to initialize other specialized |
6 | | - * subclasses of {@link ExtendableMap} with road map data from Romania. Location |
7 | | - * names, road distances and directions have been extracted from Artificial |
8 | | - * Intelligence A Modern Approach (2nd Edition), Figure 3.2, page 63. The |
9 | | - * straight-line distances to Bucharest have been taken from Artificial |
10 | | - * Intelligence A Modern Approach (2nd Edition), Figure 4.1, page 95. |
11 | | - * |
12 | | - * @author Ruediger Lunde |
13 | | - */ |
14 | | -public class SimplifiedRoadMapOfPartOfRomania extends ExtendableMap { |
15 | | - |
16 | | - public SimplifiedRoadMapOfPartOfRomania() { |
17 | | - initMap(this); |
18 | | - } |
19 | | - |
20 | | - // The different locations in the simplified map of part of Romania |
21 | | - public static final String ORADEA = "Oradea"; |
22 | | - public static final String ZERIND = "Zerind"; |
23 | | - public static final String ARAD = "Arad"; |
24 | | - public static final String TIMISOARA = "Timisoara"; |
25 | | - public static final String LUGOJ = "Lugoj"; |
26 | | - public static final String MEHADIA = "Mehadia"; |
27 | | - public static final String DOBRETA = "Dobreta"; |
28 | | - public static final String SIBIU = "Sibiu"; |
29 | | - public static final String RIMNICU_VILCEA = "RimnicuVilcea"; |
30 | | - public static final String CRAIOVA = "Craiova"; |
31 | | - public static final String FAGARAS = "Fagaras"; |
32 | | - public static final String PITESTI = "Pitesti"; |
33 | | - public static final String GIURGIU = "Giurgiu"; |
34 | | - public static final String BUCHAREST = "Bucharest"; |
35 | | - public static final String NEAMT = "Neamt"; |
36 | | - public static final String URZICENI = "Urziceni"; |
37 | | - public static final String IASI = "Iasi"; |
38 | | - public static final String VASLUI = "Vaslui"; |
39 | | - public static final String HIRSOVA = "Hirsova"; |
40 | | - public static final String EFORIE = "Eforie"; |
41 | | - |
42 | | - /** |
43 | | - * Initializes a map with a simplified road map of Romania. |
44 | | - */ |
45 | | - public static void initMap(ExtendableMap map) { |
46 | | - // mapOfRomania |
47 | | - map.clear(); |
48 | | - map.addBidirectionalLink(ORADEA, ZERIND, 71.0); |
49 | | - map.addBidirectionalLink(ORADEA, SIBIU, 151.0); |
50 | | - map.addBidirectionalLink(ZERIND, ARAD, 75.0); |
51 | | - map.addBidirectionalLink(ARAD, TIMISOARA, 118.0); |
52 | | - map.addBidirectionalLink(ARAD, SIBIU, 140.0); |
53 | | - map.addBidirectionalLink(TIMISOARA, LUGOJ, 111.0); |
54 | | - map.addBidirectionalLink(LUGOJ, MEHADIA, 70.0); |
55 | | - map.addBidirectionalLink(MEHADIA, DOBRETA, 75.0); |
56 | | - map.addBidirectionalLink(DOBRETA, CRAIOVA, 120.0); |
57 | | - map.addBidirectionalLink(SIBIU, FAGARAS, 99.0); |
58 | | - map.addBidirectionalLink(SIBIU, RIMNICU_VILCEA, 80.0); |
59 | | - map.addBidirectionalLink(RIMNICU_VILCEA, PITESTI, 97.0); |
60 | | - map.addBidirectionalLink(RIMNICU_VILCEA, CRAIOVA, 146.0); |
61 | | - map.addBidirectionalLink(CRAIOVA, PITESTI, 138.0); |
62 | | - map.addBidirectionalLink(FAGARAS, BUCHAREST, 211.0); |
63 | | - map.addBidirectionalLink(PITESTI, BUCHAREST, 101.0); |
64 | | - map.addBidirectionalLink(GIURGIU, BUCHAREST, 90.0); |
65 | | - map.addBidirectionalLink(BUCHAREST, URZICENI, 85.0); |
66 | | - map.addBidirectionalLink(NEAMT, IASI, 87.0); |
67 | | - map.addBidirectionalLink(URZICENI, VASLUI, 142.0); |
68 | | - map.addBidirectionalLink(URZICENI, HIRSOVA, 98.0); |
69 | | - map.addBidirectionalLink(IASI, VASLUI, 92.0); |
70 | | - // addBidirectionalLink(VASLUI - already all linked |
71 | | - map.addBidirectionalLink(HIRSOVA, EFORIE, 86.0); |
72 | | - // addBidirectionalLink(EFORIE - already all linked |
73 | | - |
74 | | - // distances and directions |
75 | | - // reference location: Bucharest |
76 | | - map.setDistAndDirToRefLocation(ARAD, 366, 117); |
77 | | - map.setDistAndDirToRefLocation(BUCHAREST, 0, 360); |
78 | | - map.setDistAndDirToRefLocation(CRAIOVA, 160, 74); |
79 | | - map.setDistAndDirToRefLocation(DOBRETA, 242, 82); |
80 | | - map.setDistAndDirToRefLocation(EFORIE, 161, 282); |
81 | | - map.setDistAndDirToRefLocation(FAGARAS, 176, 142); |
82 | | - map.setDistAndDirToRefLocation(GIURGIU, 77, 25); |
83 | | - map.setDistAndDirToRefLocation(HIRSOVA, 151, 260); |
84 | | - map.setDistAndDirToRefLocation(IASI, 226, 202); |
85 | | - map.setDistAndDirToRefLocation(LUGOJ, 244, 102); |
86 | | - map.setDistAndDirToRefLocation(MEHADIA, 241, 92); |
87 | | - map.setDistAndDirToRefLocation(NEAMT, 234, 181); |
88 | | - map.setDistAndDirToRefLocation(ORADEA, 380, 131); |
89 | | - map.setDistAndDirToRefLocation(PITESTI, 100, 116); |
90 | | - map.setDistAndDirToRefLocation(RIMNICU_VILCEA, 193, 115); |
91 | | - map.setDistAndDirToRefLocation(SIBIU, 253, 123); |
92 | | - map.setDistAndDirToRefLocation(TIMISOARA, 329, 105); |
93 | | - map.setDistAndDirToRefLocation(URZICENI, 80, 247); |
94 | | - map.setDistAndDirToRefLocation(VASLUI, 199, 222); |
95 | | - map.setDistAndDirToRefLocation(ZERIND, 374, 125); |
96 | | - } |
97 | | -} |
| 1 | +package aima.core.environment.map; |
| 2 | + |
| 3 | +/** |
| 4 | + * Represents a simplified road map of Romania. The initialization method is |
| 5 | + * declared static. So it can also be used to initialize other specialized |
| 6 | + * subclasses of {@link ExtendableMap} with road map data from Romania. Location |
| 7 | + * names, road distances and directions have been extracted from Artificial |
| 8 | + * Intelligence A Modern Approach (2nd Edition), Figure 3.2, page 63. The |
| 9 | + * straight-line distances to Bucharest have been taken from Artificial |
| 10 | + * Intelligence A Modern Approach (2nd Edition), Figure 4.1, page 95. |
| 11 | + * |
| 12 | + * @author Ruediger Lunde |
| 13 | + */ |
| 14 | +public class SimplifiedRoadMapOfRomania extends ExtendableMap { |
| 15 | + |
| 16 | + public SimplifiedRoadMapOfRomania() { |
| 17 | + initMap(this); |
| 18 | + } |
| 19 | + |
| 20 | + // The different locations in the simplified map of part of Romania |
| 21 | + public static final String ORADEA = "Oradea"; |
| 22 | + public static final String ZERIND = "Zerind"; |
| 23 | + public static final String ARAD = "Arad"; |
| 24 | + public static final String TIMISOARA = "Timisoara"; |
| 25 | + public static final String LUGOJ = "Lugoj"; |
| 26 | + public static final String MEHADIA = "Mehadia"; |
| 27 | + public static final String DOBRETA = "Dobreta"; |
| 28 | + public static final String SIBIU = "Sibiu"; |
| 29 | + public static final String RIMNICU_VILCEA = "RimnicuVilcea"; |
| 30 | + public static final String CRAIOVA = "Craiova"; |
| 31 | + public static final String FAGARAS = "Fagaras"; |
| 32 | + public static final String PITESTI = "Pitesti"; |
| 33 | + public static final String GIURGIU = "Giurgiu"; |
| 34 | + public static final String BUCHAREST = "Bucharest"; |
| 35 | + public static final String NEAMT = "Neamt"; |
| 36 | + public static final String URZICENI = "Urziceni"; |
| 37 | + public static final String IASI = "Iasi"; |
| 38 | + public static final String VASLUI = "Vaslui"; |
| 39 | + public static final String HIRSOVA = "Hirsova"; |
| 40 | + public static final String EFORIE = "Eforie"; |
| 41 | + |
| 42 | + /** |
| 43 | + * Initializes a map with a simplified road map of Romania. |
| 44 | + */ |
| 45 | + public static void initMap(ExtendableMap map) { |
| 46 | + // mapOfRomania |
| 47 | + map.clear(); |
| 48 | + map.addBidirectionalLink(ORADEA, ZERIND, 71.0); |
| 49 | + map.addBidirectionalLink(ORADEA, SIBIU, 151.0); |
| 50 | + map.addBidirectionalLink(ZERIND, ARAD, 75.0); |
| 51 | + map.addBidirectionalLink(ARAD, TIMISOARA, 118.0); |
| 52 | + map.addBidirectionalLink(ARAD, SIBIU, 140.0); |
| 53 | + map.addBidirectionalLink(TIMISOARA, LUGOJ, 111.0); |
| 54 | + map.addBidirectionalLink(LUGOJ, MEHADIA, 70.0); |
| 55 | + map.addBidirectionalLink(MEHADIA, DOBRETA, 75.0); |
| 56 | + map.addBidirectionalLink(DOBRETA, CRAIOVA, 120.0); |
| 57 | + map.addBidirectionalLink(SIBIU, FAGARAS, 99.0); |
| 58 | + map.addBidirectionalLink(SIBIU, RIMNICU_VILCEA, 80.0); |
| 59 | + map.addBidirectionalLink(RIMNICU_VILCEA, PITESTI, 97.0); |
| 60 | + map.addBidirectionalLink(RIMNICU_VILCEA, CRAIOVA, 146.0); |
| 61 | + map.addBidirectionalLink(CRAIOVA, PITESTI, 138.0); |
| 62 | + map.addBidirectionalLink(FAGARAS, BUCHAREST, 211.0); |
| 63 | + map.addBidirectionalLink(PITESTI, BUCHAREST, 101.0); |
| 64 | + map.addBidirectionalLink(GIURGIU, BUCHAREST, 90.0); |
| 65 | + map.addBidirectionalLink(BUCHAREST, URZICENI, 85.0); |
| 66 | + map.addBidirectionalLink(NEAMT, IASI, 87.0); |
| 67 | + map.addBidirectionalLink(URZICENI, VASLUI, 142.0); |
| 68 | + map.addBidirectionalLink(URZICENI, HIRSOVA, 98.0); |
| 69 | + map.addBidirectionalLink(IASI, VASLUI, 92.0); |
| 70 | + // addBidirectionalLink(VASLUI - already all linked |
| 71 | + map.addBidirectionalLink(HIRSOVA, EFORIE, 86.0); |
| 72 | + // addBidirectionalLink(EFORIE - already all linked |
| 73 | + |
| 74 | + // distances and directions |
| 75 | + // reference location: Bucharest |
| 76 | + map.setDistAndDirToRefLocation(ARAD, 366, 117); |
| 77 | + map.setDistAndDirToRefLocation(BUCHAREST, 0, 360); |
| 78 | + map.setDistAndDirToRefLocation(CRAIOVA, 160, 74); |
| 79 | + map.setDistAndDirToRefLocation(DOBRETA, 242, 82); |
| 80 | + map.setDistAndDirToRefLocation(EFORIE, 161, 282); |
| 81 | + map.setDistAndDirToRefLocation(FAGARAS, 176, 142); |
| 82 | + map.setDistAndDirToRefLocation(GIURGIU, 77, 25); |
| 83 | + map.setDistAndDirToRefLocation(HIRSOVA, 151, 260); |
| 84 | + map.setDistAndDirToRefLocation(IASI, 226, 202); |
| 85 | + map.setDistAndDirToRefLocation(LUGOJ, 244, 102); |
| 86 | + map.setDistAndDirToRefLocation(MEHADIA, 241, 92); |
| 87 | + map.setDistAndDirToRefLocation(NEAMT, 234, 181); |
| 88 | + map.setDistAndDirToRefLocation(ORADEA, 380, 131); |
| 89 | + map.setDistAndDirToRefLocation(PITESTI, 100, 116); |
| 90 | + map.setDistAndDirToRefLocation(RIMNICU_VILCEA, 193, 115); |
| 91 | + map.setDistAndDirToRefLocation(SIBIU, 253, 123); |
| 92 | + map.setDistAndDirToRefLocation(TIMISOARA, 329, 105); |
| 93 | + map.setDistAndDirToRefLocation(URZICENI, 80, 247); |
| 94 | + map.setDistAndDirToRefLocation(VASLUI, 199, 222); |
| 95 | + map.setDistAndDirToRefLocation(ZERIND, 374, 125); |
| 96 | + } |
| 97 | +} |
0 commit comments