bin/ai/wrightai/main.nut
author truebrain
Sun, 24 Feb 2008 22:10:05 +0000
branchnoai
changeset 9753 7209db94ad12
parent 9750 71106199d143
child 9762 ad9c304c6c77
permissions -rw-r--r--
(svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
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
	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
     4
	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
     5
	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
     6
	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
     7
	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
     8
	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
     9
	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
    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
    11
	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
    12
	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
    13
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	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
    15
		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
    16
		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
    17
		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
    18
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
 * 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
    23
 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
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
    25
{
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    26
	if (AICompany.GetBankBalance(AICompany.MY_COMPANY) + (AICompany.GetMaxLoanAmount() - AICompany.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
    27
	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
    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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
 * 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
    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
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
    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
	if (!this.HasMoney(money)) return;
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    36
	if (AICompany.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
    37
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    38
	local loan = money - AICompany.GetBankBalance(AICompany.MY_COMPANY) + AICompany.GetLoanInterval() + AICompany.GetLoanAmount();
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    39
	loan = loan - loan % AICompany.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
    40
	print(this.name + ": [INFO] Need a loan to get " + money + ": " + loan);
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    41
	AICompany.SetLoanAmount(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
    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
 * 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
    46
 *  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
    47
 */
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
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
    49
{
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    50
	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
    51
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
    52
	/* 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
    53
	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
    54
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	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
    56
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    57
	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
    58
	if (tile_1 < 0) return -1;
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
    59
	local tile_2 = this.FindSuitableAirportSpot(airport_type, tile_1);
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    60
	if (tile_2 < 0) {
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    61
		this.towns_used.RemoveValue(tile_1);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    62
		return -2;
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    63
	}
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
    64
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
    65
	/* Build the airports for real */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    66
	if (!AIAirport.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
    67
		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 + ".");
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    68
		this.towns_used.RemoveValue(tile_1);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    69
		this.towns_used.RemoveValue(tile_2);
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
    70
		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
    71
	}
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    72
	if (!AIAirport.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
    73
		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 + ".");
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    74
		AIAirport.RemoveAirport(tile_1);
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    75
		this.towns_used.RemoveValue(tile_1);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    76
		this.towns_used.RemoveValue(tile_2);
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
    77
		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
    78
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	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
    81
	if (ret < 0) {
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    82
		AIAirport.RemoveAirport(tile_1);
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
    83
		AIAirport.RemoveAirport(tile_2);
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    84
		this.towns_used.RemoveValue(tile_1);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
    85
		this.towns_used.RemoveValue(tile_2);
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
    86
		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
    87
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	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
    90
	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
    91
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
 * 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
    95
 *  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
    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
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
    98
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	/* Build an aircraft */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   100
	local hangar = AIAirport.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
   101
	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
   102
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
   103
	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
   104
9672
18c71ca987e4 (svn r10611) [NoAI] -Fix: improved FindBestXXX, it now finds the fastest, biggest vehicle available
truelight
parents: 9671
diff changeset
   105
	/* When bank balance < 300000, buy cheaper planes */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   106
	local balance = AICompany.GetBankBalance(AICompany.MY_COMPANY);
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   107
	engine_list.Valuate(AIEngineList_vPrice());
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
   108
	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
   109
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   110
	engine_list.Valuate(AIEngineList_vCargoType())
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
	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
   112
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   113
	engine_list.Valuate(AIEngineList_vCapacity())
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
   114
	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
   115
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
   116
	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
   117
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
	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
   119
		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
   120
		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
   121
	}
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   122
	local vehicle = AIVehicle.BuildVehicle(hangar, engine);
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   123
	if (!AIVehicle.IsValidVehicle(vehicle)) {
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
   124
		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
   125
		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
   126
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   127
	/* Send him on his way */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   128
	AIOrder.AppendOrder(vehicle, tile_1, AIOrder.AIOF_NONE);
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   129
	AIOrder.AppendOrder(vehicle, tile_2, AIOrder.AIOF_NONE);
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   130
	AIVehicle.StartStopVehicle(vehicle);
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
   131
	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
   132
	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
   133
	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
   134
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	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
   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
	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
   138
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
/**
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
 * 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
   142
 *  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
   143
 */
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   144
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
   145
{
9670
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   146
	local airport_x, airport_y, airport_rad;
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   147
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   148
	airport_x = AIAirport.GetAirportWidth(airport_type);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   149
	airport_y = AIAirport.GetAirportHeight(airport_type);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   150
	airport_rad = AIAirport.GetAirportCoverageRadius(airport_type);
820b77e19bb3 (svn r10609) [NoAI] -Add: added GetAirportWidth / GetAirportHeight
truelight
parents: 9668
diff changeset
   151
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
   152
	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
   153
	/* 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
   154
	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
   155
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   156
	town_list.Valuate(AITownList_vPopulation());
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
   157
	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
   158
	/* 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
   159
	town_list.KeepTop(10);
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   160
	town_list.Valuate(AIList_vRandomize());
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
   161
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	/* 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
   163
	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
   164
		/* 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
   165
		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
   166
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		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
   168
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* 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
   170
		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
   171
		/* XXX -- We assume we are more than 15 tiles away from the border! */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   172
		list.AddRectangle(tile - AIMap.GetTileIndex(15, 15), tile + AIMap.GetTileIndex(15, 15));
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   173
		list.Valuate(AITileList_vBuildableRectangle(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
   174
		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
   175
		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
   176
			/* If we have a tile defined, we don't want to be within 25 tiles of this tile */
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   177
			list.Valuate(AITileList_vDistanceSquareToTile(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
   178
			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
   179
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* Sort on acceptance, remove places that don't have acceptance */
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   181
		list.Valuate(AITileList_vCargoAcceptance(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
   182
		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
   183
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* 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
   185
		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
   186
		/* 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
   187
		{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
			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
   189
			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
   190
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   191
			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
   192
				Sleep(1);
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   193
				if (!AIAirport.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
   194
				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
   195
				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
   196
			}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
			/* 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
   199
			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
   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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		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
   203
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* 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
   205
		this.towns_used.AddItem(town, tile);
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   206
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
   207
		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
   208
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	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
   211
	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
   212
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
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
   215
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	local list = AIVehicleList();
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   217
	list.Valuate(AIVehicleList_vAge());
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
   218
	/* 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
   219
	list.KeepAboveValue(365 * 2);
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   220
	list.Valuate(AIVehicleList_vProfitLastYear());
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
   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
	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
   223
		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
   224
		/* Profit last year and this year bad? Let's sell the vehicle */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   225
		if (profit < 10000 && AIVehicle.GetProfitThisYear(i) < 10000) {
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
   226
			/* Send the vehicle to depot if we didn't do so yet */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   227
			if (!vehicle_to_depot.rawin(i) || vehicle_to_depot.rawget(i) != true) {
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   228
				print(this.name + ": [INFO] Sending " + i + " to depot as profit is: " + profit + " / " + AIVehicle.GetProfitThisYear(i));
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   229
				AIVehicle.SendVehicleToDepot(i);
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   230
				vehicle_to_depot.rawset(i, 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
   231
			}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* Try to sell it over and over till it really is in the depot */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   234
		if (vehicle_to_depot.rawin(i) && vehicle_to_depot.rawget(i) == true) {
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   235
			if (AIVehicle.SellVehicle(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
   236
				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
   237
				/* Check if we are the last one serving those airports; else sell the airports */
9745
fb2454d70f37 (svn r12225) [NoAI] -Change [API CHANGE]: AIStationVehicleList -> AIVehicleList_Station (WATCH THE NAMES CAREFULLY!)
truebrain
parents: 9738
diff changeset
   238
				local list2 = AIVehicleList_Station(AIStation.GetStationID(this.route_1.GetValue(i)));
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   239
				if (list2.Count() == 0) this.SellAirports(i);
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   240
				vehicle_to_depot.rawdelete(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
   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
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	/* 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
   246
	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
   247
9671
ad29df0de918 (svn r10610) [NoAI] -Fix r10609: typo in WrightAI
truelight
parents: 9670
diff changeset
   248
	list = AIStationList(AIStation.STATION_AIRPORT);
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   249
	list.Valuate(AIStationList_vCargoWaiting(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
   250
	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
   251
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
9745
fb2454d70f37 (svn r12225) [NoAI] -Change [API CHANGE]: AIStationVehicleList -> AIVehicleList_Station (WATCH THE NAMES CAREFULLY!)
truebrain
parents: 9738
diff changeset
   253
		local list2 = AIVehicleList_Station(i);
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   254
		/* No vehicles going to this station, abort and sell */
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   255
		if (list2.Count() == 0) {
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   256
			this.SellAirports(i);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   257
			continue;
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   258
		};
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
   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
		/* 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
   261
		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
   262
		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
   263
9753
7209db94ad12 (svn r12236) [NoAI] -Change: [API CHANGE] All valuators are now in the notation: AI<type>List_v<Valuator>. Example: AIVehicleList_vAge
truebrain
parents: 9750
diff changeset
   264
		list2.Valuate(AIVehicleList_vAge());
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
   265
		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
   266
		/* 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
   267
		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
   268
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   269
		print(this.name + ": [INFO] Station " + i + " (" + AIStation.GetLocation(i) + ") has too many cargo, adding a new vehicle for the route.");
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
   270
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* 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
   272
		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
   273
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		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
   275
	}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   278
/**
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   279
  * Sells the airports from route index i
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   280
  * Removes towns from towns_used list too
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   281
  */
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   282
function WrightAI::SellAirports(i) {
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   283
	/* Remove the airports */
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   284
	print(this.name + ": [INFO] Removing airports as nobody serves them anymore.");
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   285
	AIAirport.RemoveAirport(this.route_1.GetValue(i));
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   286
	AIAirport.RemoveAirport(this.route_2.GetValue(i));
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   287
	/* Free the towns_used entries */
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   288
	this.towns_used.RemoveValue(this.route_1.GetValue(i));
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   289
	this.towns_used.RemoveValue(this.route_2.GetValue(i));
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   290
	/* Remove the route */
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   291
	this.route_1.RemoveItem(i);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   292
	this.route_2.RemoveItem(i);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   293
}
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   294
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
   295
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
   296
{
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
	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
   298
		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
   299
		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
   300
			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
   301
				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
   302
				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
   303
				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
   304
				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
   305
				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
   306
				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
   307
				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
   308
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
			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
   310
				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
   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
	}
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
   313
}
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
   314
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
   315
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
   316
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	/* 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
   318
	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
   319
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	/* Give the boy a name */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   321
	if (!AICompany.SetCompanyName("WrightAI")) {
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
   322
		local i = 2;
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   323
		while (!AICompany.SetCompanyName("WrightAI #" + 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
   324
			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
   325
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	}
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   327
	this.name = AICompany.GetCompanyName(AICompany.MY_COMPANY);
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   328
	/* Say hello to the user */
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
   329
	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
   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 start with almost no loan, and we take a loan when we want to build something */
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   332
	AICompany.SetLoanAmount(AICompany.GetLoanInterval());
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
   333
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
	/* 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
   335
	local ticker = 0;
9747
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   336
	/* Determine time we may sleep */
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   337
	local sleepingtime = 100;
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   338
	if (this.delay_build_airport_route < sleepingtime)
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   339
		sleepingtime = this.delay_build_airport_route;
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   340
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
   341
	/* 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
   342
	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
   343
		/* Once in a while, with enough money, try to build something */
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   344
		if ((ticker % this.delay_build_airport_route == 0 || ticker == 0) && this.HasMoney(100000)) {
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
   345
			local ret = this.BuildAirportRoute();
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   346
			if (ret == -1 && ticker != 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
   347
				/* 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
   348
				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
   349
			}
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   350
			else if (ret < 0 && ticker == 0) {
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   351
				/* The AI failed to build a first airport and is deemed */
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   352
				this.ChangeName("FailedWrightAI");
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   353
				print(this.name + ": Failed to build first airport route, now giving up building. Repaying loan. Have a nice day!");
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   354
				AICompany.SetLoanAmount(0);
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   355
				return;
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   356
			}
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
   357
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* 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
   359
		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
   360
			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
   361
		}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
		/* 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
   363
		if (ticker % 5000 == 0) {
9738
53baf447bae8 (svn r12217) [NoAI] -Change: changed wrightAI to reflect the last codechange
truebrain
parents: 9720
diff changeset
   364
			AICompany.SetLoanAmount(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
   365
		}
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
   366
		/* 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
   367
		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
   368
			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
   369
		}
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
   370
		/* Make sure we do not create infinite loops */
9747
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   371
		Sleep(sleepingtime);
7e8f23e8d0c8 (svn r12227) [NoAI] -Fix (wrightAI): sleep as long as it takes to do something new (yorick)
truebrain
parents: 9745
diff changeset
   372
		ticker += sleepingtime;
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
   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
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that 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
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   376
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
   377
{
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   378
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   379
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   380
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
   381
	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
   382
	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
   383
	function GetDescription() { return "A simple AI that tries to beat you with only aircrafts"; }
9750
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   384
	function GetVersion()     { return 1.1; }
71106199d143 (svn r12232) [NoAI] -Fix: various of fixes for wrightai (mostly finished all XXX / TODO) (yorick)
truebrain
parents: 9747
diff changeset
   385
	function GetDate()        { return "2008-02-24"; }
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
   386
	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
   387
}
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   388
053afa64f977 (svn r10581) [NoAI] -Add: added WrightAI, and even though it is an aircraft only AI, it is the first NoAI that actually builds something useful and that is where the name came from (wright is archaic English for craftsman or builder)
truelight
parents:
diff changeset
   389
/* 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
   390
iFWrightAI <- FWrightAI();