truelight@9360: /* $Id$ */ truelight@9360: truelight@9360: /** @file NoAI.cpp a simple C++ AI that will never be an AI */ truelight@9360: truelight@9360: #include "NoAI.hpp" truelight@9360: truelight@9390: static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play. truelight@9390: truelight@9360: /* virtual */ void NoAI::GameLoop() truelight@9360: { rubidium@9384: if (this->GetTick() == 1) { rubidium@9405: if (!this->company.SetCompanyName("NoAI")) { rubidium@9405: char name[32]; rubidium@9405: snprintf(name, lengthof(name), "NoAI %d", this->base.Random()); rubidium@9405: this->company.SetCompanyName(name); rubidium@9405: } rubidium@9384: printf("Map size: %d by %d, %d tiles\n", this->map.GetMapSizeX(), rubidium@9384: this->map.GetMapSizeY(), this->map.GetMapSize()); rubidium@9384: } rubidium@9374: rubidium@9405: if (this->GetTick() < 10) { rubidium@9405: char *cargo_label = this->cargo.GetCargoLabel(this->GetTick()); rubidium@9405: printf("%s is %sfreight and the income is %d per 20 tiles in 10 days\n", rubidium@9405: cargo_label, this->cargo.IsFreight(this->GetTick()) ? "" : "not ", rubidium@9405: this->cargo.GetCargoIncome(20, 10, this->GetTick())); rubidium@9405: free(cargo_label); rubidium@9405: } rubidium@9405: rubidium@9405: if (this->GetTick() < this->industry.GetMaxIndustryID()) { rubidium@9405: if (this->industry.IsValidIndustry(this->GetTick())) { rubidium@9405: char *industry_name = this->industry.GetName(this->GetTick()); rubidium@9405: TileIndex t = this->industry.GetLocation(this->GetTick()); rubidium@9405: rubidium@9405: printf("Industry %s [%d of %d] at (%d, %d)\n", rubidium@9405: industry_name, this->GetTick(), this->industry.GetIndustryCount(), rubidium@9405: this->map.GetTileX(t), this->map.GetTileY(t)); rubidium@9405: } rubidium@9405: } rubidium@9405: rubidium@9374: if (this->GetTick() % 10 == 0) { rubidium@9374: char *company_name = this->company.GetCompanyName(); rubidium@9384: printf("%s has loaned %d\n", company_name, this->company.GetLoanAmount()); rubidium@9374: free(company_name); rubidium@9374: } rubidium@9374: rubidium@9374: if (this->GetTick() % 14 == 0) { rubidium@9376: uint level = (this->company.GetMaxLoanAmount() / this->company.GetLoanInterval()) + 1; rubidium@9376: this->company.SetLoanAmount(this->base.RandomRange(level) * this->company.GetLoanInterval()); rubidium@9374: } rubidium@9384: rubidium@9384: if (this->GetTick() % 13 == 0) { rubidium@9384: TownID town_id = this->base.RandomRange(this->town.GetMaxTownID()); rubidium@9405: if (this->town.IsValidTown(town_id)) { rubidium@9384: char *town_name = this->town.GetName(town_id); rubidium@9384: TileIndex t = this->town.GetLocation(town_id); rubidium@9384: rubidium@9384: printf("Town %s [%d of %d] at (%d, %d) with %d inhabitants\n", rubidium@9384: town_name, town_id, this->town.GetTownCount(), rubidium@9384: this->map.GetTileX(t), this->map.GetTileY(t), rubidium@9384: this->town.GetPopulation(town_id)); rubidium@9384: } rubidium@9384: } truelight@9360: }