--- a/bin/ai/SQNoAI/main.nut Wed Mar 14 12:42:37 2007 +0000
+++ b/bin/ai/SQNoAI/main.nut Wed Mar 14 20:22:07 2007 +0000
@@ -1,12 +1,45 @@
/* Extend our own AI from AIController so we can access basic things. */
class SQNoAI extends AIController {
+ base = AIBase();
+ company = AICompany();
+ map = AIMap();
+ town = AITown();
+
function GameLoop();
}
/* Define the GameLoop. This is called every tick. */
function SQNoAI::GameLoop()
{
- print("GameLoop " + this.GetTick());
+ if (this.GetTick() == 1) {
+ this.company.SetCompanyName("SQNoAI");
+ print("Map size: " + this.map.GetMapSizeX() + " by " +
+ this.map.GetMapSizeY() + ", " + this.map.GetMapSize() + " tiles");
+ }
+
+ if (this.GetTick() % 10 == 0) {
+ local company_name = this.company.GetCompanyName();
+ print(company_name + " has loaned " + this.company.GetLoanAmount());
+ }
+
+ if (this.GetTick() % 14 == 0) {
+ local level = (this.company.GetMaxLoanAmount() / this.company.GetLoanInterval()) + 1;
+ this.company.SetLoanAmount(this.base.RandomRange(level) * this.company.GetLoanInterval());
+ }
+
+ if (this.GetTick() % 13 == 0) {
+ local town_id = this.base.RandomRange(this.town.GetMaxTownID());
+ if (!this.town.IsValidTown(town_id)) {
+ print("He, an invalid town ID... could happen :(");
+ } else {
+ local town_name = this.town.GetName(town_id);
+ local t = this.town.GetLocation(town_id);
+
+ print("Town " + town_name + " [" + town_id + " of " + this.town.GetTownCount() +
+ "] at (" + this.map.GetTileX(t) + ", " + this.map.GetTileY(t) + ") with " +
+ this.town.GetPopulation(town_id) + " inhabitants");
+ }
+ }
}
/* Tell OpenTTD we have an AI */