author | truelight |
Wed, 14 Mar 2007 22:55:57 +0000 | |
branch | noai |
changeset 9390 | 4042c17c8055 |
parent 9384 | 188a770476e0 |
child 9405 | df6f3b4b0038 |
permissions | -rw-r--r-- |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
2 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
3 |
/** @file NoAI.cpp a simple C++ AI that will never be an AI */ |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
4 |
|
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
5 |
#include "NoAI.hpp" |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
6 |
|
9390
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9384
diff
changeset
|
7 |
static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play. |
4042c17c8055
(svn r9182) [NoAI] -Add: added AIFactory template which all AIs must define, as this
truelight
parents:
9384
diff
changeset
|
8 |
|
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
9 |
/* virtual */ void NoAI::GameLoop() |
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
10 |
{ |
9384
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
11 |
if (this->GetTick() == 1) { |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
12 |
this->company.SetCompanyName("NoAI"); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
13 |
printf("Map size: %d by %d, %d tiles\n", this->map.GetMapSizeX(), |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
14 |
this->map.GetMapSizeY(), this->map.GetMapSize()); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
15 |
} |
9374
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
16 |
|
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
17 |
if (this->GetTick() % 10 == 0) { |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
18 |
char *company_name = this->company.GetCompanyName(); |
9384
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
19 |
printf("%s has loaned %d\n", company_name, this->company.GetLoanAmount()); |
9374
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
20 |
free(company_name); |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
21 |
} |
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
22 |
|
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
23 |
if (this->GetTick() % 14 == 0) { |
9376
7c12a15c945a
(svn r9164) [NoAI] -Add: function to get the value of LOAN_INTERVAL in the AIs.
rubidium
parents:
9374
diff
changeset
|
24 |
uint level = (this->company.GetMaxLoanAmount() / this->company.GetLoanInterval()) + 1; |
7c12a15c945a
(svn r9164) [NoAI] -Add: function to get the value of LOAN_INTERVAL in the AIs.
rubidium
parents:
9374
diff
changeset
|
25 |
this->company.SetLoanAmount(this->base.RandomRange(level) * this->company.GetLoanInterval()); |
9374
61379e9b2393
(svn r9161) [NoAI] -Add: functions to get/set company related information: loan, bank balance, company value and company name.
rubidium
parents:
9361
diff
changeset
|
26 |
} |
9384
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
27 |
|
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
28 |
if (this->GetTick() % 13 == 0) { |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
29 |
TownID town_id = this->base.RandomRange(this->town.GetMaxTownID()); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
30 |
if (!this->town.IsValidTown(town_id)) { |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
31 |
printf("He, an invalid town ID... could happen :(\n"); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
32 |
} else { |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
33 |
char *town_name = this->town.GetName(town_id); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
34 |
TileIndex t = this->town.GetLocation(town_id); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
35 |
|
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
36 |
printf("Town %s [%d of %d] at (%d, %d) with %d inhabitants\n", |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
37 |
town_name, town_id, this->town.GetTownCount(), |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
38 |
this->map.GetTileX(t), this->map.GetTileY(t), |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
39 |
this->town.GetPopulation(town_id)); |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
40 |
} |
188a770476e0
(svn r9174) [NoAI] -Codechange: call all functions that are provided by the AI wrappers, so it can later be used for regression testing.
rubidium
parents:
9376
diff
changeset
|
41 |
} |
9360
c20d0a9e0a5c
(svn r9142) [NoAI] -Add: added initial code for AI-layer system
truelight
parents:
diff
changeset
|
42 |
} |