Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sun Feb 25, 2018 11:08 pm

All times are UTC




Post new topic  Reply to topic  [ 47 posts ]  Go to page 1 2 3 Next
Author Message
 Post subject: MailAI
PostPosted: Wed Jan 19, 2011 6:16 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
Introducing MailAI, an openTTD AI that transports all your love letters and court orders with trucks and trains!

I have updated this AI to version 2.0, currently tested on openTTD version 1.3.2
Massive improvement when planning on routes to build. If stations are doing good enough will start re-using them for further routes creating more complex forms then just PtP lines.
Does NOT spam road vehicles. It sometimes builds 90° turns on rail so this should be enabled in your settings.
For saving/loading functionality: The AI works after loading but might at this moment have unused buildings or routes.

I hope you enjoy this creation and I appreciate any feedback.


Attachments:
MailAI-2.22.tar [279.5 KiB]
Downloaded 400 times

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Last edited by Hephi on Sat Oct 19, 2013 8:12 am, edited 10 times in total.
Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 6:51 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4535
Location: /home/sweden
If you select a pre-defined license on bananas, you must not include any license file in your tar file that you upload. (in case you tried to upload the exact same tar-file as you have uploaded to the forums)

Also be aware that it is required for you to be able to update the AI later, that you use your account to upload it to bananas. If the devs with raw access to the database are involved, they might be able to work around that. Therefore, try to resolve the issues, rather than having some random guy upload your AI.


Edit: Sounds that your AI and PAXLink will be good friends in theory. :-)

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


Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 7:03 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2364
Location: Location, Location
Excellent! I have been watching MailAI for a while

Haven't had a chance to test it yet, but i will as soon as possible
One thing that occurs to me however, is your coding style. It's, well, a bit rubbish :) It will be much easier to debug if you, for example, base the coding style on the wiki page: http://wiki.openttd.org/Coding_Style

_________________
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


Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 7:58 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
Lord Aro wrote:
One thing that occurs to me however, is your coding style. It's, well, a bit rubbish :)



Haha :) I do try to make it logical sometimes. Are you referring to what variables I create and at what point or how I handle passing things to functions or what? I know some parts are a big mess because I kept adding code to it.


About the bananas: openTTD accepts 'false' tar files made with winRAR and can read them perfectly, Bananas wants 'real' TAR files so I needed to make it with another archive program (7-zip)

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 9:40 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
I was just reading some of your code and have a few comments;
Code:
//bad solution to a AIEngine.CanPullCargo,AICargo.CC_MAIL bug using newGRF's
   //following engines can carry mail but will not be on the CanPullCargo returned list

AIEngine.CanPullCargo takes a CargoID as argument, not a cargoclass. As such passing AICargo.CC_MAIL as argument is wrong.

Code:
   local types = AIRailTypeList();
   if (types.Count()>1)
   {
      AIRail.SetCurrentRailType(1);
   } else
   {
      AIRail.SetCurrentRailType(0);   
   }
With railtype newgrfs there is no guarantee that railtype "0" is available. It can happen that railtypes 5 and 6 are available but neither 0 nor 1 are.


I haven't played with your AI yet, but I'll definitely be giving it a try.


Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 10:47 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
I didn't notice the difference bewteen cargoclass and cargo id. How can I know what cargo id to use then? I don't see a list on the NoAI API.

I know about the rail problem but as long as there's no better way of detecting the rail types this will have to work.

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 10:55 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
You already have the code for that:
Code:
   /*taken out to minimize error value list
      local mail_list = AICargoList();
   mail_list.Valuate(AICargo.HasCargoClass, AICargo.CC_MAIL);
   mail_list.KeepValue(1);
   if(mail_list.IsEmpty())throw("No mail available in this game! Crashing wildly!");
   */


Top
   
 Post subject: Re: MailAI
PostPosted: Wed Jan 19, 2011 11:09 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
aha! I remember... thanks. I'll fix that on the next occasion.

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Thu Jan 20, 2011 10:19 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 875
Nicely done :)
You must must have put quite a lot of work in it, it's already bigger in terms of code size than SimpleAI :D
I'm running a game right now, it's been running for 16 years, and... well, it crashed right now, presumably because the first electric locomotive has been introduced.
Attachment:
Unnamed, 5th Aug 1966.png
Unnamed, 5th Aug 1966.png [ 19.53 KiB | Viewed 13392 times ]


Apart from that, the only bug I've encountered so far was this:
Attachment:
Unnamed, 3rd Jan 1960.png
Unnamed, 3rd Jan 1960.png [ 69.9 KiB | Viewed 13392 times ]


And another one of this type:
Attachment:
Unnamed, 10th Jan 1967.png
Unnamed, 10th Jan 1967.png [ 68.92 KiB | Viewed 13392 times ]


There were two instances of MailAI running for a while, but they tended to use the same towns, so I stopped the second instance. It's not a big problem, as not all towns are able to produce a sufficient amount of mail...

The estimates in the AI debug window are a bit strange to me... Why is the actual profit sometimes higher than the optimal profit? :)

Anyway, the routes are nicely built, I like those passing lane sections :D


Top
   
 Post subject: Re: MailAI
PostPosted: Thu Jan 20, 2011 11:06 am 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
About the four things Brumi posted:

1: Bug fixed, was a typo in replaceVehicle (will be in next update)
2: This is more difficult, I've rewritten the code a bit but apparently it still needs changing. I'm gonna rewrite from the start I think.
3: This is 'normal', it found a switch location but blocked the other track while building it. As it's only graphics this is low on the todo list.
4: Two instances use the same towns indeed. I'm gonna write a function that checks for mail transported before building a route.

Thanks for the input!


New version uploaded in first post!
20/01/2011
- BUGFIX typo caused errors in replaceVehicle (Brumi).
- Replaced cargoclass with cargoid when selecting engines/wagons (Yexo).
- BUGFIX building a depot which it couldn't connect to the road.
- Started code cleanup to be a little less rubish (Lord Aro).
- BUGFIX Didn't start the train after selling a wagon.

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Jan 21, 2011 12:51 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 875
I'm testing the new version. No crash or misplaced rail station this time :)
However, in 1971 (the game was started in 1950) the AI has only 4 trains and 6 road vehicles, although there are other cities worthy of mail transport. And I saw this in the AI debug window:
Attachment:
Unnamed, 8th Apr 1971.png [41.18 KiB]
Downloaded 2 times

For some reason, this window still displays v20110119, although it is the newest version.

I've attached the savegame.


Attachments:
Unnamed, 14th Apr 1971.sav [463.09 KiB]
Downloaded 187 times
Top
   
 Post subject: Re: MailAI
PostPosted: Fri Jan 21, 2011 7:45 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
I forgot to adjust version number :oops:

About your save game. What grf are you using? It says I'm missing grf files when I load the game.

It appears to me that the AI must have 'hung' building a railroute. I can't find a solution for controling the railpathfinder,
if there's no possible route it just keeps on looking. The best way to work around this is save and load the game which restarts the AI.

That's also why if you load up your saved game it suddenly sends all those old vehicles to the depot for replacing.
While it was hanging it couldn't perform the vehicle checks. It also immediately started building a new rail route.

I'll add some code that will show the town it's trying to build so whenever the AI has hung we'll see
because the last lines will be 'building rail route from townA to townB' and nothing ever comes after it.

On openttdcoop there's a new version if you're interested, ran out of time to tar it and upload it here.
21/01/2011
- IMPROVE Handling objects in the way of the railpathfinder. (crossing roads and rails)
- IMPROVE Correctly detecting bridges in BuildPassings so trackwalker can continue.
- IMPROVE Rewrote code that builds the switch in front of the station, now also chooses best side. (Brumi)
- FIX Typo in BuildRailStation that led to leaving (yet another) tile undestroyed when cleaning up station.
- BUGFIX Switchlocation finder handled coast tiles wrong.
- BUGFIX Sold vehicle before orders where copied resulting in empty order list.
- BUGFIX When selling wagons it was possible for the train to end up stopped at the depot.
- BUGFIX when it couldn't move wagons (Brumi)

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Jan 21, 2011 8:14 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4535
Location: /home/sweden
If you have a recent nightly or 1.1 beta you can click on the NewGRF button on the load game dialog and then find on online content.

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


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Jan 21, 2011 8:17 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 875
Hephi wrote:
About your save game. What grf are you using? It says I'm missing grf files when I load the game.

I was using the Generic Tram Set and the Temperate Oil Wells Only Decrease Neutralizer (I wish this name wasn't this long :D ), none of them should affect your AI.


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Jan 21, 2011 9:26 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1494
Location: The sunny side of Alps
Brumi wrote:
I was using the Generic Tram Set and the Temperate Oil Wells Only Decrease Neutralizer (I wish this name wasn't this long :D ), none of them should affect your AI.


:lol: I just had to somehow put the word neutraliser into it. :mrgreen:

Anyhow - just saw this topic - I'll give the newcomer AI a run together with SimpleAI.
Attachment:
tasty.gif
tasty.gif [ 1.45 KiB | Viewed 13264 times ]

_________________
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.

Keep 'em rollin'!


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Mar 25, 2011 4:36 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Sep 20, 2006 11:43 pm
Posts: 327
Location: UK
Ive found a bug...

It dosent seem to be aware of the forbid trains from making 90° turns setting and such keeps building impossible railways (normally with 90° required to exit passing loops)


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Mar 25, 2011 9:18 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4535
Location: /home/sweden
In bananas, I have noticed that you have set the url to:
Code:
http://www.tt-forums.net/viewtopic.php?f=65&t=52478&p=925782#p925782/projects/ai-mailai


Perhaps the ending part is a paste-error?

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


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Apr 01, 2011 7:24 am 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
dasy2k1 wrote:
Ive found a bug...

It dosent seem to be aware of the forbid trains from making 90° turns setting and such keeps building impossible railways (normally with 90° required to exit passing loops)



It's somewhere in the fine print that this AI needs 90° turns enabled. Normally 90° degree turns should only exist in
a rare occasion on station exit and with some depots. Sorry for the inconvenience.

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Fri Apr 01, 2011 7:25 am 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
Zuu wrote:
In bananas, I have noticed that you have set the url to:
Code:
http://www.tt-forums.net/viewtopic.php?f=65&t=52478&p=925782#p925782/projects/ai-mailai


Perhaps the ending part is a paste-error?


I guess so but the clicky works :)

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


Top
   
 Post subject: Re: MailAI
PostPosted: Mon Jul 25, 2011 3:46 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 25, 2009 9:56 am
Posts: 69
Location: Belgium
Found a bug trying to build a rail station. I'm not sure why it didn't build the train station but still went ahead building the truck station adjacent to the rail station. Also the added articulated stops function should only build to the adjacent station but seem to be build on the spot where the train station should be.

Image

_________________
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 0 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-2018 phpBB Limited

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