RoadRunner AI

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

Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Hi,
today it's time for version 3 of RoadRunner. The main improvement is, that it is building much faster now. It prefers bus services more now, because I think it has the best money income with it.
I will work on it this week, so maybe it is be updated soon again. One thing I'm planing to do is an optional german log output.
If you find bugs, feel free to report here. Thanks.
Attachments
RoadRunner.4.tar
RoadRunner - A road-only AI
(330 KiB) Downloaded 225 times
Last edited by Steffl on 12 Sep 2010 07:03, edited 1 time in total.
Samu
Traffic Manager
Traffic Manager
Posts: 236
Joined: 17 Apr 2007 14:28

Re: RoadRunner AI

Post by Samu »

Hi, I think I have found this problem relevant.
Attachments
Wrindinghall Transport, 15th Feb 1951.png
Wrindinghall Transport, 15th Feb 1951.png (92.41 KiB) Viewed 7321 times
Wrindinghall Transport, 15th Feb 1951#1.png
Wrindinghall Transport, 15th Feb 1951#1.png (81.41 KiB) Viewed 7321 times
Wrindinghall Transport, 2nd Jun 1951.png
Wrindinghall Transport, 2nd Jun 1951.png (112.62 KiB) Viewed 7320 times
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: RoadRunner AI

Post by Zutty »

Cool, someone forked my AI!

Nice job Steffl :)
PathZilla - A networking AI - Now with tram support.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: RoadRunner AI

Post by Kogut »

crash
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (34.93 KiB) Viewed 1049 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

I worked again on my RoadRunner AI. There are not so many big changes in gameplay this time. But I improved the log output. It can now optionally print log messages in german and one time in a year it prints the income of all vehicle groups, to see which one earns the most money.

Thanks to Samu and Kogut for bug reports. I hope I fixed this bugs now.

@Zutty:
Nice to hear, that you like my work. :-) If you want to improve PathZilla for yourself, feel free to take anything you can use from my code. (That's the minimum, after I used your whole AI as base for mine. :-) )

Edit: little bugfix
Attachments
RoadRunner.3.tar
RoadRunner - version 3 beta
(330 KiB) Downloaded 213 times
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Hi together,

it's time for a version 4 of RoadRunner AI today.
I haven't had much time the last weeks, but I did some fine adjustment of some variables. Also I completely rewrote depot finding algorithm. It shouldn't make problems any more.

Now you can download this AI over the Online Content button in OpenTTD. I hope I didn't make any mistake when I uploaded it to bananas.

I think I will rest with the further development of RoadRunner in the next time. But feel free to post bugs and all you want to say here in this topic.
Attachments
RoadRunner.4.tar
RoadRunner Version 4
(330 KiB) Downloaded 222 times
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Hi together,

here is version 5 of RoadRunner AI.
There were some bugs with saving and loading, sometimes the AI only build mail and passenger services after loading. But I'm not sure if it works now 100% fail safe.
I didn't really understand the code, but in my tests it always worked now.
Also the intern system of choosing new services was buggy. Passenger services were much underrated.

I added a new option, were you can select, if the AI should transport more passengers and mail or more industrial cargo.

If you find any bugs, feel free to post it here. Thanks and have much fun. :-)
_________________________________________________________________________________________________________________________________________

I already tried to upload it to bananas, but it didnt work. I got an "unexpected error". I don't know what I did wrong.
Can maybe someone who has more experience than me have a look at the file? Thanks.

Edit: The uploaded file didn't work when I tested it. Sorry, but please download it again.
Attachments
RoadRunner.5.tar
RoadRunner - Version 5
(330 KiB) Downloaded 214 times
Last edited by Steffl on 14 Nov 2010 16:07, edited 1 time in total.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: RoadRunner AI

Post by Kogut »

Steffl wrote:I already tried to upload it to bananas, but it didnt work. I got an "unexpected error". I don't know what I did wrong.
Can maybe someone who has more experience than me have a look at the file? Thanks.
It is http://bugs.openttd.org/task/3252 .
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Ah, I see. I'm not the only one with this problem. Thanks Kogut.
I will try to upload my AI tomorrow again, maybe it works then.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: RoadRunner AI

Post by Kogut »

Steffl wrote:Ah, I see. I'm not the only one with this problem. Thanks Kogut.
I will try to upload my AI tomorrow again, maybe it works then.
Or upload from no-Linux system.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: RoadRunner AI

Post by Rubidium »

The problem, for roadrunner at least, is a small bug in the code that checks the whole thing. It should now work okay with the tar you've already posted on the forum.
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

It worked. Kogut, you are my hero. :D
I usually use Ubuntu, but now i used an Internet Explorer emulator and it worked. :-)
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Rubidium wrote:The problem, for roadrunner at least, is a small bug in the code that checks the whole thing. It should now work okay with the tar you've already posted on the forum.
Hi Rubidium.
I tried it sometimes to upload it to bananas and I'm quite sure that there was no error in my AI.
But then I changed something in the info.nut, because I thought it could be the reason that I cannot upload it to bananas. I must have made a mistake here, and then I uploaded this bad file here to the forum.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: RoadRunner AI

Post by Rubidium »

Steffl wrote:I tried it sometimes to upload it to bananas and I'm quite sure that there was no error in my AI.
Where did I imply that there was something wrong with your AI? There was something wrong with the code that validates whether you were uploading an AI to bananas. Saying that the validation was wrong when your AI fails to upload implies that your AI is correct.

That changing the browser solved the problem for you as well is more because I fixed the validation at the webserver's side than it had to do with the browser (or operating system) you are uploading with.
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Sorry, I didn't read your post carefully. I read something with a bug and thought, you meant a bug in the AI.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: RoadRunner AI

Post by Rubidium »

This AI has an infinite loop in its save procedure. See https://secure.openttd.org/bugs/task/4260 for a test case.
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Hi, I found the reason for the infinite loop in the save code.
The AI has an self defined array type, where values are saved as key and data.
Now, if the same key is two times in the array, a foreach loop will never stop. It take same time for me to find this bug because I always thought a foreach loop will be fail safe. But now I know better. Thank you Rubidium for telling me this and thank you to the one, who reported the bug.
Attachments
RoadRunner-6.tar
RoadRunner Version 6
bugfix for version 5
(330 KiB) Downloaded 219 times
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: RoadRunner AI

Post by Zuu »

How can an associative array have more than one key that is equal?
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: RoadRunner AI

Post by Steffl »

Hmm, I explained it to me that this was the reason for the bug. I will show you the code, where the bug happens. Maybe my explanation is wrong:


The function which returns the next variable in foreach loop:

Code: Select all

/*
 * Get the next index in the map. This is used by the squirrel foreach keyword.
 * This uses an array of keys to specify sorted order and is guaranteed to be
 * stable.
 */
function Map::_nexti(prevkey) {
	if(prevkey == null){
	this.RebuildKeys();// THIS LINE IS ADDED IN VERSION 6. WITHOUT THIS SAVING CAN FAIL SOMETIMES
	return (this.keys.len() == 0) ? null : this.keys[0];
}
	local idx = ::arrayfind(this.keys, prevkey);
	if(idx == this.keys.len() - 1) return null;
	return this.keys[idx + 1]
}

Here is, what the added function does:

Code: Select all

/*
 * Rebuild the list of keys to match those in the main table.
 */
function Map::RebuildKeys() {
	this.keys = [];
	foreach(key, _ in this.data) {
		this.keys.append(key);
	}
}

You can find a buggy savegame when you follow Rubidium's link, if you want to test for yourself.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: RoadRunner AI

Post by Zuu »

I see from the first code-snippet you posted why it can be a problem if there are two or more array entries with the same key. However, I though the idea of associative arrays was that you can only have one item with the same key. But apparently there is some way to add two items with the same key to an AIList.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 10 guests