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 »

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 »

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: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker »

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
Unnamed, 2021-01-05.png (79.35 KiB) Viewed 7121 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AdmiralAI v25

Post by Kogut »

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 »

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
Hinwood Transport, 10th Jul 1970.png (22.07 KiB) Viewed 7121 times
Me and AI.sav
(518.09 KiB) Downloaded 221 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: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker »

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 217 times
ogfx-industries.zip
required industries newgrf
(16.11 KiB) Downloaded 217 times
Yisc
Engineer
Engineer
Posts: 55
Joined: 09 Apr 2004 21:14
Location: Leiden
Contact:

Re: AdmiralAI v25

Post by Yisc »

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: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker »

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: 920
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi »

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 15232 times
AI testing.sav
(647.86 KiB) Downloaded 212 times
WhirrledPeas
Engineer
Engineer
Posts: 2
Joined: 27 Feb 2009 16:57

Admiral AI crash report

Post by WhirrledPeas »

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
AICrashCapture.JPG (80.3 KiB) Viewed 7121 times
AdmiralAI.JPG
AdmiralAI.JPG (72.96 KiB) Viewed 15132 times
WhirrledPeas
Engineer
Engineer
Posts: 2
Joined: 27 Feb 2009 16:57

Re: Admiral AI crash report

Post by WhirrledPeas »

Here is the other promised screen shot.

Thanks for any guidance you may offer.
Attachments
Alternate screen shot of error report
Alternate screen shot of error report
AdmiralAI.JPG (72.96 KiB) Viewed 15131 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AdmiralAI v25

Post by planetmaker »

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 »

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: 920
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi »

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 235 times
trainmanager.diff
(839 Bytes) Downloaded 225 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: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: AdmiralAI v25

Post by Lord Aro »

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: 920
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi »

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 209 times
Hephi
Engineer
Engineer
Posts: 72
Joined: 25 Oct 2009 09:56
Location: Belgium

Re: AdmiralAI v25

Post by Hephi »

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
unfinished route
unfinished route
admiral.png (235.9 KiB) Viewed 7121 times
immediately after
immediately after
admiral2.png (887.57 KiB) Viewed 7121 times
--------------------------------------------------
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 »

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 »

I had it crash out of the blue:
Attachments
Clipboard01.jpg
Clipboard01.jpg (68.53 KiB) Viewed 14267 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: AdmiralAI v25

Post by Brumi »

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: No registered users and 4 guests