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

shadowman131
Engineer
Engineer
Posts: 1
Joined: 25 Dec 2009 08:58

Re: AdmiralAI v22

Post by shadowman131 »

Hey, had a bug in V1.0.0-beta1. Admiral would never finish building trains or road vehicles - only airplanes.

Not sure if it's the right fix, but I patched my version by changing all code blocks for train / road that looked like this:

Code: Select all

		if (!AIVehicle.RefitVehicle(v, this._cargo)) {
			local cash_shortage = AIError.GetLastError() == AIError.ERR_NOT_ENOUGH_CASH;
			AIVehicle.SellVehicle(v);
			return !cash_shortage;
		}
to

Code: Select all


		if (!AIVehicle.RefitVehicle(v, this._cargo)) {
			local cash_shortage = AIError.GetLastError() == AIError.ERR_NOT_ENOUGH_CASH;
			if (cash_shortage) {
				AIVehicle.SellVehicle(v);
				return !cash_shortage;
			}
		}
Thought I'd let you know. Thanks for making a good AI :)
Xodion
Engineer
Engineer
Posts: 5
Joined: 30 Dec 2009 14:27
Location: Leeds, UK

Re: AdmiralAI v22

Post by Xodion »

Hey Yexo, well done on making a very impressive AI. I've only been playing TTD for a few years and the pathetic AI annoyed me so much, it made the game too easy without competition (and I'm not good enough to play online multiplayer :( ). Downloaded OpenTTD last week and set up NoAI with a handful of the AIs I've seen on here, and after a few game years AdmiralAI was beating me by an embarrasingly large margin :oops: . I've only seen it make a few pathfinding mistakes so far (mostly with large open water between the stations), and as a programmer I can appreciate just how difficult it is writing something like this.

CluelessPlus and NoCAB seemed to do pretty well too, although with less variety, and poor PAXlink had a hard time - the 3 largest cities were in the middle, right next to each other, so it was flying between 3 large airports 6-8 tiles apart! Still, it's all very impressive, and I've started another game with a bigger map to give them more chance to flourish (and less likely to block me in! :P ).

Any advice for a beginner AI dev? I'm new to Squirrel but I have some experience with languages, like C++ & Python, and I have made some very basic flash game AIs but not for anything as complicated as TTD.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: AdmiralAI v22

Post by Zuu »

Thanks for your comments on some of the AIs. Im the author of CluelessPlus and PAXLink, and indeed PAXLink is and will probably never be a top performing AI. One-leg transport is much easier to manage and nowadays you can use distant join to get good coverage of a city without using feeders, but at least PAXLink is fairly unique.

To get started I suggest the AI section of the wiki. To get information about how to do specific things or to get general ideas you could untar an AI that you have downloaded and read the source of it. The API doc is also a very important resource.

If you get problems that you can not resolve you can use this forum or join #openttd and/or #openttd.noai on the irc.oftc.net IRC server.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Grolandi
Engineer
Engineer
Posts: 6
Joined: 07 Sep 2004 17:52

Re: AdmiralAI v22

Post by Grolandi »

shadowman131 wrote:Hey, had a bug in V1.0.0-beta1. Admiral would never finish building trains or road vehicles - only airplanes.

Not sure if it's the right fix, but I patched my version by changing all code blocks for train / road that looked like this:

Code: Select all

		if (!AIVehicle.RefitVehicle(v, this._cargo)) {
			local cash_shortage = AIError.GetLastError() == AIError.ERR_NOT_ENOUGH_CASH;
			AIVehicle.SellVehicle(v);
			return !cash_shortage;
		}
to

Code: Select all


		if (!AIVehicle.RefitVehicle(v, this._cargo)) {
			local cash_shortage = AIError.GetLastError() == AIError.ERR_NOT_ENOUGH_CASH;
			if (cash_shortage) {
				AIVehicle.SellVehicle(v);
				return !cash_shortage;
			}
		}
Thought I'd let you know. Thanks for making a good AI :)
I'm seeing the same problem with Admiral AI and version 1.0.0 beta 1. I'll give your changes a try. Thanks for posting!
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AdmiralAI v22

Post by Yexo »

shadowman131 wrote:Hey, had a bug in V1.0.0-beta1. Admiral would never finish building trains or road vehicles - only airplanes.

Not sure if it's the right fix, but I patched my version by changing all code blocks for train / road that looked like this:
Grolandi wrote:I'm seeing the same problem with Admiral AI and version 1.0.0 beta 1. I'll give your changes a try. Thanks for posting!
Thanks both for reporting the problem, can either of you upload a savegame where this happens?

@shadowman: I don't think that fix is correct, but I'll look into it soon.
Grolandi
Engineer
Engineer
Posts: 6
Joined: 07 Sep 2004 17:52

Re: AdmiralAI v22

Post by Grolandi »

Yexo wrote:
shadowman131 wrote:Hey, had a bug in V1.0.0-beta1. Admiral would never finish building trains or road vehicles - only airplanes.

Not sure if it's the right fix, but I patched my version by changing all code blocks for train / road that looked like this:
Grolandi wrote:I'm seeing the same problem with Admiral AI and version 1.0.0 beta 1. I'll give your changes a try. Thanks for posting!
Thanks both for reporting the problem, can either of you upload a savegame where this happens?

@shadowman: I don't think that fix is correct, but I'll look into it soon.
Here you go. No comments about my workmanship, or lack of. :))
Attachments
Slenfingway Transport, 21st Dec 1946.sav
(139.26 KiB) Downloaded 137 times
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AdmiralAI v22

Post by Yexo »

Thansk Grolandi :).

I've confirmed the problem, it's because of a change in how OpenTTD handles refits. I'm waiting with a fix on a discussion on how openttd should handle this case, but it'll certainly be fixed before openttd 1.0.0 final is out. shadowman131's change works but I'm not really happy with that solution.
Grolandi
Engineer
Engineer
Posts: 6
Joined: 07 Sep 2004 17:52

Re: AdmiralAI v22

Post by Grolandi »

Yexo wrote:Thansk Grolandi :).

I've confirmed the problem, it's because of a change in how OpenTTD handles refits. I'm waiting with a fix on a discussion on how openttd should handle this case, but it'll certainly be fixed before openttd 1.0.0 final is out. shadowman131's change works but I'm not really happy with that solution.
You're welcome. Glad the problem was so easy to find and a fix sounds easy to provide. Thanks too for your work on this project!
Grolandi
Engineer
Engineer
Posts: 6
Joined: 07 Sep 2004 17:52

Re: AdmiralAI v22

Post by Grolandi »

Just wanted to note that shadowman's fix does indeed fix the problem, in case anyone else is looking for a quick solution.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AdmiralAI v22

Post by Yexo »

I thought I had posted this yesterday, but apparently not. Updating OpenTTD to r18724 (or 1.0.0-beta2 when it becomes available) will fix the problem without changing any of AdmiralAIs files.
User avatar
luk3Z
Traffic Manager
Traffic Manager
Posts: 197
Joined: 25 Dec 2005 17:42
Location: Kielce, Poland (Mars sometimes)

Re: AdmiralAI v22

Post by luk3Z »

version: r18724
year: 1840
max loan: 1 000 000

AdmiralAI bankrupt [sic!] on the hard difficulty (1 train and 20 cars) + Modified Building Costs grf :cry:
Choochoo failed and show some errors...
Main problem: AI (probaly all AIs) don't handle well the game when we using Modified Building Costs grf and hard difficulty.
Find new graphics easier:
GRFCrawler -> http://grfcrawler.tt-forums.net
BaNaNaS -> https://bananas.openttd.org/
32 bit gfx in OTTD (32bpp) -> https://wiki.openttd.org/en/Community/N ... 20graphics
TTDPatch 2.6 -> viewtopic.php?f=19&t=67694
How to subtract tax from income (workaround) -> viewtopic.php?t=89763&start=20
How to ban distance from income -> Simple Cargo Decay Override
Grolandi
Engineer
Engineer
Posts: 6
Joined: 07 Sep 2004 17:52

Re: AdmiralAI v22

Post by Grolandi »

Yexo wrote:I thought I had posted this yesterday, but apparently not. Updating OpenTTD to r18724 (or 1.0.0-beta2 when it becomes available) will fix the problem without changing any of AdmiralAIs files.
I downloaded beta 2 today and reinstalled AdmiralAI, and all seems well.

Thank you!
djlazy
Engineer
Engineer
Posts: 23
Joined: 12 Jan 2010 23:09

Re: AdmiralAI v22

Post by djlazy »

Hi

My version of the al keeps on crashing. I have jsut installed the beta of open ttd and it went mental! it crashed 2 in about 10 seconds. Before i had the lastest version and it was crashing every so often unfortaly i have upgraded now so i would have to downgraound to go abck, but here are the screen soots from the lastest beta
Attachments
kickass transport, 11th Feb 2093.png
kickass transport, 11th Feb 2093.png (69.04 KiB) Viewed 4559 times
kickass transport, 22nd Feb 2093.png
kickass transport, 22nd Feb 2093.png (81.83 KiB) Viewed 4559 times
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: AdmiralAI v22

Post by petert »

Hi djlazy,
Like I said, you need to post the error lines at the end of the lines. See this screenshot for a very good example:
http://www.tt-forums.net/download/file.php?id=118673
"...main.nut line [1043]"
"...main.nut line [191]"
User avatar
mrMann
Tycoon
Tycoon
Posts: 2793
Joined: 27 Oct 2006 20:38
Location: A house.
Contact:

Re: AdmiralAI v22

Post by mrMann »

Surely updating to v22 of AdmiralAI would help?
Hmm, what should I put here...
djlazy
Engineer
Engineer
Posts: 23
Joined: 12 Jan 2010 23:09

Re: AdmiralAI v22

Post by djlazy »

petert wrote:Hi djlazy,
Like I said, you need to post the error lines at the end of the lines. See this screenshot for a very good example:
http://www.tt-forums.net/download/file.php?id=118673
"...main.nut line [1043]"
"...main.nut line [191]"
ok i think i get what you mean, i will try that, and yea maybe if i update it will sort it out, i will try that thanks
cyragon
Engineer
Engineer
Posts: 1
Joined: 16 Jan 2010 02:50

Re: AdmiralAI v22

Post by cyragon »

Good AI from what I've seen so far, but I found a bug.

One of the train routes failed to fully connect to the existing tracks, and it tried to put trains on the route anyway.

Keep up the good work!
Attachments
Screenshot showing the trapped trains.
Screenshot showing the trapped trains.
Ledingville Transport, 5th May 1959.sav
Saved game
(1.3 MiB) Downloaded 121 times
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AdmiralAI v22

Post by Yexo »

The blue company in that savegame is ChooChoo, not AdmiralAI.
User avatar
mrMann
Tycoon
Tycoon
Posts: 2793
Joined: 27 Oct 2006 20:38
Location: A house.
Contact:

Re: AdmiralAI v22

Post by mrMann »

Didn't think it looked like AdmiralAI. ;)
Hmm, what should I put here...
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: AdmiralAI v22

Post by Wasila »

My AdmiralAI is addicted to building stations...
Attachments
Global Connections, 1st Jul 2000.png
Global Connections, 1st Jul 2000#1.png
Global Connections, 1st Jul 2000#2.png
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 19 guests