(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify noai
authortruelight
Sat, 14 Jul 2007 08:54:17 +0000
branchnoai
changeset 9655 e8e43f333832
parent 9654 b836eb5c521f
child 9656 ddb4260f3051
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
bin/ai/regression/regression.nut
bin/ai/regression/regression.txt
src/ai/ai_squirrel.cpp
src/ai/api/ai_industrylist_valuator.cpp
src/ai/api/ai_industrylist_valuator.hpp
src/ai/api/ai_industrylist_valuator.hpp.sq
src/ai/api/ai_map.cpp
src/ai/api/ai_map.hpp
src/ai/api/ai_map.hpp.sq
src/ai/api/ai_stationlist_valuator.cpp
src/ai/api/ai_stationlist_valuator.hpp
src/ai/api/ai_stationlist_valuator.hpp.sq
src/ai/api/ai_tilelist_valuator.cpp
src/ai/api/ai_tilelist_valuator.hpp
src/ai/api/ai_tilelist_valuator.hpp.sq
src/ai/api/ai_townlist_valuator.cpp
src/ai/api/ai_townlist_valuator.hpp
src/ai/api/ai_townlist_valuator.hpp.sq
--- a/bin/ai/regression/regression.nut	Fri Jul 13 23:18:12 2007 +0000
+++ b/bin/ai/regression/regression.nut	Sat Jul 14 08:54:17 2007 +0000
@@ -175,6 +175,16 @@
 	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
 		print("    " + i + " => " + list.GetValue(i));
 	}
+	list.Valuate(AIIndustryListDistanceManhattanToTile(30000));
+	print("  DistanceManhattanToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIIndustryListDistanceSquareToTile(30000));
+	print("  DistanceSquareToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
 	list.Valuate(AIIndustryListProduction(1));
 	list.KeepAboveValue(50);
 	print("  KeepAboveValue(50): done");
@@ -296,6 +306,16 @@
 	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
 		print("    " + i + " => " + list.GetValue(i));
 	}
+	list.Valuate(AIStationListDistanceManhattanToTile(30000));
+	print("  DistanceManhattanToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AIStationListDistanceSquareToTile(30000));
+	print("  DistanceSquareToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
 
 	list = AIStationVehicleList(1);
 
@@ -480,6 +500,17 @@
 	print("  KeepValue(1):        done");
 	print("  Count():             " + list.Count());
 
+	list.Valuate(AITileListDistanceManhattanToTile(30000));
+	print("  DistanceManhattanToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AITileListDistanceSquareToTile(30000));
+	print("  DistanceSquareToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+
 	list.Valuate(AITileListCargoAcceptance(0));
 	list.KeepAboveValue(10);
 	print("  CargoAcceptance():   done");
@@ -544,6 +575,16 @@
 	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
 		print("    " + i + " => " + list.GetValue(i));
 	}
+	list.Valuate(AITownListDistanceManhattanToTile(30000));
+	print("  DistanceManhattanToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
+	list.Valuate(AITownListDistanceSquareToTile(30000));
+	print("  DistanceSquareToTile(30000) ListDump:");
+	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
+		print("    " + i + " => " + list.GetValue(i));
+	}
 	list.Valuate(AITownListPopulation());
 	list.KeepAboveValue(500);
 	print("  KeepAboveValue(500): done");
--- a/bin/ai/regression/regression.txt	Fri Jul 13 23:18:12 2007 +0000
+++ b/bin/ai/regression/regression.txt	Sat Jul 14 08:54:17 2007 +0000
@@ -580,6 +580,146 @@
     29 => 6685
     6 => 6533
     33 => 5659
+  DistanceManhattanToTile(30000) ListDump:
+    59 => 287
+    46 => 279
+    42 => 266
+    61 => 258
+    12 => 254
+    40 => 243
+    66 => 238
+    16 => 238
+    45 => 236
+    0 => 232
+    48 => 217
+    9 => 215
+    10 => 214
+    64 => 213
+    51 => 201
+    2 => 199
+    28 => 193
+    43 => 190
+    5 => 184
+    58 => 183
+    15 => 179
+    7 => 179
+    6 => 177
+    21 => 175
+    54 => 173
+    39 => 171
+    8 => 168
+    37 => 157
+    68 => 156
+    56 => 152
+    20 => 150
+    50 => 147
+    65 => 146
+    19 => 144
+    27 => 139
+    11 => 139
+    17 => 138
+    31 => 135
+    22 => 135
+    4 => 124
+    32 => 121
+    33 => 116
+    60 => 115
+    29 => 110
+    26 => 109
+    18 => 107
+    3 => 105
+    55 => 102
+    52 => 102
+    53 => 101
+    34 => 98
+    41 => 94
+    49 => 86
+    13 => 85
+    35 => 84
+    57 => 83
+    38 => 78
+    25 => 77
+    1 => 77
+    24 => 72
+    23 => 72
+    63 => 71
+    44 => 66
+    14 => 54
+    30 => 50
+    67 => 40
+    62 => 33
+    36 => 31
+    47 => 24
+  DistanceSquareToTile(30000) ListDump:
+    59 => 42697
+    46 => 40121
+    0 => 38162
+    48 => 37157
+    61 => 36482
+    12 => 36130
+    42 => 35716
+    66 => 35284
+    40 => 35037
+    16 => 32740
+    51 => 31301
+    45 => 29530
+    21 => 29257
+    7 => 28661
+    64 => 26469
+    2 => 25525
+    28 => 25237
+    39 => 23733
+    43 => 23458
+    9 => 23293
+    10 => 23236
+    54 => 22777
+    37 => 20137
+    5 => 17026
+    58 => 16889
+    56 => 16754
+    8 => 16424
+    15 => 16061
+    22 => 15957
+    6 => 15689
+    27 => 13621
+    68 => 13226
+    50 => 13049
+    19 => 12818
+    20 => 11412
+    65 => 11236
+    60 => 10057
+    11 => 9673
+    17 => 9594
+    33 => 9466
+    31 => 9425
+    26 => 9061
+    29 => 8642
+    4 => 8570
+    18 => 7349
+    32 => 7321
+    41 => 7010
+    52 => 6354
+    49 => 6290
+    53 => 5941
+    34 => 5860
+    55 => 5714
+    3 => 5553
+    25 => 5077
+    35 => 4250
+    13 => 3925
+    1 => 3805
+    57 => 3485
+    38 => 3204
+    23 => 3042
+    24 => 2834
+    63 => 2521
+    44 => 2306
+    30 => 2132
+    14 => 1746
+    67 => 818
+    36 => 745
+    62 => 569
+    47 => 488
   KeepAboveValue(50): done
   Count():             7
   Production ListDump:
@@ -887,6 +1027,74 @@
   Buildable():         done
   KeepValue(1):        done
   Count():             33
+  DistanceManhattanToTile(30000) ListDump:
+    42415 => 175
+    42414 => 174
+    42159 => 174
+    42413 => 173
+    42158 => 173
+    41903 => 173
+    42157 => 172
+    41902 => 172
+    41647 => 172
+    42156 => 171
+    41901 => 171
+    41646 => 171
+    41391 => 171
+    42410 => 170
+    41900 => 170
+    41645 => 170
+    41390 => 170
+    42409 => 169
+    41899 => 169
+    41644 => 169
+    41389 => 169
+    42408 => 168
+    42153 => 168
+    41643 => 168
+    41388 => 168
+    42407 => 167
+    41897 => 167
+    41387 => 167
+    42151 => 166
+    41641 => 166
+    41895 => 165
+    41639 => 164
+    41383 => 163
+  DistanceSquareToTile(30000) ListDump:
+    42415 => 18433
+    42159 => 18338
+    41903 => 18245
+    42414 => 18180
+    41647 => 18154
+    42158 => 18085
+    41391 => 18065
+    41902 => 17992
+    42413 => 17929
+    41646 => 17901
+    42157 => 17834
+    41390 => 17812
+    41901 => 17741
+    41645 => 17650
+    42156 => 17585
+    41389 => 17561
+    41900 => 17492
+    41644 => 17401
+    41388 => 17312
+    41899 => 17245
+    42410 => 17188
+    41643 => 17154
+    41387 => 17065
+    42409 => 16945
+    42153 => 16850
+    41897 => 16757
+    42408 => 16704
+    41641 => 16666
+    42407 => 16465
+    42151 => 16370
+    41895 => 16277
+    41639 => 16186
+    41383 => 16097
   CargoAcceptance():   done
   KeepAboveValue(10):  done
   Count():             14
@@ -1124,6 +1332,64 @@
     19 => 6511
     10 => 6446
     9 => 5825
+  DistanceManhattanToTile(30000) ListDump:
+    23 => 297
+    5 => 272
+    9 => 240
+    4 => 230
+    27 => 225
+    22 => 216
+    16 => 195
+    21 => 194
+    12 => 190
+    1 => 176
+    3 => 165
+    7 => 164
+    2 => 164
+    17 => 163
+    0 => 157
+    19 => 155
+    13 => 155
+    24 => 133
+    14 => 133
+    18 => 106
+    8 => 102
+    15 => 98
+    11 => 98
+    10 => 94
+    26 => 70
+    25 => 54
+    6 => 40
+    20 => 38
+  DistanceSquareToTile(30000) ListDump:
+    23 => 46349
+    5 => 40034
+    4 => 36532
+    12 => 32500
+    27 => 30825
+    9 => 30050
+    2 => 24698
+    22 => 24386
+    16 => 23525
+    17 => 20129
+    21 => 19396
+    1 => 16546
+    3 => 16277
+    7 => 15496
+    0 => 13249
+    19 => 12433
+    13 => 12025
+    24 => 10145
+    14 => 9389
+    10 => 8468
+    8 => 7250
+    18 => 6676
+    11 => 5002
+    15 => 4804
+    25 => 2810
+    26 => 2458
+    6 => 1088
+    20 => 922
   KeepAboveValue(500): done
   Count():             11
   Population ListDump:
@@ -1888,6 +2154,12 @@
   CargoRating(1) ListDump:
     2 => 69
     1 => 69
+  DistanceManhattanToTile(30000) ListDump:
+    2 => 106
+    1 => 96
+  DistanceSquareToTile(30000) ListDump:
+    2 => 8818
+    1 => 7058
 
 --StationVehicleList--
   Count():             1
--- a/src/ai/ai_squirrel.cpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/ai_squirrel.cpp	Sat Jul 14 08:54:17 2007 +0000
@@ -214,6 +214,8 @@
 	SQAICompanyRegister(this->engine);
 	SQAIControllerRegister(this->engine);
 	SQAIExecModeRegister(this->engine);
+	SQAIIndustryListDistanceManhattanToTileRegister(this->engine);
+	SQAIIndustryListDistanceSquareToTileRegister(this->engine);
 	SQAIIndustryListLocationRegister(this->engine);
 	SQAIIndustryListProductionRegister(this->engine);
 	SQAIIndustryListRegister(this->engine);
@@ -228,6 +230,8 @@
 	SQAISignRegister(this->engine);
 	SQAIStationListCargoRatingRegister(this->engine);
 	SQAIStationListCargoWaitingRegister(this->engine);
+	SQAIStationListDistanceManhattanToTileRegister(this->engine);
+	SQAIStationListDistanceSquareToTileRegister(this->engine);
 	SQAIStationListLocationRegister(this->engine);
 	SQAIStationListRegister(this->engine);
 	SQAIStationRegister(this->engine);
@@ -235,11 +239,15 @@
 	SQAITestModeRegister(this->engine);
 	SQAITileListBuildableRegister(this->engine);
 	SQAITileListCargoAcceptanceRegister(this->engine);
+	SQAITileListDistanceManhattanToTileRegister(this->engine);
+	SQAITileListDistanceSquareToTileRegister(this->engine);
 	SQAITileListNeighbourRoadCountRegister(this->engine);
 	SQAITileListRegister(this->engine);
 	SQAITileListRoadTileRegister(this->engine);
 	SQAITileListSlopeRegister(this->engine);
 	SQAITileRegister(this->engine);
+	SQAITownListDistanceManhattanToTileRegister(this->engine);
+	SQAITownListDistanceSquareToTileRegister(this->engine);
 	SQAITownListLocationRegister(this->engine);
 	SQAITownListPopulationRegister(this->engine);
 	SQAITownListRegister(this->engine);
--- a/src/ai/api/ai_industrylist_valuator.cpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_industrylist_valuator.cpp	Sat Jul 14 08:54:17 2007 +0000
@@ -1,5 +1,6 @@
 #include "ai_industrylist_valuator.hpp"
 #include "ai_industry.hpp"
+#include "ai_map.hpp"
 
 int32 AIIndustryListProduction::Valuate(int32 industry) const
 {
@@ -10,3 +11,13 @@
 {
 	return AIIndustry::GetLocation(industry);
 }
+
+int32 AIIndustryListDistanceManhattanToTile::Valuate(int32 industry) const
+{
+	return AIMap::DistanceManhattan(this->tile, AIIndustry::GetLocation(industry));
+}
+
+int32 AIIndustryListDistanceSquareToTile::Valuate(int32 industry) const
+{
+	return AIMap::DistanceSquare(this->tile, AIIndustry::GetLocation(industry));
+}
--- a/src/ai/api/ai_industrylist_valuator.hpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_industrylist_valuator.hpp	Sat Jul 14 08:54:17 2007 +0000
@@ -46,4 +46,50 @@
 	int32 Valuate(int32 industry) const;
 };
 
+/**
+ * Get the manhattan distance to a tile for entries in an AIIndustryList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type TileIndex
+ */
+class AIIndustryListDistanceManhattanToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AIIndustryListDistanceManhattanToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AIIndustryListDistanceManhattanToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
+/**
+ * Get the sqsuare distance to a tile for entries in an AIIndustryList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type TileIndex
+ */
+class AIIndustryListDistanceSquareToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AIIndustryListDistanceSquareToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AIIndustryListDistanceSquareToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
 #endif /* AI_INDUSTRYLIST_VALUATOR_HPP */
--- a/src/ai/api/ai_industrylist_valuator.hpp.sq	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_industrylist_valuator.hpp.sq	Sat Jul 14 08:54:17 2007 +0000
@@ -35,3 +35,39 @@
 
 	SQAIIndustryListLocation.PostRegister(engine);
 }
+
+namespace SQConvert {
+	/* Allow AIIndustryListDistanceManhattanToTile to be used as Squirrel parameter */
+	template <> AIIndustryListDistanceManhattanToTile *GetParam(ForceType<AIIndustryListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIIndustryListDistanceManhattanToTile *)instance; }
+	template <> AIIndustryListDistanceManhattanToTile &GetParam(ForceType<AIIndustryListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIIndustryListDistanceManhattanToTile *)instance; }
+	template <> const AIIndustryListDistanceManhattanToTile *GetParam(ForceType<const AIIndustryListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIIndustryListDistanceManhattanToTile *)instance; }
+	template <> const AIIndustryListDistanceManhattanToTile &GetParam(ForceType<const AIIndustryListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIIndustryListDistanceManhattanToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAIIndustryListDistanceManhattanToTileRegister(Squirrel *engine) {
+	DefSQClass <AIIndustryListDistanceManhattanToTile> SQAIIndustryListDistanceManhattanToTile("AIIndustryListDistanceManhattanToTile");
+	SQAIIndustryListDistanceManhattanToTile.PreRegister(engine);
+	SQAIIndustryListDistanceManhattanToTile.AddConstructor<void (AIIndustryListDistanceManhattanToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAIIndustryListDistanceManhattanToTile.DefSQStaticMethod(engine, &AIIndustryListDistanceManhattanToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAIIndustryListDistanceManhattanToTile.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIIndustryListDistanceSquareToTile to be used as Squirrel parameter */
+	template <> AIIndustryListDistanceSquareToTile *GetParam(ForceType<AIIndustryListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIIndustryListDistanceSquareToTile *)instance; }
+	template <> AIIndustryListDistanceSquareToTile &GetParam(ForceType<AIIndustryListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIIndustryListDistanceSquareToTile *)instance; }
+	template <> const AIIndustryListDistanceSquareToTile *GetParam(ForceType<const AIIndustryListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIIndustryListDistanceSquareToTile *)instance; }
+	template <> const AIIndustryListDistanceSquareToTile &GetParam(ForceType<const AIIndustryListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIIndustryListDistanceSquareToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAIIndustryListDistanceSquareToTileRegister(Squirrel *engine) {
+	DefSQClass <AIIndustryListDistanceSquareToTile> SQAIIndustryListDistanceSquareToTile("AIIndustryListDistanceSquareToTile");
+	SQAIIndustryListDistanceSquareToTile.PreRegister(engine);
+	SQAIIndustryListDistanceSquareToTile.AddConstructor<void (AIIndustryListDistanceSquareToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAIIndustryListDistanceSquareToTile.DefSQStaticMethod(engine, &AIIndustryListDistanceSquareToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAIIndustryListDistanceSquareToTile.PostRegister(engine);
+}
--- a/src/ai/api/ai_map.cpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_map.cpp	Sat Jul 14 08:54:17 2007 +0000
@@ -5,57 +5,57 @@
 #include "ai_map.hpp"
 #include "../../command.h"
 
-bool AIMap::IsValidTile(TileIndex t)
+/* static */ bool AIMap::IsValidTile(TileIndex t)
 {
-	return t < this->GetMapSize();
+	return t < AIMap::GetMapSize();
 }
 
-TileIndex AIMap::GetMapSize()
+/* static */ TileIndex AIMap::GetMapSize()
 {
 	return ::MapSize();
 }
 
-uint32 AIMap::GetMapSizeX()
+/* static */ uint32 AIMap::GetMapSizeX()
 {
 	return ::MapSizeX();
 }
 
-uint32 AIMap::GetMapSizeY()
+/* static */ uint32 AIMap::GetMapSizeY()
 {
 	return ::MapSizeY();
 }
 
-uint32 AIMap::GetTileX(TileIndex t)
+/* static */ uint32 AIMap::GetTileX(TileIndex t)
 {
 	return ::TileX(t);
 }
 
-uint32 AIMap::GetTileY(TileIndex t)
+/* static */ uint32 AIMap::GetTileY(TileIndex t)
 {
 	return ::TileY(t);
 }
 
-TileIndex AIMap::GetTileIndex(uint32 x, uint32 y)
+/* static */ TileIndex AIMap::GetTileIndex(uint32 x, uint32 y)
 {
 	return ::TileXY(x, y);
 }
 
-uint32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2)
+/* static */ uint32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2)
 {
 	return ::DistanceManhattan(t1, t2);
 }
 
-uint32 AIMap::DistanceMax(TileIndex t1, TileIndex t2)
+/* static */ uint32 AIMap::DistanceMax(TileIndex t1, TileIndex t2)
 {
 	return ::DistanceMax(t1, t2);
 }
 
-uint32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2)
+/* static */ uint32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2)
 {
 	return ::DistanceSquare(t1, t2);
 }
 
-uint32 AIMap::DistanceFromEdge(TileIndex t)
+/* static */ uint32 AIMap::DistanceFromEdge(TileIndex t)
 {
 	return ::DistanceFromEdge(t);
 }
--- a/src/ai/api/ai_map.hpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_map.hpp	Sat Jul 14 08:54:17 2007 +0000
@@ -22,28 +22,28 @@
 	 * @param t the tile to check.
 	 * @return true is the tile it within the boundaries of the map.
 	 */
-	bool IsValidTile(TileIndex t);
+	static bool IsValidTile(TileIndex t);
 
 	/**
 	 * Gets the number of tiles in the map.
 	 * @return the size of the map in tiles.
 	 * @post return value is always positive.
 	 */
-	TileIndex GetMapSize();
+	static TileIndex GetMapSize();
 
 	/**
 	 * Gets the amount of tiles along the SW and NE border.
 	 * @return the length along the SW and NE borders.
 	 * @post return value is always positive.
 	 */
-	uint32 GetMapSizeX();
+	static uint32 GetMapSizeX();
 
 	/**
 	 * Gets the amount of tiles along the SE and NW border.
 	 * @return the length along the SE and NW borders.
 	 * @post return value is always positive.
 	 */
-	uint32 GetMapSizeY();
+	static uint32 GetMapSizeY();
 
 	/**
 	 * Gets the place along the SW/NE border (X-value).
@@ -52,7 +52,7 @@
 	 * @return the X-value.
 	 * @post return value is lower than GetMapSizeX().
 	 */
-	uint32 GetTileX(TileIndex t);
+	static uint32 GetTileX(TileIndex t);
 
 	/**
 	 * Gets the place along the SE/NW border (Y-value).
@@ -61,7 +61,7 @@
 	 * @return the Y-value.
 	 * @post return value is lower than GetMapSizeY().
 	 */
-	uint32 GetTileY(TileIndex t);
+	static uint32 GetTileY(TileIndex t);
 
 	/**
 	 * Gets the TileIndex given a x,y-coordinate.
@@ -71,7 +71,7 @@
 	 * @pre y has to be lower than GetMapSizeY().
 	 * @return the TileIndex for the given x,y coordinate.
 	 */
-	TileIndex GetTileIndex(uint32 x, uint32 y);
+	static TileIndex GetTileIndex(uint32 x, uint32 y);
 
 	/**
 	 * Calculates the Manhattan distance; the difference of
@@ -82,7 +82,7 @@
 	 * @pre t2 has to be valid (use IsValidTile(t2)).
 	 * @return the Manhattan distance.
 	 */
-	uint32 DistanceManhattan(TileIndex t1, TileIndex t2);
+	static uint32 DistanceManhattan(TileIndex t1, TileIndex t2);
 
 	/**
 	 * Calculates the distance between xy1 and xy2 via 1D calculation.
@@ -94,7 +94,7 @@
 	 * @pre t2 has to be valid (use IsValidTile(t2)).
 	 * @return the maximum distance of X and Y.
 	 */
-	uint32 DistanceMax(TileIndex t1, TileIndex t2);
+	static uint32 DistanceMax(TileIndex t1, TileIndex t2);
 
 	/**
 	 * The squared distance between the two tiles.
@@ -106,7 +106,7 @@
 	 * @pre t2 has to be valid (use IsValidTile(t2)).
 	 * @return the distance.
 	 */
-	uint32 DistanceSquare(TileIndex t1, TileIndex t2);
+	static uint32 DistanceSquare(TileIndex t1, TileIndex t2);
 
 	/**
 	 * Calculates the shortest distance to the edge.
@@ -114,7 +114,7 @@
 	 * @pre t has to be valid (use IsValidTile(t)).
 	 * @return the distances to the closest edge.
 	 */
-	uint32 DistanceFromEdge(TileIndex t);
+	static uint32 DistanceFromEdge(TileIndex t);
 
 	/**
 	 * Destroy everything on the given tile.
--- a/src/ai/api/ai_map.hpp.sq	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_map.hpp.sq	Sat Jul 14 08:54:17 2007 +0000
@@ -13,20 +13,20 @@
 	SQAIMap.PreRegister(engine);
 	SQAIMap.AddConstructor<void (AIMap::*)(), 1>(engine, "x");
 
-	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetClassName, "GetClassName", 1, "x");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetClassName,      "GetClassName",      1, "x");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::IsValidTile,       "IsValidTile",       2, "xi");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetMapSize,        "GetMapSize",        1, "x");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetMapSizeX,       "GetMapSizeX",       1, "x");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetMapSizeY,       "GetMapSizeY",       1, "x");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetTileX,          "GetTileX",          2, "xi");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetTileY,          "GetTileY",          2, "xi");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::GetTileIndex,      "GetTileIndex",      3, "xii");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceManhattan, "DistanceManhattan", 3, "xii");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceMax,       "DistanceMax",       3, "xii");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceSquare,    "DistanceSquare",    3, "xii");
+	SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceFromEdge,  "DistanceFromEdge",  2, "xi");
 
-	SQAIMap.DefSQMethod(engine, &AIMap::IsValidTile,       "IsValidTile",       2, "xi");
-	SQAIMap.DefSQMethod(engine, &AIMap::GetMapSize,        "GetMapSize",        1, "x");
-	SQAIMap.DefSQMethod(engine, &AIMap::GetMapSizeX,       "GetMapSizeX",       1, "x");
-	SQAIMap.DefSQMethod(engine, &AIMap::GetMapSizeY,       "GetMapSizeY",       1, "x");
-	SQAIMap.DefSQMethod(engine, &AIMap::GetTileX,          "GetTileX",          2, "xi");
-	SQAIMap.DefSQMethod(engine, &AIMap::GetTileY,          "GetTileY",          2, "xi");
-	SQAIMap.DefSQMethod(engine, &AIMap::GetTileIndex,      "GetTileIndex",      3, "xii");
-	SQAIMap.DefSQMethod(engine, &AIMap::DistanceManhattan, "DistanceManhattan", 3, "xii");
-	SQAIMap.DefSQMethod(engine, &AIMap::DistanceMax,       "DistanceMax",       3, "xii");
-	SQAIMap.DefSQMethod(engine, &AIMap::DistanceSquare,    "DistanceSquare",    3, "xii");
-	SQAIMap.DefSQMethod(engine, &AIMap::DistanceFromEdge,  "DistanceFromEdge",  2, "xi");
-	SQAIMap.DefSQMethod(engine, &AIMap::DemolishTile,      "DemolishTile",      2, "xi");
+	SQAIMap.DefSQMethod(engine, &AIMap::DemolishTile, "DemolishTile", 2, "xi");
 
 	SQAIMap.PostRegister(engine);
 }
--- a/src/ai/api/ai_stationlist_valuator.cpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_stationlist_valuator.cpp	Sat Jul 14 08:54:17 2007 +0000
@@ -2,6 +2,7 @@
 
 #include "ai_stationlist_valuator.hpp"
 #include "ai_station.hpp"
+#include "ai_map.hpp"
 
 int32 AIStationListLocation::Valuate(int32 station) const
 {
@@ -17,3 +18,13 @@
 {
 	return AIStation::GetCargoRating(station, this->cargo_type);
 }
+
+int32 AIStationListDistanceManhattanToTile::Valuate(int32 station) const
+{
+	return AIMap::DistanceManhattan(this->tile, AIStation::GetLocation(station));
+}
+
+int32 AIStationListDistanceSquareToTile::Valuate(int32 station) const
+{
+	return AIMap::DistanceSquare(this->tile, AIStation::GetLocation(station));
+}
--- a/src/ai/api/ai_stationlist_valuator.hpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_stationlist_valuator.hpp	Sat Jul 14 08:54:17 2007 +0000
@@ -69,4 +69,50 @@
 	int32 Valuate(int32 station) const;
 };
 
+/**
+ * Get the manhattan distance to a tile for entries in an AIStationList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type StationID
+ */
+class AIStationListDistanceManhattanToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AIStationListDistanceManhattanToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AIStationListDistanceManhattanToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
+/**
+ * Get the sqsuare distance to a tile for entries in an AIStationList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type StationID
+ */
+class AIStationListDistanceSquareToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AIStationListDistanceSquareToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AIStationListDistanceSquareToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
 #endif /* AI_STATIONLIST_VALUATOR_HPP */
--- a/src/ai/api/ai_stationlist_valuator.hpp.sq	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_stationlist_valuator.hpp.sq	Sat Jul 14 08:54:17 2007 +0000
@@ -53,3 +53,39 @@
 
 	SQAIStationListCargoRating.PostRegister(engine);
 }
+
+namespace SQConvert {
+	/* Allow AIStationListDistanceManhattanToTile to be used as Squirrel parameter */
+	template <> AIStationListDistanceManhattanToTile *GetParam(ForceType<AIStationListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIStationListDistanceManhattanToTile *)instance; }
+	template <> AIStationListDistanceManhattanToTile &GetParam(ForceType<AIStationListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIStationListDistanceManhattanToTile *)instance; }
+	template <> const AIStationListDistanceManhattanToTile *GetParam(ForceType<const AIStationListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIStationListDistanceManhattanToTile *)instance; }
+	template <> const AIStationListDistanceManhattanToTile &GetParam(ForceType<const AIStationListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIStationListDistanceManhattanToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAIStationListDistanceManhattanToTileRegister(Squirrel *engine) {
+	DefSQClass <AIStationListDistanceManhattanToTile> SQAIStationListDistanceManhattanToTile("AIStationListDistanceManhattanToTile");
+	SQAIStationListDistanceManhattanToTile.PreRegister(engine);
+	SQAIStationListDistanceManhattanToTile.AddConstructor<void (AIStationListDistanceManhattanToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAIStationListDistanceManhattanToTile.DefSQStaticMethod(engine, &AIStationListDistanceManhattanToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAIStationListDistanceManhattanToTile.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIStationListDistanceSquareToTile to be used as Squirrel parameter */
+	template <> AIStationListDistanceSquareToTile *GetParam(ForceType<AIStationListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIStationListDistanceSquareToTile *)instance; }
+	template <> AIStationListDistanceSquareToTile &GetParam(ForceType<AIStationListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIStationListDistanceSquareToTile *)instance; }
+	template <> const AIStationListDistanceSquareToTile *GetParam(ForceType<const AIStationListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIStationListDistanceSquareToTile *)instance; }
+	template <> const AIStationListDistanceSquareToTile &GetParam(ForceType<const AIStationListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIStationListDistanceSquareToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAIStationListDistanceSquareToTileRegister(Squirrel *engine) {
+	DefSQClass <AIStationListDistanceSquareToTile> SQAIStationListDistanceSquareToTile("AIStationListDistanceSquareToTile");
+	SQAIStationListDistanceSquareToTile.PreRegister(engine);
+	SQAIStationListDistanceSquareToTile.AddConstructor<void (AIStationListDistanceSquareToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAIStationListDistanceSquareToTile.DefSQStaticMethod(engine, &AIStationListDistanceSquareToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAIStationListDistanceSquareToTile.PostRegister(engine);
+}
--- a/src/ai/api/ai_tilelist_valuator.cpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_tilelist_valuator.cpp	Sat Jul 14 08:54:17 2007 +0000
@@ -1,6 +1,7 @@
 #include "ai_tilelist_valuator.hpp"
 #include "ai_tile.hpp"
 #include "ai_road.hpp"
+#include "ai_map.hpp"
 #include "../../tile.h"
 #include "../../road_map.h"
 
@@ -28,3 +29,13 @@
 {
 	return AITile::GetCargoAcceptance(tile, this->cargo_type);
 }
+
+int32 AITileListDistanceManhattanToTile::Valuate(int32 tile) const
+{
+	return AIMap::DistanceManhattan(this->tile, tile);
+}
+
+int32 AITileListDistanceSquareToTile::Valuate(int32 tile) const
+{
+	return AIMap::DistanceSquare(this->tile, tile);
+}
--- a/src/ai/api/ai_tilelist_valuator.hpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_tilelist_valuator.hpp	Sat Jul 14 08:54:17 2007 +0000
@@ -98,4 +98,51 @@
 	int32 Valuate(int32 tile) const;
 };
 
+/**
+ * Get the manhattan distance to a tile for entries in an AITileList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type TileIndex
+ */
+class AITileListDistanceManhattanToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AITileListDistanceManhattanToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AITileListDistanceManhattanToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
+/**
+ * Get the sqsuare distance to a tile for entries in an AITileList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type TileIndex
+ */
+class AITileListDistanceSquareToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AITileListDistanceSquareToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AITileListDistanceSquareToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
+
 #endif /* AI_TILELIST_VALUATOR_HPP */
--- a/src/ai/api/ai_tilelist_valuator.hpp.sq	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_tilelist_valuator.hpp.sq	Sat Jul 14 08:54:17 2007 +0000
@@ -89,3 +89,39 @@
 
 	SQAITileListCargoAcceptance.PostRegister(engine);
 }
+
+namespace SQConvert {
+	/* Allow AITileListDistanceManhattanToTile to be used as Squirrel parameter */
+	template <> AITileListDistanceManhattanToTile *GetParam(ForceType<AITileListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITileListDistanceManhattanToTile *)instance; }
+	template <> AITileListDistanceManhattanToTile &GetParam(ForceType<AITileListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileListDistanceManhattanToTile *)instance; }
+	template <> const AITileListDistanceManhattanToTile *GetParam(ForceType<const AITileListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITileListDistanceManhattanToTile *)instance; }
+	template <> const AITileListDistanceManhattanToTile &GetParam(ForceType<const AITileListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileListDistanceManhattanToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAITileListDistanceManhattanToTileRegister(Squirrel *engine) {
+	DefSQClass <AITileListDistanceManhattanToTile> SQAITileListDistanceManhattanToTile("AITileListDistanceManhattanToTile");
+	SQAITileListDistanceManhattanToTile.PreRegister(engine);
+	SQAITileListDistanceManhattanToTile.AddConstructor<void (AITileListDistanceManhattanToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAITileListDistanceManhattanToTile.DefSQStaticMethod(engine, &AITileListDistanceManhattanToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAITileListDistanceManhattanToTile.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AITileListDistanceSquareToTile to be used as Squirrel parameter */
+	template <> AITileListDistanceSquareToTile *GetParam(ForceType<AITileListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITileListDistanceSquareToTile *)instance; }
+	template <> AITileListDistanceSquareToTile &GetParam(ForceType<AITileListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileListDistanceSquareToTile *)instance; }
+	template <> const AITileListDistanceSquareToTile *GetParam(ForceType<const AITileListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITileListDistanceSquareToTile *)instance; }
+	template <> const AITileListDistanceSquareToTile &GetParam(ForceType<const AITileListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITileListDistanceSquareToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAITileListDistanceSquareToTileRegister(Squirrel *engine) {
+	DefSQClass <AITileListDistanceSquareToTile> SQAITileListDistanceSquareToTile("AITileListDistanceSquareToTile");
+	SQAITileListDistanceSquareToTile.PreRegister(engine);
+	SQAITileListDistanceSquareToTile.AddConstructor<void (AITileListDistanceSquareToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAITileListDistanceSquareToTile.DefSQStaticMethod(engine, &AITileListDistanceSquareToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAITileListDistanceSquareToTile.PostRegister(engine);
+}
--- a/src/ai/api/ai_townlist_valuator.cpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_townlist_valuator.cpp	Sat Jul 14 08:54:17 2007 +0000
@@ -1,5 +1,6 @@
 #include "ai_townlist_valuator.hpp"
 #include "ai_town.hpp"
+#include "ai_map.hpp"
 
 int32 AITownListPopulation::Valuate(int32 town) const
 {
@@ -10,3 +11,13 @@
 {
 	return AITown::GetLocation(town);
 }
+
+int32 AITownListDistanceManhattanToTile::Valuate(int32 town) const
+{
+	return AIMap::DistanceManhattan(this->tile, AITown::GetLocation(town));
+}
+
+int32 AITownListDistanceSquareToTile::Valuate(int32 town) const
+{
+	return AIMap::DistanceSquare(this->tile, AITown::GetLocation(town));
+}
--- a/src/ai/api/ai_townlist_valuator.hpp	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_townlist_valuator.hpp	Sat Jul 14 08:54:17 2007 +0000
@@ -39,4 +39,50 @@
 	int32 Valuate(int32 town) const;
 };
 
+/**
+ * Get the manhattan distance to a tile for entries in an AITownList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type TownID
+ */
+class AITownListDistanceManhattanToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AITownListDistanceManhattanToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AITownListDistanceManhattanToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
+/**
+ * Get the sqsuare distance to a tile for entries in an AITownList instance.
+ * @note resulting items are of the type distance
+ * @note the input items are of the type TownID
+ */
+class AITownListDistanceSquareToTile : public AIAbstractList::Valuator {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AITownListDistanceSquareToTile"; }
+
+	/**
+	 * Custom constructor, we want a tile as parameter.
+	 */
+	AITownListDistanceSquareToTile(TileIndex tile) { this->tile = tile; }
+
+private:
+	TileIndex tile;
+
+	int32 Valuate(int32 station) const;
+};
+
 #endif /* AI_TOWNLIST_VALUATOR_HPP */
--- a/src/ai/api/ai_townlist_valuator.hpp.sq	Fri Jul 13 23:18:12 2007 +0000
+++ b/src/ai/api/ai_townlist_valuator.hpp.sq	Sat Jul 14 08:54:17 2007 +0000
@@ -35,3 +35,39 @@
 
 	SQAITownListLocation.PostRegister(engine);
 }
+
+namespace SQConvert {
+	/* Allow AITownListDistanceManhattanToTile to be used as Squirrel parameter */
+	template <> AITownListDistanceManhattanToTile *GetParam(ForceType<AITownListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITownListDistanceManhattanToTile *)instance; }
+	template <> AITownListDistanceManhattanToTile &GetParam(ForceType<AITownListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITownListDistanceManhattanToTile *)instance; }
+	template <> const AITownListDistanceManhattanToTile *GetParam(ForceType<const AITownListDistanceManhattanToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITownListDistanceManhattanToTile *)instance; }
+	template <> const AITownListDistanceManhattanToTile &GetParam(ForceType<const AITownListDistanceManhattanToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITownListDistanceManhattanToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAITownListDistanceManhattanToTileRegister(Squirrel *engine) {
+	DefSQClass <AITownListDistanceManhattanToTile> SQAITownListDistanceManhattanToTile("AITownListDistanceManhattanToTile");
+	SQAITownListDistanceManhattanToTile.PreRegister(engine);
+	SQAITownListDistanceManhattanToTile.AddConstructor<void (AITownListDistanceManhattanToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAITownListDistanceManhattanToTile.DefSQStaticMethod(engine, &AITownListDistanceManhattanToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAITownListDistanceManhattanToTile.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AITownListDistanceSquareToTile to be used as Squirrel parameter */
+	template <> AITownListDistanceSquareToTile *GetParam(ForceType<AITownListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITownListDistanceSquareToTile *)instance; }
+	template <> AITownListDistanceSquareToTile &GetParam(ForceType<AITownListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITownListDistanceSquareToTile *)instance; }
+	template <> const AITownListDistanceSquareToTile *GetParam(ForceType<const AITownListDistanceSquareToTile *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AITownListDistanceSquareToTile *)instance; }
+	template <> const AITownListDistanceSquareToTile &GetParam(ForceType<const AITownListDistanceSquareToTile &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AITownListDistanceSquareToTile *)instance; }
+}; // namespace SQConvert
+
+void SQAITownListDistanceSquareToTileRegister(Squirrel *engine) {
+	DefSQClass <AITownListDistanceSquareToTile> SQAITownListDistanceSquareToTile("AITownListDistanceSquareToTile");
+	SQAITownListDistanceSquareToTile.PreRegister(engine);
+	SQAITownListDistanceSquareToTile.AddConstructor<void (AITownListDistanceSquareToTile::*)(TileIndex tile), 2>(engine, "xi");
+
+	SQAITownListDistanceSquareToTile.DefSQStaticMethod(engine, &AITownListDistanceSquareToTile::GetClassName, "GetClassName", 1, "x");
+
+	SQAITownListDistanceSquareToTile.PostRegister(engine);
+}