Page 2 of 4

Re: RoadRunner AI

Posted: 27 Jun 2010 09:50
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.

Re: RoadRunner AI

Posted: 29 Jun 2010 23:48
by Samu
Hi, I think I have found this problem relevant.

Re: RoadRunner AI

Posted: 01 Jul 2010 13:19
by Zutty
Cool, someone forked my AI!

Nice job Steffl :)

Re: RoadRunner AI

Posted: 04 Jul 2010 11:55
by Kogut
crash

Re: RoadRunner AI

Posted: 04 Jul 2010 16:51
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

Re: RoadRunner AI

Posted: 12 Sep 2010 07:22
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 15:30
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 15:41
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 .

Re: RoadRunner AI

Posted: 14 Nov 2010 15:50
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 16:04
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 16:19
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 16:20
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. :-)

Re: RoadRunner AI

Posted: 14 Nov 2010 16:28
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 16:57
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.

Re: RoadRunner AI

Posted: 14 Nov 2010 17:29
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.

Re: RoadRunner AI

Posted: 24 Nov 2010 11:52
by Rubidium
This AI has an infinite loop in its save procedure. See https://secure.openttd.org/bugs/task/4260 for a test case.

Re: RoadRunner AI

Posted: 27 Nov 2010 07:39
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.

Re: RoadRunner AI

Posted: 27 Nov 2010 10:55
by Zuu
How can an associative array have more than one key that is equal?

Re: RoadRunner AI

Posted: 27 Nov 2010 18:48
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.

Re: RoadRunner AI

Posted: 27 Nov 2010 21:56
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.