bin/ai/regression/main.nut
branchnoai
changeset 9470 4593c953a276
parent 9469 7072beb81014
child 9471 467ee8749166
--- a/bin/ai/regression/main.nut	Sun Mar 18 23:59:07 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-class Regression extends AIController {
-	stop     = false;
-
-	function Start();
-	function Stop();
-
-	constructor() {	}
-}
-
-
-
-function Regression::TestInit()
-{
-	print("");
-	print("--TestInit--");
-	print(" TickTest: " + this.GetTick());
-	Sleep(1);
-	print(" TickTest: " + this.GetTick());
-}
-
-function Regression::Base()
-{
-	local base = AIBase();
-
-	print("");
-	print("--AIBase--");
-	print("  Rand():       " + base.Rand());
-	print("  Rand():       " + base.Rand());
-	print("  Rand():       " + base.Rand());
-	print("  RandRange(0): " + base.RandRange(0));
-	print("  RandRange(0): " + base.RandRange(0));
-	print("  RandRange(0): " + base.RandRange(0));
-	print("  RandRange(1): " + base.RandRange(1));
-	print("  RandRange(1): " + base.RandRange(1));
-	print("  RandRange(1): " + base.RandRange(1));
-	print("  RandRange(2): " + base.RandRange(2));
-	print("  RandRange(2): " + base.RandRange(2));
-	print("  RandRange(2): " + base.RandRange(2));
-	print("  RandRange(9): " + base.RandRange(9));
-	print("  RandRange(9): " + base.RandRange(9));
-	print("  RandRange(9): " + base.RandRange(9));
-	print("  Chance(1, 2): " + base.Chance(1, 2));
-	print("  Chance(1, 2): " + base.Chance(1, 2));
-	print("  Chance(1, 2): " + base.Chance(1, 2));
-}
-
-function Regression::Cargo()
-{
-	local cargo = AICargo();
-
-	print("");
-	print("--AICargo--");
-	for (local i = -1; i < 15; i++) {
-		print("  Cargo " + i);
-		print("    GetCargoLabel():         '" + cargo.GetCargoLabel(i)+ "'");
-		print("    IsFreight():             " + cargo.IsFreight(i));
-		print("    GetCargoIncome(0, 0):    " + cargo.GetCargoIncome(0, 0, i));
-		print("    GetCargoIncome(10, 10):  " + cargo.GetCargoIncome(10, 10, i));
-		print("    GetCargoIncome(100, 10): " + cargo.GetCargoIncome(100, 10, i));
-		print("    GetCargoIncome(10, 100): " + cargo.GetCargoIncome(10, 100, i));
-	}
-}
-
-function Regression::Company()
-{
-	local company = AICompany();
-
-	print("");
-	print("--Company--");
-	print("  SetCompanyName():     " + company.SetCompanyName("Regression"));
-	print("  SetCompanyName():     " + company.SetCompanyName("Regression"));
-	print("  GetCompanyName():     " + company.GetCompanyName());
-	print("  GetCompanyValue():    " + company.GetCompanyValue());
-	print("  GetBankBalance():     " + company.GetBankBalance());
-	print("  GetLoanAmount():      " + company.GetLoanAmount());
-	print("  GetMaxLoanAmount():   " + company.GetMaxLoanAmount());
-	print("  GetLoanInterval():    " + company.GetLoanInterval());
-	print("  SetLoanAmount(1):     " + company.SetLoanAmount(1));
-	print("  SetLoanAmount(100):   " + company.SetLoanAmount(100));
-	print("  SetLoanAmount(10000): " + company.SetLoanAmount(10000));
-	print("  GetBankBalance():     " + company.GetBankBalance());
-	print("  GetLoanAmount():      " + company.GetLoanAmount());
-	print("  SetLoanAmount(10000): " + company.SetLoanAmount(company.GetMaxLoanAmount()));
-	print("  GetBankBalance():     " + company.GetBankBalance());
-	print("  GetLoanAmount():      " + company.GetLoanAmount());
-}
-
-function Regression::Industry()
-{
-	local industry = AIIndustry();
-	local j = 0;
-
-	print("");
-	print("--Industry--");
-	print("  GetMaxIndustryID():  " + industry.GetMaxIndustryID());
-	print("  GetIndustryCount():  " + industry.GetIndustryCount());
-	for (local i = -1; i < industry.GetMaxIndustryID(); i++) {
-		if (industry.IsValidIndustry(i)) j++;
-		print("  Industry " + i);
-		print("    IsValidIndustry(): " + industry.IsValidIndustry(i));
-		print("    GetName():         " + industry.GetName(i));
-		print("    GetLocation():     " + industry.GetLocation(i));
-	}
-	print("  Valid Industries:    " + j);
-	print("  GetIndustryCount():  " + industry.GetIndustryCount());
-}
-
-function Regression::Map()
-{
-	local map = AIMap();
-
-	print("");
-	print("--Map--");
-	print("  GetMapSize():     " + map.GetMapSize());
-	print("  GetMapSizeX():    " + map.GetMapSizeX());
-	print("  GetMapSizeY():    " + map.GetMapSizeY());
-	print("  GetTileX(123):    " + map.GetTileX(123));
-	print("  GetTileY(123):    " + map.GetTileY(123));
-	print("  IsValidTile(123): " + map.IsValidTile(123));
-	print("  GetTileX(124):    " + map.GetTileX(124));
-	print("  GetTileY(124):    " + map.GetTileY(124));
-	print("  IsValidTile(124): " + map.IsValidTile(124));
-	print("  IsValidTile(0):   " + map.IsValidTile(0));
-	print("  IsValidTile(-1):  " + map.IsValidTile(-1));
-	print("  IsValidTile():    " + map.IsValidTile(map.GetMapSize()));
-	print("  IsValidTile():    " + map.IsValidTile(map.GetMapSize() - 1));
-}
-
-function Regression::Town()
-{
-	local town = AITown();
-	local j = 0;
-
-	print("");
-	print("--Town--");
-	print("  GetMaxTownID():    " + town.GetMaxTownID());
-	print("  GetTownCount():    " + town.GetTownCount());
-	for (local i = -1; i < town.GetMaxTownID(); i++) {
-		if (town.IsValidTown(i)) j++;
-		print("  Town " + i);
-		print("    IsValidTown():   " + town.IsValidTown(i));
-		print("    GetName():       " + town.GetName(i));
-		print("    GetPopulation(): " + town.GetPopulation(i));
-		print("    GetLocation():   " + town.GetLocation(i));
-	}
-	print("  Valid Industries:  " + j);
-	print("  GetTownCount():    " + town.GetTownCount());
-}
-
-
-function Regression::Start()
-{
-	this.TestInit();
-	this.Base();
-	this.Cargo();
-	this.Company();
-	this.Industry();
-	this.Map();
-	this.Town();
-}
-
-function Regression::Stop()
-{
-	this.stop = true;
-}
-
-class FRegression extends AIFactory {
-	function GetAuthor()      { return "OpenTTD Dev Team"; }
-	function GetName()        { return "Regression"; }
-	function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
-	function GetVersion()     { return 1; }
-	function GetDate()        { return "2007-03-18"; }
-	function CreateInstance() { return "Regression"; }
-}
-
-/* Only enable this if you want to run the regression test.
- *  The best way to do it is to disable all other AIs, so you are sure thisone
- *  kicks in, and use a pre-made savegame of which you already know the result.
- * You can compare the output from this AI with the pre-made one, and it should
- *  match. If not, something went wrong. */
-//iFRegression <-FRegression();