Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Nov 23, 2017 7:31 am

All times are UTC




Post new topic  Reply to topic  [ 104 posts ]  Go to page 1 2 3 4 5 6 Next
Author Message
PostPosted: Fri May 23, 2008 10:23 pm 
Offline
President
President
User avatar

Joined: Sun Jun 03, 2007 10:22 pm
Posts: 950
TrueLight wrote:
[
Now show us your AI and let us enjoy the moment too :)


OK, here it is: Convoy (the bus loving AI)

Features:
-Uses buses only
-Pathfinding is 'curvy', straight roads would be better performancewise, but I don't like having only straight roads
-Completely written in Squirrel, no patches

Installation:
-Compatible with r13219 (thanks for solving the passenger class problem)
-Since this week it is possible to use the tarloader to load the AI, so installation is extremely easy:
copy the tar to the bin/ai directory ( no need to untar ). Ready!
-Start openttd.
-To set up a battle load a scenario, or a new game ( if you're battling with Wright, choose a very flat map )
-Press the ` key (left of 1), and enter start_ai WrightAI <enter>, start_ai Convoy <enter>
-Press the ` again to close the console

Have fun !


I've chosen an iterative approach: first create a working AI that is playable, although many parts are not optimal.
So there's a rather long todo list still, but the AI should already be nice to compete against.

ToDo:
-Improve pathfinder: A* is not completely implemented, shorter routes on the openlist are disregarded
-Improve pathfinding on slopes, sometimes connections on slopes are failing
-Improve town coverage, only one station per town is build, add intratown lines
-Optimize time performance
-Line building: currently only unused towns are connected, which is ok for the first few years, but after that, no unused towns can be found, and connections between lines must be added
- more comments, use some requires
-etc etc

Goals:
-My goal is not to create the best performing AI financially (I'm not taking part in any challenge), but to create an AI that human players like to play against. So remarks about the gameplay are welcome.
-Second goal: To improve my Object Oriention skills. I am pretty experienced in plain C programming, but in OO programming I consider myself a novice. So any comments on how to improve the OO design would be highly appreciated, I might learn a thing or two. And the best way to learn is to start doing it.

Licence:
Don't know much about that, GNU GPL is fine I think. Meaning: feel free to use or modify any of my code ( a link would be nice ), or better, improve and republish it. I think it is be possible to create a nice AI by the OTTD community, using the best open source practices.
I thank TrueLight and Zuu: I re-used some functions of Wright and Clueless ( if that's a problem, I'll rewrite them, and yeah, I know, I should have asked beforehand :mrgreen: )

The last version is available here: viewtopic.php?p=764906#p764906 , don't use the ones below anymore, they're obsolete because of API changes

Train support test version: viewtopic.php?p=787094#p787094


Attachments:
File comment: Convoy v1.1
Convoy.tar [40 KiB]
Downloaded 2895 times
Convoy.tar [30 KiB]
Downloaded 915 times


Last edited by GeekToo on Tue May 05, 2009 7:30 pm, edited 19 times in total.
Top
   
PostPosted: Sat May 24, 2008 1:09 pm 
Offline
Director
Director

Joined: Fri Jan 05, 2007 3:50 pm
Posts: 611
Location: Poland
GeekToo wrote:
TrueLight wrote:
[
Now show us your AI and let us enjoy the moment too :)


OK, here it is: Convoy (the bus loving AI)



Performs quite well actually.
It does have a tendency to buy too much buses per line. It seems that it buys as much of them, as it is necessary to transport expected passengers available. It doesn't take into account, that bus stations have limited throughput. It results in bus queues ob both ends of line, which isn't very economical i suppose.

And I got one SQ error so far:

NoAI wrote:
dbg: [ai] [3] [S] Your script made an error: the index '0' does not exist
dbg: [ai] [3] [S]
dbg: [ai] [3] [S] *FUNCTION [ManageVehicles()] convoy/main.nut line [977]
dbg: [ai] [3] [S] *FUNCTION [Start()] convoy/main.nut line [866]
dbg: [ai] [3] [S]
dbg: [ai] [3] [S] [@ITERATOR@] 17
dbg: [ai] [3] [S] [line_it] INSTANCE
dbg: [ai] [3] [S] [@INDEX@] 16
dbg: [ai] [3] [S] [this] INSTANCE
dbg: [ai] [3] [S] [i] 31200
dbg: [ai] [3] [S] [list] INSTANCE
dbg: [ai] [3] [S] [this] INSTANCE


--edit--
And another one (same game)
NoAI wrote:
dbg: [ai] [4] [S] Your script made an error: the index '0' does not exist
dbg: [ai] [4] [S]
dbg: [ai] [4] [S] *FUNCTION [ManageVehicles()] convoy/main.nut line [977]
dbg: [ai] [4] [S] *FUNCTION [Start()] convoy/main.nut line [866]
dbg: [ai] [4] [S]
dbg: [ai] [4] [S] [@ITERATOR@] 16
dbg: [ai] [4] [S] [line_it] INSTANCE
dbg: [ai] [4] [S] [@INDEX@] 15
dbg: [ai] [4] [S] [this] INSTANCE
dbg: [ai] [4] [S] [i] 25600
dbg: [ai] [4] [S] [list] INSTANCE
dbg: [ai] [4] [S] [this] INSTANCE


In both cases it was after '[INFO] Extra buses needed'


Top
   
PostPosted: Sat May 24, 2008 9:04 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4532
Location: /home/sweden
GeekToo wrote:
I thank TrueLight and Zuu: I re-used some functions of Wright and Clueless ( if that's a problem, I'll rewrite them, and yeah, I know, I should have asked beforehand :mrgreen: )


Sure, use what you find usefull. Glad you found use for some of the code I written. Even if some parts of it is rather outdated, as it was written about a year ago except for being brought up date to the extent that it runs a few times. The ManageLoan function looks familiar, do you remember any other parts you've used?


So actually its time to say happy birthday to NoAI. This thread was started 13 March last year. But then Truelight, Rubidium and possible some more of the devs have spent time on NoAI before it was announced. But I say happy late birth day NoAI :bow: :D

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sun May 25, 2008 12:06 am 
Offline
President
President
User avatar

Joined: Sun Jun 03, 2007 10:22 pm
Posts: 950
Finaldeath wrote:
It just for some reason only used 3 of it's built routes and swarmed them with buses, which is a bit odd, when it had 100,000 in the bank (with still a 510,000 loan that is)


I changed the code, so half the amount of buses will go to one town, and the other half go to the other. About the issue that lines are not used, a savegame or scenario would be nice.


Mchl wrote:

Performs quite well actually.

Thanks

Mchl wrote:
It does have a tendency to buy too much buses per line. It seems that it buys as much of them, as it is necessary to transport expected passengers available. It doesn't take into account, that bus stations have limited throughput. It results in bus queues ob both ends of line, which isn't very economical i suppose.

Like I said above, I've now changed the code, so buses will be sent to both towns. The queuing is alright I guess, as long as the complete road is not filled, the buses do queue the first time, but once all buses have completed their route, the distance they keep is optimal.

Mchl wrote:
dbg: [ai] [3] [S] Your script made an error: the index '0' does not exist
dbg: [ai] [3] [S]
dbg: [ai] [3] [S] *FUNCTION [ManageVehicles()] convoy/main.nut line [977]


Thanks for the feedback, it was a bug, I've solved it. I'll post an update soon.

Roujin wrote:
One thing I noticed is that the AI does not correct its errors.. e.g. if some connection on a slope failed, or it was interrupted by some other player (I tried that on purpose :P)

It just plans its route from A to B, once it found a nice plan, starts to build it, but doesn't check if it actually succeeds at building it. So if you e.g. buy a piece of land somewhere on the route the AI planned, it will build the whole route, minus that tile, then build its buses and so on..

In my opinion it should after finishing building, and from time to time make a check if its route is still connected.


You're right, it's not very fault tolerant at the moment. I spent this night on improving that. Should be better on the next update.
BTW, thanks for updating the wiki, nice template, and I was pleasantly surprised to see Convoy there half a day after publishing.

Zuu wrote:
The ManageLoan function looks familiar, do you remember any other parts you've used?

Actually I don't. But I did remember that when I entered this project, and started programming my AI, about half a year ago, Clueless and Wright were the only AI's around, and I studied them, and learned a lot from them. Then I did a patch for the extra zoom level graphics, and did leave my AI for a while. But recently I picked it up again, that's why I don't remember exactly. But, even if my code does not contain much Clueless code any more, the 'thank you' is well deserved, cause it was one of my inspiration sources :) .


Top
   
PostPosted: Sun May 25, 2008 7:42 am 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
GeekToo wrote:
[...]BTW, thanks for updating the wiki, nice template, and I was pleasantly surprised to see Convoy there half a day after publishing.
[...]


Sure, feel free to add any information :) Actually after downloading your AI, I wanted to download more (that is, all AIs that have been made up until now) and watch them compete. So I started going back in this thread, but got fed up after some pages.. then I thought there should be a place where all released and available AIs are listed.
And the wiki seems the best place for me to do that ;)

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
PostPosted: Sun May 25, 2008 12:57 pm 
Offline
Director
Director

Joined: Fri Jan 05, 2007 3:50 pm
Posts: 611
Location: Poland
GeekToo: I've found you a theme song for Convoy ;)
http://www.youtube.com/watch?v=r-VcU89usjM


Top
   
PostPosted: Sun May 25, 2008 9:41 pm 
Offline
President
President
User avatar

Joined: Sun Jun 03, 2007 10:22 pm
Posts: 950
I've updated Convoy ( download in my previous post: viewtopic.php?p=693171#p693171)

-solved the bug reported by Mchl ( btw nice theme, we should build an AVI player in OTTD :D )
-improved the way buses take their initial route: one half to one station, the others to the other station. This improves the queing
(reported by Mchl and FinalDeath)
-improved the loan management, it continues building when it has money, instead of waiting a couple of hundred ticks
-added some improvements to the pathfinding
-added error handling during pathfinding, so the trick Roujin reported ( buying land, while the AI is building roads, should be solved).
I've not worked on the route checking yet, so football stadiums still are a problem. I have to find a way to solve this elegantly.

Overall, the performance is about 30 percent better, I ran a test against wright, and managed to stay ahead of it at least 3 years (
then I stopped the test)

Thanks for the feedback guys, keep it coming! There's a lot to improve still


Top
   
PostPosted: Sun Jun 08, 2008 11:22 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon May 31, 2004 9:21 am
Posts: 1292
GeekToo wrote:
Quote:
Or anyway, I pressed the Download link on the wiki page, I assumed it pointed to 1.1


Depends on when you pressed it, I updated the link yesterday or friday


Well, I downloaded it a few hours ago, so I had the latest ;)

_________________
The only thing necessary for the triumph of evil is for good men to do nothing.


Top
   
 Post subject: Convoy, a Road AI
PostPosted: Wed Jun 11, 2008 10:29 pm 
Offline
President
President
User avatar

Joined: Sun Jun 03, 2007 10:22 pm
Posts: 950
Update of Convoy:

Recent developments ( especially the different behaviour of IsBuildable ) did make the pathfinding of the previous Convoys pretty useless ( as is: not able to find a route ). I tried integrating the BinHeap of the library, as it was better coded than my version ( that is, being a much more pure Container class), but unfortunately, the performance was a lot worse than in my previous Convoy version. Main reason: the Exists function, which does compare a complete node. Suggestion to the devs: add an id to the Insert parameter list.
So for now, I still use my own BinHeap.

Lots of things have improved since the previous version, and I realise lots of things still have to be done.


Attachments:
Convoy.tar [40 KiB]
Downloaded 243 times
Top
   
PostPosted: Thu Jun 12, 2008 11:21 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon May 31, 2004 9:21 am
Posts: 1292
GeekToo wrote:
Update of Convoy:

(..)

Lots of things have improved since the previous version, and I realise lots of things still have to be done.

I ran it through the tournament system, the results are online .. impressive :) You won from both AviatorAI and WrightAI :)

http://devs.openttd.org/~noai/tournament/

_________________
The only thing necessary for the triumph of evil is for good men to do nothing.


Top
   
PostPosted: Thu Jun 12, 2008 11:43 am 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
Wow! That IS impressive, considering that aircraft are at a natural advantage to buses in OpenTTD. Congratulations GeekToo :D You've set the bar!

Edit: Hey Truelight can we get RalphsAI into the tournament also?

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Sun Jun 15, 2008 11:27 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Mon May 19, 2008 1:11 pm
Posts: 129
I was running Convoy against my bus-based AI, Jinjaba (Jinjaba Is Not Just Another Bus AI) and I was neck-and-neck with Convoy for overall score.

However, despite building significantly less busses, I was much more profitable. As a result, I think you might have too many busses on your routes. See attached.


Attachments:
Unnamed, 3rd Nov 1970.png [42.16 KiB]
Downloaded 303 times
Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 12:09 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon May 31, 2004 9:21 am
Posts: 1292
paullb wrote:
I was running Convoy against my bus-based AI, Jinjaba (Jinjaba Is Not Just Another Bus AI) and I was neck-and-neck with Convoy for overall score.

However, despite building significantly less busses, I was much more profitable. As a result, I think you might have too many busses on your routes. See attached.


Beautiful name for an AI, really :) Very nice ;) Either way, if you want your AI battling in the tournament system, but want to keep your code private, feel free to PM me the code. I will never give out any part of the source without your explicit permission. Might be nice to see how it does against all others :)

_________________
The only thing necessary for the triumph of evil is for good men to do nothing.


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 1:45 pm 
Offline
Engineer
Engineer

Joined: Thu Jun 05, 2008 3:51 pm
Posts: 70
I noticed that Convoy has a peculiar bug. Sometimes if a large and a small* town are close by, and Convoy tries to connect both, then the following can happen:

suppose A is a small town, B is a big town and the distance between them is 13, then Convoy tries to build a bus station in A, but it check all tiles within a square of 30 for highest acceptance (15 tiles in all directions). But the highest acceptance in that square [i]is actually in town B[/b] because it is bigger! So it builds a station in B (while thinking it is building it in A) then tries to connect this new station with the exit point in A, which then fails, and then tries to build a station in B, which also fails because there is already a station too close by.

I noticed this one when I tried to figure out why a certain line couldn't be built. My debug code said that building a station in B had failed, but when I looked at the map, there actually was a station in B, but no station in A. After some pondering I came up with the above explanation, and a suitable fix (valuate the list for potential bus station tiles with IsWithinTownInfuluence of town A)


-------------------
* I modified Convoy a bit for testing, and let it connect two nearby towns without taking into account the populations. But if it did, it would just take longer for the same bug to occur.

_________________
Nunc dimittis servum tuum Domine secundum verbum tuum in pace


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 1:47 pm 
Offline
Engineer
Engineer

Joined: Thu Jun 05, 2008 3:51 pm
Posts: 70
TrueLight wrote:
(..)
Either way, if you want your AI battling in the tournament system, but want to keep your code private, feel free to PM me the code. I will never give out any part of the source without your explicit permission. Might be nice to see how it does against all others :)


You don't happen to participate in the tjip-challenge yourself? :D If I have a rudimentary AI in the next few weeks, I might want to try it in the tournament without giving away its "secrets"

_________________
Nunc dimittis servum tuum Domine secundum verbum tuum in pace


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 1:57 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon May 31, 2004 9:21 am
Posts: 1292
wilco_moerman wrote:
TrueLight wrote:
(..)
Either way, if you want your AI battling in the tournament system, but want to keep your code private, feel free to PM me the code. I will never give out any part of the source without your explicit permission. Might be nice to see how it does against all others :)


You don't happen to participate in the tjip-challenge yourself? :D If I have a rudimentary AI in the next few weeks, I might want to try it in the tournament without giving away its "secrets"


I already stated that in an other topic, both Rubidium and I do not participate in the TJIP challenge, for well, exactly this reason :) So we assure you that your source-code would be kept very private, and never be shared without your approval. Screenshots of the minimap how ever, will be made, so if you don't want to share that info, I guess you are out of luck ;)

Ps: our tournament system in no way represent the system TJIP might be using, so a win on our tournament system doesn't guarantee anything on the TJIP challenge ;) "behaalde resultaten uit het verleden bieden geen garantie voor de toekomst" (sorry of lack of translation :))

_________________
The only thing necessary for the triumph of evil is for good men to do nothing.


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 2:02 pm 
Offline
Engineer
Engineer

Joined: Thu Jun 05, 2008 3:51 pm
Posts: 70
TrueLight wrote:
(..)

I already stated that in an other topic, both Rubidium and I do not participate in the TJIP challenge, for well, exactly this reason :)


must have missed that one.

Quote:
So we assure you that your source-code would be kept very private, and never be shared without your approval. Screenshots of the minimap how ever, will be made, so if you don't want to share that info, I guess you are out of luck ;)


I can't imagine why... but perhaps someone will create an AI which reveals tactical information in the minimap? We will see :)

Quote:
Ps: our tournament system in no way represent the system TJIP might be using, so a win on our tournament system doesn't guarantee anything on the TJIP challenge ;)


but it is good to know at least something about the strength of my AI

Quote:
"behaalde resultaten uit het verleden bieden geen garantie voor de toekomst" (sorry of lack of translation :))


is goed hoor, ik zal er rekening mee houden 8)

_________________
Nunc dimittis servum tuum Domine secundum verbum tuum in pace


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 2:46 pm 
Offline
Engineer
Engineer

Joined: Sat Dec 22, 2007 1:04 am
Posts: 52
wilco_moerman wrote:
After some pondering I came up with the above explanation, and a suitable fix (valuate the list for potential bus station tiles with IsWithinTownInfuluence of town A)



That is the problem. My AI has that problem as well, and I asked that question. IsWithinTownInfluence will still be valid in townA even though it is closer (or attached to a road) in townB. Only way I know around that now is to have an IsConnected private function that checks if there is a path.

MarkS


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 3:44 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Jun 21, 2004 3:25 pm
Posts: 87
reylas wrote:
wilco_moerman wrote:
After some pondering I came up with the above explanation, and a suitable fix (valuate the list for potential bus station tiles with IsWithinTownInfuluence of town A)



That is the problem. My AI has that problem as well, and I asked that question. IsWithinTownInfluence will still be valid in townA even though it is closer (or attached to a road) in townB. Only way I know around that now is to have an IsConnected private function that checks if there is a path.

MarkS


I solved this problem by staring on the town tile then adding all road tiles that are in the towns influence and their adjacent tiles, then choosing one of these to build a but stop on. So far it has always worked, even when towns are already connected by another player. Only disadvantage is its probably a bit more expensive than just using a large rectangle around the town.


Top
   
 Post subject: Re: Convoy- a Road AI
PostPosted: Mon Jun 16, 2008 4:13 pm 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
reylas wrote:
wilco_moerman wrote:
After some pondering I came up with the above explanation, and a suitable fix (valuate the list for potential bus station tiles with IsWithinTownInfuluence of town A)



That is the problem. My AI has that problem as well, and I asked that question. IsWithinTownInfluence will still be valid in townA even though it is closer (or attached to a road) in townB. Only way I know around that now is to have an IsConnected private function that checks if there is a path.

MarkS


IsWithinTownInfluence seems to work fine for me.

Ralph - I think your solution sounds better to me, as it will allow for larger towns.

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 104 posts ]  Go to page 1 2 3 4 5 6 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.