AdmiralAI v25

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Markus_cz
Engineer
Engineer
Posts: 2
Joined: 01 Apr 2007 13:08
Location: Brno, Czech Republic

Re: AdmiralAI v25

Post by Markus_cz » 08 Jan 2011 16:11

I'm playing with eGRVTS and AdmiralAI consistently makes bad choices of vehicles. eGRVTS inlcudes some vehicles that are almost never profitable, mainly the early steam cars, but AdmiralAI seems to like them for some reason. It will inevitably bankrupt.

See the included image
Attachments
Brünschalinen, 19th Nov 1874.png
(213.14 KiB) Downloaded 1 time

kiome
Engineer
Engineer
Posts: 1
Joined: 18 Feb 2011 10:07

Re: AdmiralAI v25

Post by kiome » 18 Feb 2011 10:13

Hi,

I have the following problem with AdmiralAI, it occurs just after the electric rails have been discovered.

Image

Uploaded with ImageShack.us

How can it be resolved ?

Many thanks.

kiome

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9276
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker » 17 Mar 2011 06:52

In some tests I had AdmiralAI start. It did start well with a train route and air service. Looking at the train routes I wondered though whether it might not want to pick slightly longer, more profitable routes (AdmiralAI: yellow. The blue company came 2nd).

Also I noticed that the track building algorithm by AIAI and AdmiralAI vary a lot. To me it seems that AdmiralAI always builds one direction first and only then builds the other direction of tracks between stations, with quite some thought time passing between that (and also between building stations and building track). It might be an idea to jointly path find both tracks or only build the path is found. AIAI builds both directions at the same time and it looks like an interesting concept (upper unfinished tracks which are being build that very moment)
Attachments
Unnamed, 2021-01-05.png
(79.35 KiB) Downloaded 1 time

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AdmiralAI v25

Post by Kogut » 17 Mar 2011 18:56

It is not AIAI. AIAI is constructing first track and later it is trying to build second.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AdmiralAI v25

Post by Zuu » 10 Apr 2011 17:38

I had AdmiralAI crash with the same error as kiome. As his screenshot is on a slow external server I've attached a screenshot of my error even if it is a duplicate.

Edit: I'm using r22302 + the OpenGFX+ sets. I've also attached the savegame if it is of any help. I believe the crash happened quite some time ago as I didn't notice it until I was to save the game.
Attachments
Hinwood Transport, 10th Jul 1970.png
(22.07 KiB) Downloaded 1 time
Me and AI.sav
(518.09 KiB) Downloaded 108 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9276
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker » 20 Apr 2011 20:14

I did it again, let the AIs have fun with my NewGRF testgame while I was at work. This time AdmiralAI crashed on me (savegame and custom newgrfs attached):

Code: Select all

dbg: [ai] [1] [S] Your script made an error: assertion failed
dbg: [ai] [1] [S] 
dbg: [ai] [1] [S] *FUNCTION [BuildPath()] AdmiralAI-25.tar/admiralai-25/rail/railroutebuilder.nut line [571]
dbg: [ai] [1] [S] *FUNCTION [TestBuildPath()] AdmiralAI-25.tar/admiralai-25/rail/railroutebuilder.nut line [541]
dbg: [ai] [1] [S] *FUNCTION [ConnectRailStations()] AdmiralAI-25.tar/admiralai-25/rail/railroutebuilder.nut line [307]
dbg: [ai] [1] [S] *FUNCTION [BuildNewRoute()] AdmiralAI-25.tar/admiralai-25/rail/trainmanager.nut line [354]
dbg: [ai] [1] [S] *FUNCTION [Start()] AdmiralAI-25.tar/admiralai-25/main.nut line [701]
dbg: [ai] [1] [S] 
dbg: [ai] [1] [S] [orig_path] INSTANCE
dbg: [ai] [1] [S] [prevprev] 85990
dbg: [ai] [1] [S] [prev] 85989
dbg: [ai] [1] [S] [path] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [test] INSTANCE
dbg: [ai] [1] [S] [path] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [building_ok] false
dbg: [ai] [1] [S] [num_retries] 0
dbg: [ai] [1] [S] [first_path] INSTANCE
dbg: [ai] [1] [S] [path] INSTANCE
dbg: [ai] [1] [S] [path2] false
dbg: [ai] [1] [S] [pf2] INSTANCE
dbg: [ai] [1] [S] [track_near_station_b_already_build] false
dbg: [ai] [1] [S] [track_near_station_a_already_build] false
dbg: [ai] [1] [S] [platform_length] 4
dbg: [ai] [1] [S] [tile] 87016
dbg: [ai] [1] [S] [goals] ARRAY
dbg: [ai] [1] [S] [sources] ARRAY
dbg: [ai] [1] [S] [pf] INSTANCE
dbg: [ai] [1] [S] [ignored] INSTANCE
dbg: [ai] [1] [S] [station_b] 372
dbg: [ai] [1] [S] [station_a] 371
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [station_to] INSTANCE
dbg: [ai] [1] [S] [station_from] INSTANCE
dbg: [ai] [1] [S] [@ITERATOR@] 266
dbg: [ai] [1] [S] [dummy] 95
dbg: [ai] [1] [S] [ind_to] 266
dbg: [ai] [1] [S] [ind_acc_list] INSTANCE
dbg: [ai] [1] [S] [@ITERATOR@] 144
dbg: [ai] [1] [S] [dummy] 91
dbg: [ai] [1] [S] [ind_from] 144
dbg: [ai] [1] [S] [val_list] INSTANCE
dbg: [ai] [1] [S] [@ITERATOR@] 6
dbg: [ai] [1] [S] [dummy] 724
dbg: [ai] [1] [S] [cargo] 6
dbg: [ai] [1] [S] [cargo_list] INSTANCE
dbg: [ai] [1] [S] [rail_type_list] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [veh_list] INSTANCE
dbg: [ai] [1] [S] [build_route] false
dbg: [ai] [1] [S] [last_type] 1
dbg: [ai] [1] [S] [build_road_route] 3
dbg: [ai] [1] [S] [build_busses] false
dbg: [ai] [1] [S] [start_tick] 2
dbg: [ai] [1] [S] [group_list] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] The AI died unexpectedly.
dbg: [ai] The AI died unexpectedly.
Attachments
random_AI_test2.sav
savegame
(662.86 KiB) Downloaded 102 times
ogfx-industries.zip
required industries newgrf
(16.11 KiB) Downloaded 110 times

Yisc
Engineer
Engineer
Posts: 50
Joined: 09 Apr 2004 21:14
Location: Leiden
Contact:

Re: AdmiralAI v25

Post by Yisc » 21 Apr 2011 20:45

Is there any developement going on for this AI?
I really liked to play a game against it, but the crashes prevents it.
Hopefully an update for this AI will be released soon.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9276
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker » 27 Apr 2011 21:43

Same bug as Zuu describes, after 36 game years. But it was stressed hard, but did better for years than most AI, when I activated mid-game the cargo destinations in my YACD game (before it was ranked 2nd or 3rd):

Code: Select all

dbg: [ai] [1] [S] Your script made an error: parameter 2 has an invalid type 'null' ; expected: 'integer'
dbg: [ai] [1] [S] 
dbg: [ai] [1] [S] *FUNCTION [ConvertRailType()] AdmiralAI-25.tar/admiralai-25/stationmanager.nut line [333]
dbg: [ai] [1] [S] *FUNCTION [_UpdateRailType()] AdmiralAI-25.tar/admiralai-25/rail/trainline.nut line [371]
dbg: [ai] [1] [S] *FUNCTION [CheckVehicles()] AdmiralAI-25.tar/admiralai-25/rail/trainline.nut line [413]
dbg: [ai] [1] [S] *FUNCTION [CheckRoutes()] AdmiralAI-25.tar/admiralai-25/rail/trainmanager.nut line [236]
dbg: [ai] [1] [S] *FUNCTION [DoMaintenance()] AdmiralAI-25.tar/admiralai-25/main.nut line [545]
dbg: [ai] [1] [S] *FUNCTION [Start()] AdmiralAI-25.tar/admiralai-25/main.nut line [680]
dbg: [ai] [1] [S] 
dbg: [ai] [1] [S] [tile] 184512
dbg: [ai] [1] [S] [tiles] INSTANCE
dbg: [ai] [1] [S] [rail_type] 1
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [new_type] 1
dbg: [ai] [1] [S] [rail_type_list] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [@ITERATOR@] 1
dbg: [ai] [1] [S] [route] INSTANCE
dbg: [ai] [1] [S] [@INDEX@] 0
dbg: [ai] [1] [S] [need_money] false
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [ret2] false
dbg: [ai] [1] [S] [ret1] false
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] [1] [S] [last_type] 1
dbg: [ai] [1] [S] [build_road_route] 3
dbg: [ai] [1] [S] [build_busses] false
dbg: [ai] [1] [S] [start_tick] 5
dbg: [ai] [1] [S] [group_list] INSTANCE
dbg: [ai] [1] [S] [this] INSTANCE
dbg: [ai] The AI died unexpectedly.

Brumi
President
President
Posts: 903
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi » 27 May 2011 15:58

I got a similar crash to Zuu's and planetmaker's crash, only the line number in stationmanager.nut is different.
I'm playing OpenTTD without patches, with the Generic Tram Set and the Temperate Oil Wells Only Decrease Neutraliser as the only NewGRFs. I have a savegame before the crash as well, but quite a long time has passed since then...
Attachments
AdmiralAI crash.png
AdmiralAI crash.png (25.05 KiB) Viewed 5237 times
AI testing.sav
(647.86 KiB) Downloaded 105 times

WhirrledPeas
Engineer
Engineer
Posts: 2
Joined: 27 Feb 2009 16:57

Admiral AI crash report

Post by WhirrledPeas » 15 Jun 2011 00:19

Admiral AI consistently crashes in the current game.

I am attempting to attach screen shots of two error messages but I'm not very tech savvy so please excuse any error.
Attachments
AICrashCapture.JPG
(80.3 KiB) Downloaded 1 time
AdmiralAI.JPG
AdmiralAI.JPG (72.96 KiB) Viewed 5137 times

WhirrledPeas
Engineer
Engineer
Posts: 2
Joined: 27 Feb 2009 16:57

Re: Admiral AI crash report

Post by WhirrledPeas » 15 Jun 2011 00:20

Here is the other promised screen shot.

Thanks for any guidance you may offer.
Attachments
AdmiralAI.JPG
Alternate screen shot of error report
AdmiralAI.JPG (72.96 KiB) Viewed 5136 times

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9276
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker » 15 Jun 2011 00:27

The savegame itself might be sometimes interesting, though the screenshots you provided often go a loong way :-)

Please attach bug reports with a specific AI to its respective thread, e.g.. this one in the case of Admiral AI ;-)

HUgo8745
Engineer
Engineer
Posts: 29
Joined: 11 Feb 2010 20:05

Re: AdmiralAI v25

Post by HUgo8745 » 23 Jun 2011 20:38

AdmiralAI crashed when electric rails was introduced.
Attachments
Nardingstone Bay Transport, 8th May 1966.png
(308.33 KiB) Downloaded 1 time

Brumi
President
President
Posts: 903
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi » 24 Jun 2011 11:54

I took the liberty and tried to fix the bug in ConvertRailType. The problem is that after loading from a savegame, the _platform_length field of the StationManager instances remain uninitialised. So I inserted an AfterLoadSetPlatformLength function into the StationManager class, which is a slightly modified version of SimpleAI's GetRailStationPlatformLength. It took me quite a while to realise that you don't even use the Save() and Load() functions of StationManager :)
Here are the diffs: (these are my first diff files ever made, so they may be wrong :) )
stationmanager.diff
(1.29 KiB) Downloaded 124 times
trainmanager.diff
(839 Bytes) Downloaded 111 times
Is the fix OK?

By the way, your SVN repository at http://noai.openttd.org/svn/ai-admiralai/ doesn't seem to work, it's giving me error 502 (Bad gateway).

User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2365
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: AdmiralAI v25

Post by Lord Aro » 24 Jun 2011 15:05

The NoAI SVN has been down for ages. Most AI in active development have moved to openttdcoop

Also i think (not sure) Yexo may have already fixed the bug, just never bothered to release a fixed version
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra

Brumi
President
President
Posts: 903
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi » 24 Jun 2011 16:09

Hmm... I realised that there is a new version just one page back after I posted my diffs :)

It seems to me that this particular bug has been fixed, but there is a typo in the code where it loads pre-v26 savegames. Loading this savegame fails:
Attachments
crash this.sav
(373.38 KiB) Downloaded 104 times

Hephi
Engineer
Engineer
Posts: 69
Joined: 25 Oct 2009 09:56
Location: Belgium

Re: AdmiralAI v25

Post by Hephi » 28 Jul 2011 10:43

It seems to have problems finding the second rail outgoing of this station and so it gave up and started building a new route (the station at the bottom of the screenshot).

Immediately after it had the same problem although if pathfinder would have looked a bit harder it might have found a possible route.
Attachments
admiral.png
unfinished route
(235.9 KiB) Downloaded 1 time
admiral2.png
immediately after
(887.57 KiB) Downloaded 1 time
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AdmiralAI v25

Post by Kogut » 25 Oct 2011 21:43

Small suggestion, in function TownManager::ImproveTownRating

Code: Select all

		foreach (tile, dummy in list) {
			AITile.PlantTree(tile);
		}
		/* Check whether the current rating is good enough. */
		if (AITown.GetRating(town_id, AICompany.COMPANY_SELF) >= min_rating) return true;
may be replaced with

Code: Select all

		foreach (tile, dummy in list) {
			AITile.PlantTree(tile);
			/* Check whether the current rating is good enough. */
			if (AITown.GetRating(town_id, AICompany.COMPANY_SELF) >= min_rating) return true;
		}
or even entire loop may be modified

Code: Select all

	for (local size = 3; size <= 1000; size++) {
		local list = AITileList();
		SafeAddRectangle(list, location, size);
		list.Valuate(AITile.IsBuildable);
		list.KeepValue(1);
		/* Don't build trees on tiles that already have trees, as this doesn't
		 * give any town rating improvement. */
		list.Valuate(AITile.HasTreeOnTile);
		list.KeepValue(0);
		foreach (tile, dummy in list) {
			if(AITile.GetClosestTown(tile) != town_id)return false;
			AITile.PlantTree(tile);
			/* Check whether the current rating is good enough. */
			if (AITown.GetRating(town_id, AICompany.COMPANY_SELF) >= min_rating) return true;
		}
	}
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Re: AdmiralAI v25

Post by Moriarty » 29 Jan 2012 21:51

I had it crash out of the blue:
Attachments
Clipboard01.jpg
Clipboard01.jpg (68.53 KiB) Viewed 4272 times

Brumi
President
President
Posts: 903
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi » 30 Jan 2012 10:21

There is a newer version posted on the previous page (link), which AFAIK doesn't have this bug. Loading the savegame may be a problem, but it's only a typo in the code, so you should be able to fix it.

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: doikdi and 4 guests