MailAI
Moderator: OpenTTD Developers
MailAI
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.
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 907 times
Last edited by Hephi on 19 Oct 2013 08:12, edited 10 times in total.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
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.
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)
Junctioneer (a traffic intersection simulator)
Re: MailAI
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
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
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
Re: MailAI
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.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
I was just reading some of your code and have a few comments;
AIEngine.CanPullCargo takes a CargoID as argument, not a cargoclass. As such passing AICargo.CC_MAIL as argument is wrong.
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.
Code: Select all
//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
Code: Select all
local types = AIRailTypeList();
if (types.Count()>1)
{
AIRail.SetCurrentRailType(1);
} else
{
AIRail.SetCurrentRailType(0);
}
I haven't played with your AI yet, but I'll definitely be giving it a try.
Re: MailAI
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.
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.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
You already have the code for that:
Code: Select all
/*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!");
*/
Re: MailAI
aha! I remember... thanks. I'll fix that on the next occasion.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
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
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. Apart from that, the only bug I've encountered so far was this: And another one of this type: 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
You must must have put quite a lot of work in it, it's already bigger in terms of code size than SimpleAI
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. Apart from that, the only bug I've encountered so far was this: And another one of this type: 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
Re: MailAI
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.
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.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
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: For some reason, this window still displays v20110119, although it is the newest version.
I've attached the savegame.
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: 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 509 times
Re: MailAI
I forgot to adjust version number
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)
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.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
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)
Junctioneer (a traffic intersection simulator)
Re: MailAI
I was using the Generic Tram Set and the Temperate Oil Wells Only Decrease Neutralizer (I wish this name wasn't this long ), none of them should affect your AI.Hephi wrote:About your save game. What grf are you using? It says I'm missing grf files when I load the game.
Re: MailAI
I just had to somehow put the word neutraliser into it.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 ), none of them should affect your AI.
Anyhow - just saw this topic - I'll give the newcomer AI a run together with SimpleAI.
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'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Re: MailAI
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 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)
Re: MailAI
In bananas, I have noticed that you have set the url to:
Perhaps the ending part is a paste-error?
Code: Select all
http://www.tt-forums.net/viewtopic.php?f=65&t=52478&p=925782#p925782/projects/ai-mailai
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: MailAI
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.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
I guess so but the clicky worksZuu wrote:In bananas, I have noticed that you have set the url to:Perhaps the ending part is a paste-error?Code: Select all
http://www.tt-forums.net/viewtopic.php?f=65&t=52478&p=925782#p925782/projects/ai-mailai
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Re: MailAI
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.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
MailAI, a casual postal service for openTTD.
--------------------------------------------------
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests