Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
/** * Build an airport route. Find 2 cities that are big enough and try to build airport in both cities. * Then we can build an aircraft and make some money. */ function WrightAI::BuildAirportRoute() { /* Check if we can build more aircraft. */ if (GetAircraftCount() >= AIGameSettings.GetValue("max_aircraft") || AIGameSettings.IsDisabledVehicleType(AIVehicle.VT_AIR)) return 0; /* Create a list of available airports */ local airportTypes = AIList(); airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_INTERCON), AIAirport.AT_INTERCON); // 7 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_INTERNATIONAL), AIAirport.AT_INTERNATIONAL); // 4 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_METROPOLITAN), AIAirport.AT_METROPOLITAN); // 3 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_LARGE), AIAirport.AT_LARGE); // 1 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_COMMUTER), AIAirport.AT_COMMUTER); // 5 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_SMALL), AIAirport.AT_SMALL); // 0 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_HELISTATION), AIAirport.AT_HELISTATION); // 8 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_HELIDEPOT), AIAirport.AT_HELIDEPOT); // 6 airportTypes.AddItem(AIAirport.GetPrice(AIAirport.AT_HELIPORT), AIAirport.AT_HELIPORT); // 2 /* Filter out airports larger than the maximum value of a station size */ local list = airportTypes; local station_spread = AIGameSettings.GetValue("station_spread"); for (local i = list.Begin(); list.HasNext(); i = list.Next()) { local airport_type = airportTypes.GetValue(i); // AILog.Info("airport_type = " + airport_type); local airport_x = AIAirport.GetAirportWidth(airport_type); // AILog.Info("airport_x = " + airport_x); local airport_y = AIAirport.GetAirportHeight(airport_type); // AILog.Info("airport_y = " + airport_y); if (airport_x > station_spread || airport_y > station_spread) { airportTypes.RemoveValue(airport_type); } /* Also filter out unavailable airports */ if (!AIAirport.IsValidAirportType(airport_type)) { airportTypes.RemoveValue(airport_type); } // /* Filter out heliports while helistations and helidepots aren't available, because it is required that one of the airports in a route to have a hangar */ // if (airport_type == AIAirport.AT_HELIPORT && !AIAirport.IsValidAirportType(AIAirport.AT_HELISTATION) && !AIAirport.IsValidAirportType(AIAirport.AT_HELIDEPOT)) { // airportTypes.RemoveValue(airport_type); // } } /* No airports available. Abort */ if (airportTypes.Count() == 0) return 0; local available_engines = false; local engine_costs = 0; if (big_engine_list.Count() == 0) { // airportTypes.RemoveValue(AIAirport.AT_INTERCON); // airportTypes.RemoveValue(AIAirport.AT_INTERNATIONAL); // airportTypes.RemoveValue(AIAirport.AT_METROPOLITAN); // airportTypes.RemoveValue(AIAirport.AT_LARGE); } else { available_engines = true; engine_costs = engine_costs + AIEngine.GetPrice(big_engine_list.Begin()); } if (small_engine_list.Count() == 0) { // airportTypes.RemoveValue(AIAirport.AT_COMMUTER); // airportTypes.RemoveValue(AIAirport.AT_SMALL); } else { available_engines = true; engine_costs = engine_costs + AIEngine.GetPrice(small_engine_list.Begin()); } if (helicopter_list.Count() == 0) { airportTypes.RemoveValue(AIAirport.AT_HELISTATION); airportTypes.RemoveValue(AIAirport.AT_HELIDEPOT); airportTypes.RemoveValue(AIAirport.AT_HELIPORT); } else { available_engines = true; engine_costs = engine_costs + AIEngine.GetPrice(helicopter_list.Begin()); } /* There are no engines available */ if (!available_engines) return 0; /* Not enough money */ local estimated_costs = airportTypes.Begin() + engine_costs; if (!this.HasMoney(estimated_costs + 25000)) return 0; // AILog.Info("airportTypes contains " + airportTypes.Count() + " type " + airportTypes.GetValue(0)); airportTypes.Sort(AIList.SORT_BY_ITEM, AIList.SORT_DESCENDING); /* Ensure there are at least 2 unused towns */ local town_list = AITownList(); if (AIController.GetSetting("cities_only")) { town_list.Valuate(AITown.IsCity); town_list.KeepValue(1); } if (town_list.Count() - this.towns_used.Count() < 2) return 0; AILog.Info("Trying to build an airport route..."); local tile_1 = this.FindSuitableAirportSpot(airportTypes, 0, false, false, false); local airport1_location = tile_1[0]; local airport1_type = tile_1[1]; local airport1_stationId = tile_1[5]; if (airport1_location < 0) { AILog.Info("Couldn't find a suitable town to build the first airport in"); return -1; } if (airport1_type == AIAirport.AT_HELIPORT) { airportTypes.RemoveValue(AIAirport.AT_HELIPORT); airportTypes.Sort(AIList.SORT_BY_ITEM, AIList.SORT_ASCENDING); } local large_aircraft = tile_1[2]; local small_aircraft = tile_1[3]; local helicopter = tile_1[4]; local tile_2 = this.FindSuitableAirportSpot(airportTypes, airport1_location, large_aircraft, small_aircraft, helicopter); local airport2_location = tile_2[0]; local airport2_type = tile_2[1]; local airport2_stationId = tile_2[5]; if (airport2_location < 0) { AILog.Info("Couldn't find a suitable town to build the second airport in"); return -1; } /* Build the airports for real */ // local last_cost.AIAccounting(); local tap = TestBuildAirport(); if (!tap.TryBuild(airport1_location, airport1_type, airport1_stationId)) { // // local last_cost = AIAccounting(); // if (AITestMode() && AIAirport.BuildAirport(airport1_location, airport1_type, airport1_stationId)) { // if (HasMoney(last_cost.GetCosts())) GetMoney(last_cost.GetCosts()); // } // if (!AIAirport.BuildAirport(airport1_location, airport1_type, airport1_stationId)) { // RepayLoan(); AILog.Warning("Although the testing told us we could build 2 airports, it still failed on the first airport at tile " + airport1_location + "."); // assert(AIError.GetLastError() != AIError.ERR_STATION_TOO_SPREAD_OUT); return -1; } // RepayLoan(); // // last_cost.ResetCosts(); tap = TestBuildAirport(); if (!tap.TryBuild(airport2_location, airport2_type, airport2_stationId)) { // // if (AITestMode() && AIAirport.BuildAirport(airport2_location, airport2_type, airport2_stationId)) { // if (HasMoney(last_cost.GetCosts())) GetMoney(last_cost.GetCosts()); // } // if (!AIAirport.BuildAirport(airport2_location, airport2_type, airport2_stationId)) { // RepayLoan(); AILog.Warning("Although the testing told us we could build 2 airports, it still failed on the second airport at tile " + airport2_location + "."); // assert(AIError.GetLastError() != AIError.ERR_STATION_TOO_SPREAD_OUT); return -1; } // RepayLoan(); local ret = this.BuildAircraft(airport1_location, airport2_location, false, GetAircraftCount() == 0 ? true : false); if (ret < 0) { return ret; } local airport1_town = AITile.GetClosestTown(airport1_location); local airport2_town = AITile.GetClosestTown(airport2_location); this.towns_used.AddItem(airport1_town, airport1_location); this.towns_used.AddItem(airport2_town, airport2_location); // AILog.Warning("Done building aicraft route."); return ret; }
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever