(svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ... noai
authortruelight
Tue, 24 Jul 2007 21:09:39 +0000
branchnoai
changeset 9691 1231d4e5f5aa
parent 9690 ac2ee072cebf
child 9692 7fbf759a6337
(svn r10679) [NoAI] -Add: added AIMarine, which takes care of Ships, Docks, ...
[NoAI] -Change [API Change]: renamed FindBestAircraftVehicle to FindBestAirVehicle for naming consistency
bin/ai/regression/regression.nut
bin/ai/regression/regression.txt
bin/ai/wrightai/main.nut
source.list
src/ai/ai_squirrel.cpp
src/ai/api/ai_marine.cpp
src/ai/api/ai_marine.hpp
src/ai/api/ai_marine.hpp.sq
src/ai/api/ai_vehicle.cpp
src/ai/api/ai_vehicle.hpp
src/ai/api/ai_vehicle.hpp.sq
--- a/bin/ai/regression/regression.nut	Tue Jul 24 20:52:36 2007 +0000
+++ b/bin/ai/regression/regression.nut	Tue Jul 24 21:09:39 2007 +0000
@@ -346,6 +346,49 @@
 	print("    DistanceFromEdge():  " + map.DistanceFromEdge(10000));
 }
 
+function Regression::Marine()
+{
+	local marine = AIMarine();
+	local company = AICompany();
+
+	print("");
+	print("--AIMarine--");
+
+	print("  IsWaterDepotTile():   " + marine.IsWaterDepotTile(32116));
+	print("  IsDockTile():         " + marine.IsDockTile(32116));
+	print("  IsBuoyTile():         " + marine.IsBuoyTile(32116));
+	print("  IsLockTile():         " + marine.IsLockTile(32116));
+	print("  IsCanalTile():        " + marine.IsCanalTile(32116));
+
+	print("  GetBankBalance():     " + company.GetBankBalance(AICompany.MY_COMPANY));
+	print("  BuildWaterDepot():    " + marine.BuildWaterDepot(28479, false));
+	print("  BuildDock():          " + marine.BuildDock(29253));
+	print("  BuildBuoy():          " + marine.BuildBuoy(28481));
+	print("  BuildLock():          " + marine.BuildLock(28487));
+	print("  BuildCanal():         " + marine.BuildCanal(32127));
+	print("  IsWaterDepotTile():   " + marine.IsWaterDepotTile(28479));
+	print("  IsDockTile():         " + marine.IsDockTile(29253));
+	print("  IsBuoyTile():         " + marine.IsBuoyTile(28481));
+	print("  IsLockTile():         " + marine.IsLockTile(28487));
+	print("  IsCanalTile():        " + marine.IsCanalTile(32127));
+	print("  GetBankBalance():     " + company.GetBankBalance(AICompany.MY_COMPANY));
+
+	print("  RemoveWaterDepot():   " + marine.RemoveWaterDepot(28479));
+	print("  RemoveDock():         " + marine.RemoveDock(29253));
+	print("  RemoveBuoy():         " + marine.RemoveBuoy(28481));
+	print("  RemoveLock():         " + marine.RemoveLock(28487));
+	print("  RemoveCanal():        " + marine.RemoveCanal(32127));
+	print("  IsWaterDepotTile():   " + marine.IsWaterDepotTile(28479));
+	print("  IsDockTile():         " + marine.IsDockTile(29253));
+	print("  IsBuoyTile():         " + marine.IsBuoyTile(28481));
+	print("  IsLockTile():         " + marine.IsLockTile(28487));
+	print("  IsCanalTile():        " + marine.IsCanalTile(32127));
+	print("  GetBankBalance():     " + company.GetBankBalance(AICompany.MY_COMPANY));
+
+	print("  BuildWaterDepot():    " + marine.BuildWaterDepot(28479, false));
+	print("  BuildDock():          " + marine.BuildDock(29253));
+}
+
 function Regression::Order()
 {
 	local order = AIOrder();
@@ -407,7 +450,7 @@
 		print("    " + i + " => " + list.GetValue(i));
 	}
 
-	list = AIStationVehicleList(1);
+	list = AIStationVehicleList(3);
 
 	print("");
 	print("--StationVehicleList--");
@@ -726,10 +769,16 @@
 		print("    Reliability 100:    " + vehicle.FindBestRoadVehicle(i, 100, 1000000));
 	}
 	for (local i = -1; i < 15; i++) {
-		print("  FindBestAircraftVehicle Cargo " + i);
-		print("    Reliability 0:      " + vehicle.FindBestAircraftVehicle(i, 0,   1000000));
-		print("    Reliability 50:     " + vehicle.FindBestAircraftVehicle(i, 50,  1000000));
-		print("    Reliability 100:    " + vehicle.FindBestAircraftVehicle(i, 100, 1000000));
+		print("  FindBestAirVehicle Cargo " + i);
+		print("    Reliability 0:      " + vehicle.FindBestAirVehicle(i, 0,   1000000));
+		print("    Reliability 50:     " + vehicle.FindBestAirVehicle(i, 50,  1000000));
+		print("    Reliability 100:    " + vehicle.FindBestAirVehicle(i, 100, 1000000));
+	}
+	for (local i = -1; i < 15; i++) {
+		print("  FindBestWaterVehicle Cargo " + i);
+		print("    Reliability 0:      " + vehicle.FindBestWaterVehicle(i, 0,   1000000));
+		print("    Reliability 50:     " + vehicle.FindBestWaterVehicle(i, 50,  1000000));
+		print("    Reliability 100:    " + vehicle.FindBestWaterVehicle(i, 100, 1000000));
 	}
 
 	local bank = company.GetBankBalance(AICompany.MY_COMPANY);
@@ -781,6 +830,10 @@
 
 	print("  BuildVehicle():       " + vehicle.BuildVehicle(32119, 219));
 	print("  IsValidVehicle(1026): " + vehicle.IsValidVehicle(1026));
+	print("  IsValidVehicle(1027): " + vehicle.IsValidVehicle(1027));
+
+	print("  BuildVehicle():       " + vehicle.BuildVehicle(28479, 204));
+	print("  IsValidVehicle(1028): " + vehicle.IsValidVehicle(1028));
 
 	local list = AIVehicleList();
 
@@ -840,6 +893,7 @@
 	this.TestInit();
 	this.Std();
 	this.Base();
+	this.List();
 	this.Airport();
 	this.Cargo();
 	this.Company();
@@ -847,7 +901,7 @@
 	this.Industry();
 	this.IndustryList();
 	this.Map();
-	this.List();
+	this.Marine();
 	this.PathFinder();
 	this.Road();
 	this.Sign();
--- a/bin/ai/regression/regression.txt	Tue Jul 24 20:52:36 2007 +0000
+++ b/bin/ai/regression/regression.txt	Tue Jul 24 21:09:39 2007 +0000
@@ -28,6 +28,255 @@
   Chance(1, 2): true
   Chance(1, 2): false
 
+--List--
+  IsEmpty():     true
+  Count():       101
+  HasItem(1050): false
+  HasItem(1051): true
+  IsEmpty():     false
+  List Dump:
+    1 => 1
+    2 => 2
+    1000 => 1000
+    1001 => 1001
+    1002 => 1002
+    1003 => 1003
+    1004 => 1004
+    1005 => 1005
+    1006 => 1006
+    1007 => 1007
+    1008 => 1008
+    1009 => 1009
+    1010 => 1010
+    1011 => 1011
+    1012 => 1012
+    1013 => 1013
+    1014 => 1014
+    1015 => 1015
+    1016 => 1016
+    1017 => 1017
+    1018 => 1018
+    1019 => 1019
+    1020 => 1020
+    1021 => 1021
+    1022 => 1022
+    1023 => 1023
+    1024 => 1024
+    1025 => 1025
+    1026 => 1026
+    1027 => 1027
+    1028 => 1028
+    1029 => 1029
+    1030 => 1030
+    1031 => 1031
+    1032 => 1032
+    1033 => 1033
+    1034 => 1034
+    1035 => 1035
+    1036 => 1036
+    1037 => 1037
+    1038 => 1038
+    1039 => 1039
+    1040 => 1040
+    1041 => 1041
+    1042 => 1042
+    1043 => 1043
+    1044 => 1044
+    1045 => 1045
+    1046 => 1046
+    1047 => 1047
+    1048 => 1048
+    1049 => 1049
+    1051 => 12
+    1052 => 1052
+    1053 => 1053
+    1054 => 1054
+    1055 => 1055
+    1056 => 1056
+    1057 => 1057
+    1058 => 1058
+    1059 => 1059
+    1060 => 1060
+    1061 => 1061
+    1062 => 1062
+    1063 => 1063
+    1064 => 1064
+    1065 => 1065
+    1066 => 1066
+    1067 => 1067
+    1068 => 1068
+    1069 => 1069
+    1070 => 1070
+    1071 => 1071
+    1072 => 1072
+    1073 => 1073
+    1074 => 1074
+    1075 => 1075
+    1076 => 1076
+    1077 => 1077
+    1078 => 1078
+    1079 => 1079
+    1080 => 1080
+    1081 => 1081
+    1082 => 1082
+    1083 => 1083
+    1084 => 1084
+    1085 => 1085
+    1086 => 1086
+    1087 => 1087
+    1088 => 1088
+    1089 => 1089
+    1090 => 1090
+    1091 => 1091
+    1092 => 1092
+    1093 => 1093
+    1094 => 1094
+    1095 => 1095
+    1096 => 1096
+    1097 => 1097
+    1098 => 1098
+    1099 => 1099
+  Randomize ListDump:
+    1 => 12862691
+    2 => -1917812707
+    1000 => 1421163554
+    1001 => -312664745
+    1002 => -2068922958
+    1003 => 1861130245
+    1004 => 1649688256
+    1005 => 15955316
+    1006 => 1355779470
+    1007 => 865353559
+    1008 => 803536462
+    1009 => -1712495000
+    1010 => -1505961326
+    1011 => -870330146
+    1012 => 126669570
+    1013 => -805020189
+    1014 => 793365509
+    1015 => 913987592
+    1016 => -720783506
+    1017 => 1926417138
+    1018 => -683369878
+    1019 => 446485522
+    1020 => 537800773
+    1021 => -615490971
+    1022 => 1776085247
+    1023 => -1869659646
+    1024 => 1353595954
+    1025 => 1880025847
+    1026 => 56594834
+    1027 => 1165500481
+    1028 => 1086094131
+    1029 => -263041456
+    1030 => 1130819676
+    1031 => 1868532194
+    1032 => 406052492
+    1033 => 529742212
+    1034 => 1549122406
+    1035 => 1528374594
+    1036 => -1586709059
+    1037 => -1866528486
+    1038 => -2123636907
+    1039 => 2060223021
+    1040 => -982427121
+    1041 => -99903420
+    1042 => 373385608
+    1043 => -1522828933
+    1044 => -1560504629
+    1045 => -2077599081
+    1046 => -782857017
+    1047 => 192681035
+    1048 => -642978559
+    1049 => 1723023122
+    1051 => 1181099329
+    1052 => -1581037797
+    1053 => -1856480328
+    1054 => -360359556
+    1055 => 2087072896
+    1056 => 1566859460
+    1057 => 490730845
+    1058 => -871118486
+    1059 => -1265136557
+    1060 => -1710287301
+    1061 => 624475954
+    1062 => 1448791554
+    1063 => -1448570564
+    1064 => -923161374
+    1065 => -1175940076
+    1066 => 1633634195
+    1067 => 474627780
+    1068 => -1754850936
+    1069 => -970278622
+    1070 => -1005842954
+    1071 => -1149168206
+    1072 => -1107909687
+    1073 => -1319038694
+    1074 => 1057817048
+    1075 => 410375978
+    1076 => 37823872
+    1077 => 2005120480
+    1078 => 2001195837
+    1079 => 2132885814
+    1080 => -809853417
+    1081 => -1575623843
+    1082 => -598915313
+    1083 => 620318589
+    1084 => -2127761983
+    1085 => -507862777
+    1086 => -245405898
+    1087 => -811840780
+    1088 => 571811265
+    1089 => 1695322056
+    1090 => 1956157477
+    1091 => -495557029
+    1092 => -1727000177
+    1093 => -1572068837
+    1094 => -1100027091
+    1095 => -677705398
+    1096 => 742793210
+    1097 => 431459282
+    1098 => -1694029724
+    1099 => 105515356
+  KeepTop(10):
+    1 => 12862691
+    2 => -1917812707
+    1000 => 1421163554
+    1001 => -312664745
+    1002 => -2068922958
+    1003 => 1861130245
+    1004 => 1649688256
+    1005 => 15955316
+    1006 => 1355779470
+    1007 => 865353559
+  KeepBottom(8):
+    1000 => 1421163554
+    1001 => -312664745
+    1002 => -2068922958
+    1003 => 1861130245
+    1004 => 1649688256
+    1005 => 15955316
+    1006 => 1355779470
+    1007 => 865353559
+  RemoveBottom(2):
+    1000 => 1421163554
+    1001 => -312664745
+    1002 => -2068922958
+    1003 => 1861130245
+    1004 => 1649688256
+    1005 => 15955316
+  RemoveTop(2):
+    1002 => -2068922958
+    1003 => 1861130245
+    1004 => 1649688256
+    1005 => 15955316
+  RemoveList({1003, 1004}):
+    1002 => -2068922958
+    1005 => 15955316
+  KeepList({1003, 1004, 1005}):
+    1005 => 15955316
+  IsEmpty():     true
+
 --AIAirport--
   IsHangarTile():       false
   IsAirportTile():      false
@@ -809,254 +1058,37 @@
     DistanceSquare():    1746
     DistanceFromEdge():  16
 
---List--
-  IsEmpty():     true
-  Count():       101
-  HasItem(1050): false
-  HasItem(1051): true
-  IsEmpty():     false
-  List Dump:
-    1 => 1
-    2 => 2
-    1000 => 1000
-    1001 => 1001
-    1002 => 1002
-    1003 => 1003
-    1004 => 1004
-    1005 => 1005
-    1006 => 1006
-    1007 => 1007
-    1008 => 1008
-    1009 => 1009
-    1010 => 1010
-    1011 => 1011
-    1012 => 1012
-    1013 => 1013
-    1014 => 1014
-    1015 => 1015
-    1016 => 1016
-    1017 => 1017
-    1018 => 1018
-    1019 => 1019
-    1020 => 1020
-    1021 => 1021
-    1022 => 1022
-    1023 => 1023
-    1024 => 1024
-    1025 => 1025
-    1026 => 1026
-    1027 => 1027
-    1028 => 1028
-    1029 => 1029
-    1030 => 1030
-    1031 => 1031
-    1032 => 1032
-    1033 => 1033
-    1034 => 1034
-    1035 => 1035
-    1036 => 1036
-    1037 => 1037
-    1038 => 1038
-    1039 => 1039
-    1040 => 1040
-    1041 => 1041
-    1042 => 1042
-    1043 => 1043
-    1044 => 1044
-    1045 => 1045
-    1046 => 1046
-    1047 => 1047
-    1048 => 1048
-    1049 => 1049
-    1051 => 12
-    1052 => 1052
-    1053 => 1053
-    1054 => 1054
-    1055 => 1055
-    1056 => 1056
-    1057 => 1057
-    1058 => 1058
-    1059 => 1059
-    1060 => 1060
-    1061 => 1061
-    1062 => 1062
-    1063 => 1063
-    1064 => 1064
-    1065 => 1065
-    1066 => 1066
-    1067 => 1067
-    1068 => 1068
-    1069 => 1069
-    1070 => 1070
-    1071 => 1071
-    1072 => 1072
-    1073 => 1073
-    1074 => 1074
-    1075 => 1075
-    1076 => 1076
-    1077 => 1077
-    1078 => 1078
-    1079 => 1079
-    1080 => 1080
-    1081 => 1081
-    1082 => 1082
-    1083 => 1083
-    1084 => 1084
-    1085 => 1085
-    1086 => 1086
-    1087 => 1087
-    1088 => 1088
-    1089 => 1089
-    1090 => 1090
-    1091 => 1091
-    1092 => 1092
-    1093 => 1093
-    1094 => 1094
-    1095 => 1095
-    1096 => 1096
-    1097 => 1097
-    1098 => 1098
-    1099 => 1099
-  Randomize ListDump:
-    1 => 1163947042
-    2 => -1513471425
-    1000 => 1562384206
-    1001 => 1833834195
-    1002 => -643703837
-    1003 => 79805044
-    1004 => -1946902569
-    1005 => -1363518126
-    1006 => 954256773
-    1007 => 72347912
-    1008 => 47883823
-    1009 => -526367464
-    1010 => 346325205
-    1011 => -291428903
-    1012 => -1188902385
-    1013 => -1562251412
-    1014 => -552815341
-    1015 => 603515522
-    1016 => 522991803
-    1017 => 1584966634
-    1018 => 259781126
-    1019 => -1798372027
-    1020 => -1290381010
-    1021 => -2118641661
-    1022 => 1981833351
-    1023 => 356860827
-    1024 => -748795736
-    1025 => 1281369326
-    1026 => 38829942
-    1027 => -962063214
-    1028 => 686566813
-    1029 => -463383379
-    1030 => -51377460
-    1031 => -1314021363
-    1032 => -22458076
-    1033 => -1689110622
-    1034 => 1917673188
-    1035 => -374359940
-    1036 => 814208703
-    1037 => -779698758
-    1038 => 26176155
-    1039 => 318789462
-    1040 => 1275414053
-    1041 => -1236954331
-    1042 => -857923735
-    1043 => 595999707
-    1044 => -1992427987
-    1045 => 306864841
-    1046 => 653337905
-    1047 => 1953580222
-    1048 => 1207858715
-    1049 => 408422240
-    1051 => 829258216
-    1052 => -1724902148
-    1053 => -1627854008
-    1054 => 1608232025
-    1055 => -1379999864
-    1056 => 1465015175
-    1057 => -717078999
-    1058 => 1397987245
-    1059 => 1761965383
-    1060 => -40513737
-    1061 => -877356160
-    1062 => 1039172583
-    1063 => -1108941798
-    1064 => 603116880
-    1065 => -580990468
-    1066 => -1456784483
-    1067 => -1440803259
-    1068 => 583917089
-    1069 => 1367075057
-    1070 => 1762142035
-    1071 => 748223299
-    1072 => -1749562785
-    1073 => -423135862
-    1074 => 250140274
-    1075 => 208016187
-    1076 => 799885915
-    1077 => -2135630100
-    1078 => -1446755021
-    1079 => -290921131
-    1080 => -1042816678
-    1081 => -1399388025
-    1082 => -1777598091
-    1083 => 1413196365
-    1084 => 920434787
-    1085 => 1131297890
-    1086 => -361269603
-    1087 => -1848914632
-    1088 => -896934400
-    1089 => -1133847065
-    1090 => -597619383
-    1091 => -1030970132
-    1092 => -1337968061
-    1093 => 1966368896
-    1094 => -2074278501
-    1095 => 1144440235
-    1096 => 1566334976
-    1097 => 1383194789
-    1098 => -230311246
-    1099 => -1462383584
-  KeepTop(10):
-    1 => 1163947042
-    2 => -1513471425
-    1000 => 1562384206
-    1001 => 1833834195
-    1002 => -643703837
-    1003 => 79805044
-    1004 => -1946902569
-    1005 => -1363518126
-    1006 => 954256773
-    1007 => 72347912
-  KeepBottom(8):
-    1000 => 1562384206
-    1001 => 1833834195
-    1002 => -643703837
-    1003 => 79805044
-    1004 => -1946902569
-    1005 => -1363518126
-    1006 => 954256773
-    1007 => 72347912
-  RemoveBottom(2):
-    1000 => 1562384206
-    1001 => 1833834195
-    1002 => -643703837
-    1003 => 79805044
-    1004 => -1946902569
-    1005 => -1363518126
-  RemoveTop(2):
-    1002 => -643703837
-    1003 => 79805044
-    1004 => -1946902569
-    1005 => -1363518126
-  RemoveList({1003, 1004}):
-    1002 => -643703837
-    1005 => -1363518126
-  KeepList({1003, 1004, 1005}):
-    1005 => -1363518126
-  IsEmpty():     true
+--AIMarine--
+  IsWaterDepotTile():   false
+  IsDockTile():         false
+  IsBuoyTile():         false
+  IsLockTile():         false
+  IsCanalTile():        false
+  GetBankBalance():     284108
+  BuildWaterDepot():    true
+  BuildDock():          true
+  BuildBuoy():          true
+  BuildLock():          true
+  BuildCanal():         true
+  IsWaterDepotTile():   true
+  IsDockTile():         true
+  IsBuoyTile():         true
+  IsLockTile():         true
+  IsCanalTile():        true
+  GetBankBalance():     254559
+  RemoveWaterDepot():   true
+  RemoveDock():         true
+  RemoveBuoy():         true
+  RemoveLock():         true
+  RemoveCanal():        true
+  IsWaterDepotTile():   false
+  IsDockTile():         false
+  IsBuoyTile():         false
+  IsLockTile():         false
+  IsCanalTile():        false
+  GetBankBalance():     231914
+  BuildWaterDepot():    true
+  BuildDock():          true
 
 --PathFinderStupid--
   FindRoute():  Route Array
@@ -1151,9 +1183,9 @@
 --Station--
   IsValidStation(0):        true
   IsValidStation(1000):     false
-  GetLocation(1):           33411
+  GetLocation(1):           29253
   GetLocation(1000):        -1
-  GetStationID(33411):      1
+  GetStationID(33411):      3
   GetStationID(34411):      65535
   GetCargoWaiting(0, 0):    0
   GetCargoWaiting(1000, 0): -1
@@ -1165,14 +1197,14 @@
 --StationList--
   Count():             2
   Location ListDump:
-    2 => 33421
-    1 => 33411
+    4 => 33421
+    3 => 33411
   CargoWaiting(0) ListDump:
-    2 => 0
-    1 => 0
+    4 => 0
+    3 => 0
   CargoWaiting(1) ListDump:
-    2 => 0
-    1 => 0
+    4 => 0
+    3 => 0
 
 --TileList--
   Count():             0
@@ -2268,67 +2300,131 @@
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo -1
-    Reliability 0:      65535
-    Reliability 50:     65535
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 0
-    Reliability 0:      216
-    Reliability 50:     216
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 1
+  FindBestAirVehicle Cargo -1
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 2
-    Reliability 0:      216
-    Reliability 50:     216
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 3
-    Reliability 0:      65535
-    Reliability 50:     65535
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 4
-    Reliability 0:      65535
-    Reliability 50:     65535
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 5
+  FindBestAirVehicle Cargo 0
     Reliability 0:      216
     Reliability 50:     216
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 6
-    Reliability 0:      65535
-    Reliability 50:     65535
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 7
-    Reliability 0:      65535
-    Reliability 50:     65535
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 8
-    Reliability 0:      65535
-    Reliability 50:     65535
-    Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 9
+  FindBestAirVehicle Cargo 1
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 10
+  FindBestAirVehicle Cargo 2
     Reliability 0:      216
     Reliability 50:     216
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 11
+  FindBestAirVehicle Cargo 3
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 12
+  FindBestAirVehicle Cargo 4
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 13
+  FindBestAirVehicle Cargo 5
+    Reliability 0:      216
+    Reliability 50:     216
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 6
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
-  FindBestAircraftVehicle Cargo 14
+  FindBestAirVehicle Cargo 7
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 8
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 9
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 10
+    Reliability 0:      216
+    Reliability 50:     216
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 11
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 12
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 13
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestAirVehicle Cargo 14
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo -1
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 0
+    Reliability 0:      206
+    Reliability 50:     206
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 1
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 2
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 3
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 4
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 5
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 6
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 7
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 8
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 9
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 10
+    Reliability 0:      204
+    Reliability 50:     204
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 11
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 12
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 13
+    Reliability 0:      65535
+    Reliability 50:     65535
+    Reliability 100:    65535
+  FindBestWaterVehicle Cargo 14
     Reliability 0:      65535
     Reliability 50:     65535
     Reliability 100:    65535
@@ -2354,51 +2450,63 @@
     GetLocation():       33417
     GetEngineType():     153
     GetUnitNumber():     1
-    GetAge():            0
+    GetAge():            1
     GetMaxAge():         5490
-    GetAgeLeft():        5490
+    GetAgeLeft():        5489
     GetProfitThisYear(): 0
     GetProfitLastYear(): 0
     GetVehicleType():    1
   BuildVehicle():       1026
   IsValidVehicle(1026): true
+  IsValidVehicle(1027): false
+  BuildVehicle():       1028
+  IsValidVehicle(1028): true
 
 --VehicleList--
-  Count():             3
+  Count():             4
   Location ListDump:
     1025 => 33417
     1024 => 33417
     1026 => 32119
+    1028 => 28479
   EngineType ListDump:
     1026 => 219
+    1028 => 204
     1025 => 153
     1024 => 153
   UnitNumber ListDump:
     1025 => 2
+    1028 => 1
     1026 => 1
     1024 => 1
   Age ListDump:
+    1024 => 1
+    1028 => 0
     1026 => 0
     1025 => 0
-    1024 => 0
   MaxAge ListDump:
+    1028 => 10980
     1026 => 10980
     1025 => 5490
     1024 => 5490
   AgeLeft ListDump:
+    1028 => 10980
     1026 => 10980
     1025 => 5490
-    1024 => 5490
+    1024 => 5489
   ProfitThisYear ListDump:
+    1028 => 0
     1026 => 0
     1025 => 0
     1024 => 0
   ProfitLastYear ListDump:
+    1028 => 0
     1026 => 0
     1025 => 0
     1024 => 0
   VehicleType ListDump:
     1026 => 3
+    1028 => 2
     1025 => 1
     1024 => 1
 
@@ -2425,23 +2533,23 @@
 --VehicleStationList--
   Count():             2
   Location ListDump:
-    2 => 33421
-    1 => 33411
+    4 => 33421
+    3 => 33411
   CargoWaiting(0) ListDump:
-    2 => 0
-    1 => 0
+    4 => 0
+    3 => 0
   CargoWaiting(1) ListDump:
-    2 => 0
-    1 => 0
+    4 => 0
+    3 => 0
   CargoRating(1) ListDump:
-    2 => 69
-    1 => 69
+    4 => 69
+    3 => 69
   DistanceManhattanToTile(30000) ListDump:
-    2 => 106
-    1 => 96
+    4 => 106
+    3 => 96
   DistanceSquareToTile(30000) ListDump:
-    2 => 8818
-    1 => 7058
+    4 => 8818
+    3 => 7058
 
 --StationVehicleList--
   Count():             1
--- a/bin/ai/wrightai/main.nut	Tue Jul 24 20:52:36 2007 +0000
+++ b/bin/ai/wrightai/main.nut	Tue Jul 24 21:09:39 2007 +0000
@@ -110,7 +110,7 @@
 	local hangar = this.airport.GetHangarOfAirport(tile_1);
 	/* When bank balance < 300000, buy cheaper planes */
 	local balance = this.company.GetBankBalance(AICompany.MY_COMPANY);
-	local engine = this.vehicle.FindBestAircraftVehicle(0, 0, (balance < 300000 ? 50000 : (balance < 1000000 ? 300000 : 1000000)));
+	local engine = this.vehicle.FindBestAirVehicle(0, 0, (balance < 300000 ? 50000 : (balance < 1000000 ? 300000 : 1000000)));
 	if (!this.vehicle.IsValidEngine(engine)) {
 		print(this.name + ": [ERROR] Couldn't find a suitable engine");
 		return -5;
--- a/source.list	Tue Jul 24 20:52:36 2007 +0000
+++ b/source.list	Tue Jul 24 21:09:39 2007 +0000
@@ -347,6 +347,7 @@
 ai/api/ai_list.hpp
 ai/api/ai_list_valuator.hpp
 ai/api/ai_map.hpp
+ai/api/ai_marine.hpp
 ai/api/ai_object.hpp
 ai/api/ai_order.hpp
 ai/api/ai_pathfinder.hpp
@@ -386,6 +387,7 @@
 ai/api/ai_list.cpp
 ai/api/ai_list_valuator.cpp
 ai/api/ai_map.cpp
+ai/api/ai_marine.cpp
 ai/api/ai_object.cpp
 ai/api/ai_order.cpp
 ai/api/ai_pathfinder_stupid.cpp
--- a/src/ai/ai_squirrel.cpp	Tue Jul 24 20:52:36 2007 +0000
+++ b/src/ai/ai_squirrel.cpp	Tue Jul 24 21:09:39 2007 +0000
@@ -37,6 +37,7 @@
 #include "api/ai_list.hpp.sq"
 #include "api/ai_list_valuator.hpp.sq"
 #include "api/ai_map.hpp.sq"
+#include "api/ai_marine.hpp.sq"
 #include "api/ai_order.hpp.sq"
 #include "api/ai_pathfinder.hpp.sq"
 #include "api/ai_pathfinder_stupid.hpp.sq"
@@ -230,6 +231,7 @@
 	SQAIListRandomizeRegister(this->engine);
 	SQAIListRegister(this->engine);
 	SQAIMapRegister(this->engine);
+	SQAIMarineRegister(this->engine);
 	SQAIOrderRegister(this->engine);
 	SQAIPathFinderRegister(this->engine);
 	SQAIPathFinderStupidRegister(this->engine);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_marine.cpp	Tue Jul 24 21:09:39 2007 +0000
@@ -0,0 +1,143 @@
+/* $Id$ */
+
+#include "ai_marine.hpp"
+#include "../../command.h"
+#include "../../variables.h"
+#include "../../station_map.h"
+#include "../../water_map.h"
+
+
+/* static */ bool AIMarine::IsWaterDepotTile(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_DEPOT;
+}
+
+/* static */ bool AIMarine::IsDockTile(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return ::IsTileType(tile, MP_STATION) && ::IsDock(tile);
+}
+
+/* static */ bool AIMarine::IsBuoyTile(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return ::IsTileType(tile, MP_STATION) && ::IsBuoy(tile);
+}
+
+/* static */ bool AIMarine::IsLockTile(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_LOCK;
+}
+
+/* static */ bool AIMarine::IsCanalTile(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return ::IsTileType(tile, MP_WATER) && ::IsCanal(tile);
+}
+
+bool AIMarine::BuildWaterDepot(TileIndex tile, bool vertical)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return this->DoCommand(tile, vertical, 0, CMD_BUILD_SHIP_DEPOT);
+}
+
+bool AIMarine::BuildDock(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return this->DoCommand(tile, 1, 0, CMD_BUILD_DOCK);
+}
+
+bool AIMarine::BuildBuoy(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_BUILD_BUOY);
+}
+
+bool AIMarine::BuildLock(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_BUILD_LOCK);
+}
+
+bool AIMarine::BuildCanal(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	return this->DoCommand(tile, tile, 0, CMD_BUILD_CANAL);
+}
+
+bool AIMarine::RemoveWaterDepot(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	/* Not a water depot tile */
+	if (!IsWaterDepotTile(tile)) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
+}
+
+bool AIMarine::RemoveDock(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	/* Not a dock tile */
+	if (!IsDockTile(tile)) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
+}
+
+bool AIMarine::RemoveBuoy(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	/* Not a buoy tile */
+	if (!IsBuoyTile(tile)) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
+}
+
+bool AIMarine::RemoveLock(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	/* Not a lock tile */
+	if (!IsLockTile(tile)) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
+}
+
+bool AIMarine::RemoveCanal(TileIndex tile)
+{
+	/* Outside of the map */
+	if (tile >= ::MapSize()) return false;
+
+	/* Not a canal tile */
+	if (!IsCanalTile(tile)) return false;
+
+	return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_marine.hpp	Tue Jul 24 21:09:39 2007 +0000
@@ -0,0 +1,142 @@
+/* $Id$ */
+
+/** @file ai_marine.hpp Everything to query and build marine */
+
+#ifndef AI_MARINE_HPP
+#define AI_MARINE_HPP
+
+#include "ai_object.hpp"
+
+/**
+ * Class that handles all marine related functions.
+ */
+class AIMarine : public AIObject {
+public:
+	/**
+	 * The name of the class, needed by several sub-processes.
+	 */
+	static const char *GetClassName() { return "AIMarine"; }
+
+	/**
+	 * Checks whether the given tile is actually a tile with a water depot.
+	 * @param tile the tile to check.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return true if and only if the tile has a water depot.
+	 */
+	static bool IsWaterDepotTile(TileIndex tile);
+
+	/**
+	 * Checks whether the given tile is actually a tile with a dock.
+	 * @param tile the tile to check.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return true if and only if the tile has a dock.
+	 */
+	static bool IsDockTile(TileIndex tile);
+
+	/**
+	 * Checks whether the given tile is actually a tile with a buoy.
+	 * @param tile the tile to check.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return true if and only if the tile has a buoy.
+	 */
+	static bool IsBuoyTile(TileIndex tile);
+
+	/**
+	 * Checks whether the given tile is actually a tile with a lock.
+	 * @param tile the tile to check.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return true if and only if the tile has a lock.
+	 */
+	static bool IsLockTile(TileIndex tile);
+
+	/**
+	 * Checks whether the given tile is actually a tile with a canal.
+	 * @param tile the tile to check.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return true if and only if the tile has a canal.
+	 */
+	static bool IsCanalTile(TileIndex tile);
+
+	/**
+	 * Builds a water depot on tile.
+	 * @param tile the tile where the water depot will be build.
+	 * @param vertical if true, depot will be vertical, else horizontal.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the water depot has been/can be build or not.
+	 */
+	bool BuildWaterDepot(TileIndex tile, bool vertical);
+
+	/**
+	 * Builds a dock where tile is the tile still on land.
+	 * @param tile the tile still on land of the dock.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the dock has been/can be build or not.
+	 */
+	bool BuildDock(TileIndex tile);
+
+	/**
+	 * Builds a buoy on tile.
+	 * @param tile the tile where the buoy will be build.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the buoy has been/can be build or not.
+	 */
+	bool BuildBuoy(TileIndex tile);
+
+	/**
+	 * Builds a lock on tile.
+	 * @param tile the tile where the lock will be build.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the lock has been/can be build or not.
+	 */
+	bool BuildLock(TileIndex tile);
+
+	/**
+	 * Builds a canal on tile.
+	 * @param tile the tile where the canal will be build.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the canal has been/can be build or not.
+	 */
+	bool BuildCanal(TileIndex tile);
+
+	/**
+	 * Removes a water depot.
+	 * @param tile any tile of the water depot.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the water depot has been/can be removed or not.
+	 */
+	bool RemoveWaterDepot(TileIndex tile);
+
+	/**
+	 * Removes a dock.
+	 * @param tile any tile of the dock.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the dock has been/can be removed or not.
+	 */
+	bool RemoveDock(TileIndex tile);
+
+	/**
+	 * Removes a buoy.
+	 * @param tile any tile of the buoy.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the buoy has been/can be removed or not.
+	 */
+	bool RemoveBuoy(TileIndex tile);
+
+	/**
+	 * Removes a lock.
+	 * @param tile any tile of the lock.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the lock has been/can be removed or not.
+	 */
+	bool RemoveLock(TileIndex tile);
+
+	/**
+	 * Removes a canal.
+	 * @param tile any tile of the canal.
+	 * @pre tile is always positive and smaller than AIMap::GetMapSize().
+	 * @return whether the canal has been/can be removed or not.
+	 */
+	bool RemoveCanal(TileIndex tile);
+};
+
+#endif /* AI_MARINE_HPP */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_marine.hpp.sq	Tue Jul 24 21:09:39 2007 +0000
@@ -0,0 +1,36 @@
+#include "ai_marine.hpp"
+
+namespace SQConvert {
+	/* Allow AIMarine to be used as Squirrel parameter */
+	template <> AIMarine *GetParam(ForceType<AIMarine *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIMarine *)instance; }
+	template <> AIMarine &GetParam(ForceType<AIMarine &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIMarine *)instance; }
+	template <> const AIMarine *GetParam(ForceType<const AIMarine *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIMarine *)instance; }
+	template <> const AIMarine &GetParam(ForceType<const AIMarine &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIMarine *)instance; }
+	template <> int Return<AIMarine *>(HSQUIRRELVM vm, AIMarine *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIMarine", res, NULL, DefSQDestructorCallback<AIMarine>); return 1; }
+}; // namespace SQConvert
+
+void SQAIMarineRegister(Squirrel *engine) {
+	DefSQClass <AIMarine> SQAIMarine("AIMarine");
+	SQAIMarine.PreRegister(engine);
+	SQAIMarine.AddConstructor<void (AIMarine::*)(), 1>(engine, "x");
+
+	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::GetClassName,     "GetClassName",     1, "x");
+	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsWaterDepotTile, "IsWaterDepotTile", 2, "xi");
+	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsDockTile,       "IsDockTile",       2, "xi");
+	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsBuoyTile,       "IsBuoyTile",       2, "xi");
+	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsLockTile,       "IsLockTile",       2, "xi");
+	SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsCanalTile,      "IsCanalTile",      2, "xi");
+
+	SQAIMarine.DefSQMethod(engine, &AIMarine::BuildWaterDepot,  "BuildWaterDepot",  3, "xib");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::BuildDock,        "BuildDock",        2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::BuildBuoy,        "BuildBuoy",        2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::BuildLock,        "BuildLock",        2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::BuildCanal,       "BuildCanal",       2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveWaterDepot, "RemoveWaterDepot", 2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveDock,       "RemoveDock",       2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveBuoy,       "RemoveBuoy",       2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveLock,       "RemoveLock",       2, "xi");
+	SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveCanal,      "RemoveCanal",      2, "xi");
+
+	SQAIMarine.PostRegister(engine);
+}
--- a/src/ai/api/ai_vehicle.cpp	Tue Jul 24 20:52:36 2007 +0000
+++ b/src/ai/api/ai_vehicle.cpp	Tue Jul 24 21:09:39 2007 +0000
@@ -89,11 +89,16 @@
 	return this->FindBestVehicle(cargo, min_reliability, VEHICLE_ROAD, max_cost);
 }
 
-EngineID AIVehicle::FindBestAircraftVehicle(CargoID cargo, uint8 min_reliability, uint max_cost)
+EngineID AIVehicle::FindBestAirVehicle(CargoID cargo, uint8 min_reliability, uint max_cost)
 {
 	return this->FindBestVehicle(cargo, min_reliability, VEHICLE_AIR, max_cost);
 }
 
+EngineID AIVehicle::FindBestWaterVehicle(CargoID cargo, uint8 min_reliability, uint max_cost)
+{
+	return this->FindBestVehicle(cargo, min_reliability, VEHICLE_WATER, max_cost);
+}
+
 VehicleID AIVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
 {
 	if (!this->IsValidEngine(engine_id)) return false;
--- a/src/ai/api/ai_vehicle.hpp	Tue Jul 24 20:52:36 2007 +0000
+++ b/src/ai/api/ai_vehicle.hpp	Tue Jul 24 21:09:39 2007 +0000
@@ -71,7 +71,21 @@
 	 *   when no engine was found given the cargo and reliability. Check the
 	 *   return value using IsValidEngine.
 	 */
-	EngineID FindBestAircraftVehicle(CargoID cargo, uint8 min_reliability, uint max_cost);
+	EngineID FindBestAirVehicle(CargoID cargo, uint8 min_reliability, uint max_cost);
+
+	/**
+	 * Find the best ship for this job, given a minimum reliability.
+	 * @param cargo           the cargo the vehicle has to transport.
+	 * @param min_reliability the minimum reliability of the vehicle,
+	 *   between 0 and 100.
+	 * @param max_cost        the maximum cost for the vehicle.
+	 * @pre AICargo::IsValidCargo(cargo).
+	 * @pre min_reliability is between 0 and 100.
+	 * @return the engine with the best characteristics, or an invalid engine
+	 *   when no engine was found given the cargo and reliability. Check the
+	 *   return value using IsValidEngine.
+	 */
+	EngineID FindBestWaterVehicle(CargoID cargo, uint8 min_reliability, uint max_cost);
 
 	/**
 	 * Builds a vehicle with the given engine at the given depot.
--- a/src/ai/api/ai_vehicle.hpp.sq	Tue Jul 24 20:52:36 2007 +0000
+++ b/src/ai/api/ai_vehicle.hpp.sq	Tue Jul 24 21:09:39 2007 +0000
@@ -37,15 +37,16 @@
 	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitLastYear, "GetProfitLastYear", 2, "xi");
 	SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetVehicleType,    "GetVehicleType",    2, "xi");
 
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::FindBestRoadVehicle,     "FindBestRoadVehicle",     4, "xiii");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::FindBestAircraftVehicle, "FindBestAircraftVehicle", 4, "xiii");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::BuildVehicle,            "BuildVehicle",            3, "xii");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::CloneVehicle,            "CloneVehicle",            4, "xiib");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::RefitVehicle,            "RefitVehicle",            3, "xii");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SellVehicle,             "SellVehicle",             2, "xi");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SendVehicleToDepot,      "SendVehicleToDepot",      2, "xi");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::StartStopVehicle,        "StartStopVehicle",        2, "xi");
-	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SkipVehicleOrder,        "SkipVehicleOrder",        2, "xi");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::FindBestRoadVehicle,  "FindBestRoadVehicle",  4, "xiii");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::FindBestAirVehicle,   "FindBestAirVehicle",   4, "xiii");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::FindBestWaterVehicle, "FindBestWaterVehicle", 4, "xiii");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::BuildVehicle,         "BuildVehicle",         3, "xii");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::CloneVehicle,         "CloneVehicle",         4, "xiib");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::RefitVehicle,         "RefitVehicle",         3, "xii");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SellVehicle,          "SellVehicle",          2, "xi");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SendVehicleToDepot,   "SendVehicleToDepot",   2, "xi");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::StartStopVehicle,     "StartStopVehicle",     2, "xi");
+	SQAIVehicle.DefSQMethod(engine, &AIVehicle::SkipVehicleOrder,     "SkipVehicleOrder",     2, "xi");
 
 	SQAIVehicle.PostRegister(engine);
 }