bin/ai/wrightai/main.nut
author rubidium
Thu, 22 Nov 2007 23:00:00 +0000
branchnoai
changeset 9720 2b1f99d52a7b
parent 9691 1231d4e5f5aa
child 9738 53baf447bae8
permissions -rw-r--r--
(svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     1
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     2
class WrightAI extends AIController {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     3
	airport = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     4
	company = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     5
	map = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     6
	order = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     7
	station = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     8
	vehicle = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
     9
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    10
	name = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    11
	towns_used = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    12
	route_1 = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    13
	route_2 = null;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    14
	distance_of_route = {};
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    15
	vehicle_to_depot = {};
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    16
	delay_build_airport_route = 1000;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    17
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    18
	function Start();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    19
	function Stop();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    20
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    21
	constructor() {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    22
		this.airport = AIAirport();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    23
		this.company = AICompany();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    24
		this.map = AIMap();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    25
		this.order = AIOrder();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    26
		this.station = AIStation();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    27
		this.vehicle = AIVehicle();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    28
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    29
		this.towns_used = AIList();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    30
		this.route_1 = AIList();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    31
		this.route_2 = AIList();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    32
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    33
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    34
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    35
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    36
 * Check if we have enough money (via loan and on bank).
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    37
 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    38
function WrightAI::HasMoney(money)
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    39
{
9668
6fe3d2cb9655 (svn r10582) [NoAI] -Codechange: allow getting the president and company names of other companies as well as their company value and bank balance.
rubidium
parents: 9667
diff changeset
    40
	if (this.company.GetBankBalance(AICompany.MY_COMPANY) + (this.company.GetMaxLoanAmount() - this.company.GetLoanAmount()) > money) return true;
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    41
	return false;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    42
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    43
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    44
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    45
 * Get the amount of money requested, loan if needed.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    46
 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    47
function WrightAI::GetMoney(money)
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    48
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    49
	if (!this.HasMoney(money)) return;
9668
6fe3d2cb9655 (svn r10582) [NoAI] -Codechange: allow getting the president and company names of other companies as well as their company value and bank balance.
rubidium
parents: 9667
diff changeset
    50
	if (this.company.GetBankBalance(AICompany.MY_COMPANY) > money) return;
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    51
9668
6fe3d2cb9655 (svn r10582) [NoAI] -Codechange: allow getting the president and company names of other companies as well as their company value and bank balance.
rubidium
parents: 9667
diff changeset
    52
	local loan = money - this.company.GetBankBalance(AICompany.MY_COMPANY) + this.company.GetLoanInterval() + this.company.GetLoanAmount();
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    53
	loan = loan - loan % this.company.GetLoanInterval();
9682
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
    54
	print(this.name + ": [INFO] Need a loan to get " + money + ": " + loan);
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    55
	this.company.SetLoanAmount(loan);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    56
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    57
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    58
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    59
 * Build an airport route. Find 2 cities that are big enough and try to build airport in both cities.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    60
 *  Then we can build an aircraft and make some money.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    61
 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    62
function WrightAI::BuildAirportRoute()
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    63
{
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    64
	local airport_type = (AIAirport.AiportAvailable(AIAirport.AT_SMALL) ? AIAirport.AT_SMALL : AIAirport.AT_LARGE);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    65
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    66
	/* Get enough money to work with */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    67
	this.GetMoney(150000);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    68
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    69
	print(this.name + ": [INFO] Trying to build an airport route");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    70
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    71
	local tile_1 = this.FindSuitableAirportSpot(airport_type, 0);
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    72
	if (tile_1 < 0) return -1;
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    73
	local tile_2 = this.FindSuitableAirportSpot(airport_type, tile_1);
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    74
	/* XXX -- If tile_2 isn't found, tile_1 town is added to used list, but never really used */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    75
	if (tile_2 < 0) return -2;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    76
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    77
	/* Build the airports for real */
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    78
	if (!this.airport.BuildAirport(tile_1, airport_type)) {
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    79
		print(this.name + ": [ERROR] Although the testing told us we could build 2 airports, it still failed on the first airport at tile " + tile_1 + ".");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    80
		/* XXX -- We should free the towns again for an other day */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    81
		return -3;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    82
	}
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    83
	if (!this.airport.BuildAirport(tile_2, airport_type)) {
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    84
		print(this.name + ": [ERROR] Although the testing told us we could build 2 airports, it still failed on the second airport at tile " + tile_2 + ".");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    85
		this.airport.RemoveAirport(tile_1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    86
		/* XXX -- We should free the towns again for an other day */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    87
		return -4;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    88
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    89
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    90
	local ret = this.BuildAircraft(tile_1, tile_2);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    91
	if (ret < 0) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    92
		this.airport.RemoveAirport(tile_1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    93
		this.airport.RemoveAirport(tile_2);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    94
		/* XXX -- We should free the towns again for an other day */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    95
		return ret;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    96
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    97
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    98
	print(this.name + ": [INFO] Done building a route");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    99
	return ret;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   100
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   101
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   102
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   103
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   104
 * Build an aircraft with orders from tile_1 to tile_2.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   105
 *  The best available aircraft of that time will be bought.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   106
 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   107
function WrightAI::BuildAircraft(tile_1, tile_2)
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   108
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   109
	/* Build an aircraft */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   110
	local hangar = this.airport.GetHangarOfAirport(tile_1);
9720
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   111
	local engine = null;
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   112
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   113
	local engine_list = AIEngineList(AIVehicle.VEHICLE_AIR);
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   114
9672
18c71ca987e4 (svn r10611) [NoAI] -Fix: improved FindBestXXX, it now finds the fastest, biggest vehicle available
truelight
parents: 9671
diff changeset
   115
	/* When bank balance < 300000, buy cheaper planes */
18c71ca987e4 (svn r10611) [NoAI] -Fix: improved FindBestXXX, it now finds the fastest, biggest vehicle available
truelight
parents: 9671
diff changeset
   116
	local balance = this.company.GetBankBalance(AICompany.MY_COMPANY);
9720
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   117
	engine_list.Valuate(AIEngineListPrice());
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   118
	engine_list.KeepBelowValue(balance < 300000 ? 50000 : (balance < 1000000 ? 300000 : 1000000));
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   119
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   120
	engine_list.Valuate(AIEngineListCargoType())
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   121
	engine_list.KeepValue(0); // passengers
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   122
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   123
	engine_list.Valuate(AIEngineListCapacity())
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   124
	engine_list.KeepTop(1);
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   125
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   126
	engine = engine_list.Begin();
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   127
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   128
	if (!AIEngine.IsValidEngine(engine)) {
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   129
		print(this.name + ": [ERROR] Couldn't find a suitable engine");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   130
		return -5;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   131
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   132
	local vehicle = this.vehicle.BuildVehicle(hangar, engine);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   133
	if (!this.vehicle.IsValidVehicle(vehicle)) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   134
		print(this.name + ": [ERROR] Couldn't build the aircraft");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   135
		return -6;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   136
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   137
	/* Send him on his way */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   138
	this.order.AppendOrder(vehicle, tile_1, AIOrder.AIOF_NONE);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   139
	this.order.AppendOrder(vehicle, tile_2, AIOrder.AIOF_NONE);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   140
	this.vehicle.StartStopVehicle(vehicle);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   141
	this.distance_of_route.rawset(vehicle, AIMap.DistanceManhattan(tile_1, tile_2));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   142
	this.route_1.AddItem(vehicle, tile_1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   143
	this.route_2.AddItem(vehicle, tile_2);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   144
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   145
	print(this.name + ": [INFO] Done building an aircraft");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   146
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   147
	return 0;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   148
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   149
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   150
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   151
 * Find a suitable spot for an airport, walking all towns hoping to find one.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   152
 *  When a town is used, it is marked as such and not re-used.
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   153
 */
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   154
function WrightAI::FindSuitableAirportSpot(airport_type, center_tile)
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   155
{
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   156
	local airport_x, airport_y, airport_rad;
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   157
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   158
	airport_x = AIAirport.GetAirportWidth(airport_type);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   159
	airport_y = AIAirport.GetAirportHeight(airport_type);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   160
	airport_rad = AIAirport.GetAirportCoverageRadius(airport_type);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   161
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   162
	local town_list = AITownList();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   163
	/* Remove all the towns we already used */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   164
	town_list.RemoveList(this.towns_used);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   165
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   166
	town_list.Valuate(AITownListPopulation());
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   167
	town_list.KeepAboveValue(500);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   168
	/* Keep the best 10, if we can't find 2 stations in there, just leave it anyway */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   169
	town_list.KeepTop(10);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   170
	town_list.Valuate(AIListRandomize());
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   171
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   172
	/* Now find 2 suitable towns */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   173
	for (local town = town_list.Begin(); town_list.HasNext(); town = town_list.Next()) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   174
		/* Don't make this a CPU hog */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   175
		Sleep(1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   176
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   177
		local tile = AITown.GetLocation(town);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   178
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   179
		/* Create a 30x30 grid around the core of the town and see if we can find a spot for a small airport */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   180
		local list = AITileList();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   181
		/* XXX -- We assume we are more than 15 tiles away from the border! */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   182
		list.AddRectangle(tile - this.map.GetTileIndex(15, 15), tile + this.map.GetTileIndex(15, 15));
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   183
		list.Valuate(AITileListBuildableRectangle(airport_x, airport_y));
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   184
		list.KeepValue(1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   185
		if (center_tile != 0) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   186
			/* If we have a tile defined, we don't want to be within 25 tiles of this tile */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   187
			list.Valuate(AITileListDistanceSquareToTile(center_tile));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   188
			list.KeepAboveValue(625);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   189
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   190
		/* Sort on acceptance, remove places that don't have acceptance */
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   191
		list.Valuate(AITileListCargoAcceptance(0, airport_x, airport_y, airport_rad));
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   192
		list.RemoveBelowValue(10);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   193
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   194
		/* Couldn't find a suitable place for this town, skip to the next */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   195
		if (list.Count() == 0) continue;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   196
		/* Walk all the tiles and see if we can build the airport at all */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   197
		{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   198
			local test = AITestMode();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   199
			local good_tile = 0;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   200
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   201
			for (tile = list.Begin(); list.HasNext(); tile = list.Next()) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   202
				Sleep(1);
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   203
				if (!this.airport.BuildAirport(tile, airport_type)) continue;
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   204
				good_tile = tile;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   205
				break;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   206
			}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   207
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   208
			/* Did we found a place to build the airport on? */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   209
			if (good_tile == 0) continue;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   210
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   211
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   212
		print(this.name + ": [INFO] Found a good spot for an airport in town " + town + " at tile " + tile);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   213
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   214
		/* Make the town as used, so we don't use it again */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   215
		this.towns_used.AddItem(town, tile);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   216
		return tile;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   217
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   218
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   219
	print(this.name + ": [INFO] Couldn't find a suitable town to build an airport in");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   220
	return -1;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   221
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   222
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   223
function WrightAI::ManageAirRoutes()
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   224
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   225
	local list = AIVehicleList();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   226
	list.Valuate(AIVehicleListAge());
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   227
	/* Give the plane at least 2 years to make a difference */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   228
	list.KeepAboveValue(365 * 2);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   229
	list.Valuate(AIVehicleListProfitLastYear());
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   230
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   231
	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   232
		local profit = list.GetValue(i);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   233
		/* Profit last year and this year bad? Let's sell the vehicle */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   234
		if (profit < 10000 && this.vehicle.GetProfitThisYear(i) < 10000) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   235
			/* Send the vehicle to depot if we didn't do so yet */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   236
			if (!this.vehicle_to_depot.rawin(i) || this.vehicle_to_depot.rawget(i) != true) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   237
				print(this.name + ": [INFO] Sending " + i + " to depot as profit is: " + profit + " / " + this.vehicle.GetProfitThisYear(i));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   238
				this.vehicle.SendVehicleToDepot(i);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   239
				this.vehicle_to_depot.rawset(i, true);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   240
			}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   241
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   242
		/* Try to sell it over and over till it really is in the depot */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   243
		if (this.vehicle_to_depot.rawin(i) && this.vehicle_to_depot.rawget(i) == true) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   244
			if (this.vehicle.SellVehicle(i)) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   245
				print(this.name + ": [INFO] Selling " + i + " as it finally is in a depot.");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   246
				/* Check if we are the last one serving those airports; else sell the airports */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   247
				local list2 = AIStationVehicleList(this.station.GetStationID(this.route_1.GetValue(i)));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   248
				if (list2.Count() == 0) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   249
					/* Remove the airports */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   250
					print(this.name + ": [INFO] Removing airports as nobody serves them anymore.");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   251
					this.airport.RemoveAirport(this.route_1.GetValue(i));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   252
					this.airport.RemoveAirport(this.route_2.GetValue(i));
9682
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   253
					this.route_1.RemoveItem(i);
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   254
					this.route_2.RemoveItem(i);
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   255
					/* XXX -- We should free the towns_used entries too */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   256
				}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   257
				this.vehicle_to_depot.rawdelete(i);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   258
			}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   259
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   260
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   261
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   262
	/* Don't try to add planes when we are short on cash */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   263
	if (!this.HasMoney(50000)) return;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   264
9671
ad29df0de918 (svn r10610) [NoAI] -Fix r10609: typo in WrightAI
truelight
parents: 9670
diff changeset
   265
	list = AIStationList(AIStation.STATION_AIRPORT);
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   266
	list.Valuate(AIStationListCargoWaiting(0));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   267
	list.KeepAboveValue(250);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   268
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   269
	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   270
		local list2 = AIStationVehicleList(i);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   271
		/* No vehicles going to this station, abort */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   272
		/* TODO -- Sell station */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   273
		if (list2.Count() == 0) continue;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   274
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   275
		/* Find the first vehicle that is going to this station */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   276
		local v = list2.Begin();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   277
		local dist = this.distance_of_route.rawget(v);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   278
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   279
		list2.Valuate(AIVehicleListAge());
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   280
		list2.KeepBelowValue(dist);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   281
		/* Do not build a new vehicle if we bought a new one in the last DISTANCE days */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   282
		if (list2.Count() != 0) continue;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   283
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   284
		print(this.name + ": [INFO] Station " + i + " (" + this.station.GetLocation(i) + ") has too many cargo, adding a new vehicle for the route.");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   285
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   286
		/* Make sure we have enough money */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   287
		this.GetMoney(50000);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   288
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   289
		return this.BuildAircraft(this.route_1.GetValue(v), this.route_2.GetValue(v));
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   290
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   291
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   292
9682
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   293
function WrightAI::HandleEvents()
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   294
{
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   295
	while (AIEventController.IsEventWaiting()) {
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   296
		local e = AIEventController.GetNextEvent();
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   297
		switch (e.GetEventType()) {
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   298
			case AIEvent.AI_ET_CRASHED_VEHICLE:
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   299
				local ec = AIEventVehicleCrash.Convert(e);
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   300
				local v = ec.GetVehicleID();
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   301
				print(this.name + ": [INFO] We have a crashed vehicle (" + v + "), buying a new one as replacement");
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   302
				this.BuildAircraft(this.route_1.GetValue(v), this.route_2.GetValue(v));
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   303
				this.route_1.RemoveItem(v);
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   304
				this.route_2.RemoveItem(v);
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   305
				break;
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   306
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   307
			default:
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   308
				break;
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   309
		}
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   310
	}
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   311
}
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   312
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   313
function WrightAI::Start()
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   314
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   315
	/* Sleep 1 tick, as we can't execute anything in tick 0 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   316
	Sleep(1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   317
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   318
	/* Give the boy a name */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   319
	if (!this.company.SetCompanyName("WrightAI")) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   320
		local i = 2;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   321
		while (!this.company.SetCompanyName("WrightAI #" + i)) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   322
			i++;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   323
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   324
	}
9668
6fe3d2cb9655 (svn r10582) [NoAI] -Codechange: allow getting the president and company names of other companies as well as their company value and bank balance.
rubidium
parents: 9667
diff changeset
   325
	this.name = this.company.GetCompanyName(AICompany.MY_COMPANY);
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   326
	print(this.name + ": Welcome to WrightAI. I will be building airports all day long.");
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   327
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   328
	/* We start with almost no loan, and we take a loan when we want to build something */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   329
	this.company.SetLoanAmount(this.company.GetLoanInterval());
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   330
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   331
	/* We need our local ticker, as GetTick() will skip ticks */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   332
	local ticker = 0;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   333
	/* Let's go on for ever */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   334
	while (true) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   335
		ticker++;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   336
		/* Once in a while, with enough money, try to build something */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   337
		if (ticker % this.delay_build_airport_route == 0 && this.HasMoney(100000)) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   338
			local ret = this.BuildAirportRoute();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   339
			if (ret == -1) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   340
				/* No more route found, delay even more before trying to find an other */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   341
				this.delay_build_airport_route = 10000;
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   342
			}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   343
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   344
		/* Manage the routes once in a while */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   345
		if (ticker % 2000 == 0) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   346
			this.ManageAirRoutes();
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   347
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   348
		/* Try to get ride of our loan once in a while */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   349
		if (ticker % 5000 == 0) {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   350
			this.company.SetLoanAmount(0);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   351
		}
9682
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   352
		/* Check for events once in a while */
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   353
		if (ticker % 100 == 0) {
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   354
			this.HandleEvents();
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents: 9672
diff changeset
   355
		}
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   356
		/* Make sure we do not create infinite loops */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   357
		Sleep(1);
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   358
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   359
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   360
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   361
function WrightAI::Stop()
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   362
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   363
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   364
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   365
class FWrightAI extends AIFactory {
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   366
	function GetAuthor()      { return "OpenTTD Dev Team"; }
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   367
	function GetName()        { return "WrightAI"; }
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   368
	function GetDescription() { return "A simple AI that tries to beat you with only aircrafts"; }
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   369
	function GetVersion()     { return 1; }
9720
2b1f99d52a7b (svn r11496) [NoAI] -Fix: the WrightAI was using an older version of the API, effectively making it non-functional. Patch by Zuu.
rubidium
parents: 9691
diff changeset
   370
	function GetDate()        { return "2007-11-18"; }
9667
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   371
	function CreateInstance() { return "WrightAI"; }
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   372
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   373
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   374
/* Tell the core we are an AI */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   375
iFWrightAI <- FWrightAI();