src/ai/NoAI/NoAI.cpp
branchnoai
changeset 9441 03da911c8d5f
child 9444 fd27df7ca2a0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/NoAI/NoAI.cpp	Fri Mar 16 17:03:49 2007 +0000
@@ -0,0 +1,68 @@
+/* $Id$ */
+
+/** @file NoAI.cpp a simple C++ AI that will never be an AI */
+
+#include "NoAI.hpp"
+
+static FNoAI iFNoAI; ///< Tell the AI-core that we have an AI with which we like to play.
+
+/* virtual */ void NoAI::Start()
+{
+	while (true) {
+		printf("Start NoAI %d\n", this->GetTick());
+		this->Sleep(5);
+	}
+	return;
+	if (this->GetTick() == 1) {
+		if (!this->company.SetCompanyName("NoAI")) {
+			char name[32];
+			snprintf(name, lengthof(name), "NoAI %d", this->base.Rand());
+			this->company.SetCompanyName(name);
+		}
+		printf("Map size: %d by %d, %d tiles\n", this->map.GetMapSizeX(),
+				this->map.GetMapSizeY(), this->map.GetMapSize());
+	}
+
+	if (this->GetTick() < 10) {
+		char *cargo_label = this->cargo.GetCargoLabel(this->GetTick());
+		printf("%s is %sfreight and the income is %d per 20 tiles in 10 days\n",
+				cargo_label, this->cargo.IsFreight(this->GetTick()) ? "" : "not ",
+				this->cargo.GetCargoIncome(20, 10, this->GetTick()));
+		free(cargo_label);
+	}
+
+	if (this->GetTick() < this->industry.GetMaxIndustryID()) {
+		if (this->industry.IsValidIndustry(this->GetTick())) {
+			char *industry_name = this->industry.GetName(this->GetTick());
+			TileIndex t = this->industry.GetLocation(this->GetTick());
+
+			printf("Industry %s [%d of %d] at (%d, %d)\n",
+					industry_name, this->GetTick(), this->industry.GetIndustryCount(),
+					this->map.GetTileX(t), this->map.GetTileY(t));
+		}
+	}
+
+	if (this->GetTick() % 10 == 0) {
+		char *company_name = this->company.GetCompanyName();
+		printf("%s has loaned %d\n", company_name, this->company.GetLoanAmount());
+		free(company_name);
+	}
+
+	if (this->GetTick() % 14 == 0) {
+		uint level = (this->company.GetMaxLoanAmount() / this->company.GetLoanInterval()) + 1;
+		this->company.SetLoanAmount(this->base.RandRange(level) * this->company.GetLoanInterval());
+	}
+
+	if (this->GetTick() % 13 == 0) {
+		TownID town_id = this->base.RandRange(this->town.GetMaxTownID());
+		if (this->town.IsValidTown(town_id)) {
+			char *town_name = this->town.GetName(town_id);
+			TileIndex t = this->town.GetLocation(town_id);
+
+			printf("Town %s [%d of %d] at (%d, %d) with %d inhabitants\n",
+					town_name, town_id, this->town.GetTownCount(),
+					this->map.GetTileX(t), this->map.GetTileY(t),
+					this->town.GetPopulation(town_id));
+		}
+	}
+}