7 static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play. |
7 static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play. |
8 |
8 |
9 /* virtual */ void NoAI::GameLoop() |
9 /* virtual */ void NoAI::GameLoop() |
10 { |
10 { |
11 if (this->GetTick() == 1) { |
11 if (this->GetTick() == 1) { |
12 this->company.SetCompanyName("NoAI"); |
12 if (!this->company.SetCompanyName("NoAI")) { |
|
13 char name[32]; |
|
14 snprintf(name, lengthof(name), "NoAI %d", this->base.Random()); |
|
15 this->company.SetCompanyName(name); |
|
16 } |
13 printf("Map size: %d by %d, %d tiles\n", this->map.GetMapSizeX(), |
17 printf("Map size: %d by %d, %d tiles\n", this->map.GetMapSizeX(), |
14 this->map.GetMapSizeY(), this->map.GetMapSize()); |
18 this->map.GetMapSizeY(), this->map.GetMapSize()); |
|
19 } |
|
20 |
|
21 if (this->GetTick() < 10) { |
|
22 char *cargo_label = this->cargo.GetCargoLabel(this->GetTick()); |
|
23 printf("%s is %sfreight and the income is %d per 20 tiles in 10 days\n", |
|
24 cargo_label, this->cargo.IsFreight(this->GetTick()) ? "" : "not ", |
|
25 this->cargo.GetCargoIncome(20, 10, this->GetTick())); |
|
26 free(cargo_label); |
|
27 } |
|
28 |
|
29 if (this->GetTick() < this->industry.GetMaxIndustryID()) { |
|
30 if (this->industry.IsValidIndustry(this->GetTick())) { |
|
31 char *industry_name = this->industry.GetName(this->GetTick()); |
|
32 TileIndex t = this->industry.GetLocation(this->GetTick()); |
|
33 |
|
34 printf("Industry %s [%d of %d] at (%d, %d)\n", |
|
35 industry_name, this->GetTick(), this->industry.GetIndustryCount(), |
|
36 this->map.GetTileX(t), this->map.GetTileY(t)); |
|
37 } |
15 } |
38 } |
16 |
39 |
17 if (this->GetTick() % 10 == 0) { |
40 if (this->GetTick() % 10 == 0) { |
18 char *company_name = this->company.GetCompanyName(); |
41 char *company_name = this->company.GetCompanyName(); |
19 printf("%s has loaned %d\n", company_name, this->company.GetLoanAmount()); |
42 printf("%s has loaned %d\n", company_name, this->company.GetLoanAmount()); |
25 this->company.SetLoanAmount(this->base.RandomRange(level) * this->company.GetLoanInterval()); |
48 this->company.SetLoanAmount(this->base.RandomRange(level) * this->company.GetLoanInterval()); |
26 } |
49 } |
27 |
50 |
28 if (this->GetTick() % 13 == 0) { |
51 if (this->GetTick() % 13 == 0) { |
29 TownID town_id = this->base.RandomRange(this->town.GetMaxTownID()); |
52 TownID town_id = this->base.RandomRange(this->town.GetMaxTownID()); |
30 if (!this->town.IsValidTown(town_id)) { |
53 if (this->town.IsValidTown(town_id)) { |
31 printf("He, an invalid town ID... could happen :(\n"); |
|
32 } else { |
|
33 char *town_name = this->town.GetName(town_id); |
54 char *town_name = this->town.GetName(town_id); |
34 TileIndex t = this->town.GetLocation(town_id); |
55 TileIndex t = this->town.GetLocation(town_id); |
35 |
56 |
36 printf("Town %s [%d of %d] at (%d, %d) with %d inhabitants\n", |
57 printf("Town %s [%d of %d] at (%d, %d) with %d inhabitants\n", |
37 town_name, town_id, this->town.GetTownCount(), |
58 town_name, town_id, this->town.GetTownCount(), |