Page 1 of 3
FelicitusAI v0.2.1
Posted: 18 Feb 2009 05:54
by Felicitus
Hi,
this thread is meant to inform you about the development progress on the FelicitusAI, and also to get new ideas which can be implemented during the development progress.
Introduction
The FelicitusAI is an AI which tries to beat you using trains. It models a high-performance AI (similar to the players on Kurt's hard goal servers). Basically, it starts off with a simple line, which is aimed to be as long as possible, and then extends that line to a dual-track line and eventually builds a grid-based main line network to connect everything on the map. It is also planned that the AI can build new industries as needed, to optimize the existing delivery of cargo.
Latest Version
Version 0.2.1
FelicitusAI - Development Progress: Stations
Posted: 18 Feb 2009 06:04
by Felicitus
In order to keep the AI flexible, the engine allows an on-the-fly upgrade of existing stations. I'm currently working on the basic station builder, which has generic methods to build stations. The station builder allows to extend and to upgrade stations. Extending a station means that stations extend the platform length to meet new requirements. Upgrading a station means that the station layout itself is updated, for example, converting a simple station to a RORO station.
Right now I've got two stations: A basic station in two lengths, a RORO station, a simple terminus station and a terminus station with two platforms.
You can see the stations which the station builder can build in the attachment.
Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 06:38
by Wold
A thing I don't like about Kurt's "game type" is the RoRo sleek station. You lose about 15% of the rating by forcing the train to a depot since no points are awarded for the speed part.
Nice idea. I hope you realize it
Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 06:46
by Felicitus
Yes, I know

I don't know if the sleek roro will ever be built by the FelicitusAI, let's see what development brings.
Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 09:03
by Timitry
The ideas for your AI sound promising, i hope you can realize that!
I like the idea of using those roro-sleek stations, however, i have a suggestion. See my attached picture to see what it looks like.
Advantages: Two trains can load at the same time, which will give you a higher rating (first train is full ---> second train starts loading immediately) in comparison to the one-platform version (first train is full ---> leaves station ---> second train enters station ---> second train starts loading).
It does not occupy much more space than the single-platform layout and is easy to build. The depot can hold an infinite amount of trains, and they will only leave the depot if one of the platforms is free. This might especially be useful if you plan to let your ai build big networks, where one jammed up station could block the whole traffic. With this kind of station, your excess trains are always out-of-the-way, plus you could probably easily check whether a platform has too many trains by "looking" into the depots - ideally there is always one train waiting in it

I hope i can convince you of that layout, and good luck with your ai!
Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 09:49
by Felicitus
Believe it or not, I just implented that station for my parseStation function - basically I'm a lazy developer and after implementing the first two stations by hand, I got bored and so I wrote a function which parses an existing station, and writing the output to the console, so I can just copy the commands and put them into the station code. The station builder even supports rotation now
By the way, there's a little mistake in your station. You have no signals between your depot and the station, so the train would only leave the depot if both platforms are free

Or does the new depot have a PBS signal in it? EDIT: Oh yes, it does! That's brilliant - so we can save one more tile space

FelicitusAI is happy now, as it doesn't need so much space
So its pretty easy for me and other developers to add new station types. Of course, if the station has a variable amount of platforms, a littlebit of manual coding is required. Looks good for now, it's time for bed then

Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 13:57
by SirkoZ
Wow - Felicitus - I'm impressed by your AI plan - I've been to Kurt's server many times and people there really build neat networks.
It will be great to have such a capable and smart AI.
I wish you success with this project.

Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 14:10
by Timitry
Felicitus wrote:Believe it or not, I just implented that station for my parseStation function
...
FelicitusAI is happy now, as it doesn't need so much space

Glad to hear that

I made a little example of how your AI could evolve a two-way-railway track with that station. I know that you probably have your own agenda for your ai, but i'm just in a kind of idea-rush which i need to share with someone, and you're unlucky to be that one

, so never mind
If there's a lot of cargo being generated at the coal mine station, you might need three platforms!
(2 more pictures following...)
Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 14:10
by Timitry
(The last 2 pictures)
Re: FelicitusAI - Development Progress
Posted: 18 Feb 2009 19:51
by Felicitus
Yes, that's the plan. Basically, the AI starts off with a stage 1 platform (which is a simple, short platform, length 4) and sends the train then. After the train delivered, it extends the train and the platform to be longer (length 10 or shorter, if the allowed station spread is lower), then sends the platform for a second run. After that is done, it upgrades the platform to a basic roro platform, and if enough money is left, a second train is bought and the track is converted to a (partial) dual line track.
Re: FelicitusAI - Development Progress
Posted: 21 Feb 2009 07:59
by Felicitus
A little status update: My AI got its first train running - and well, it already made a good profit

(see attachment)
Altough it sounds very unspectacular, the AI engine already does A LOT of things:
- Calculating which industries are best to connect in the first place
- Estimating the line and train costs
- Rating all available engines by reliability, speed, power and cost and picks the best one
- Picking the correct wagons for the cargo
- Automatic placement of a depot
- Keeps a map of all lines in memory, so the AI can connect these lines later using junctions
- Calculation of the optimal station placement, and tries to place the two stations as far as possible from each other
Unfortunately, it's currently not possible to use this AI (or probably any AI) with NewGRF trains which have specific checks, for example, the North American Train Set. This is due to the fact that the NewGRF itself decides wether a wagon can be attached to an engine, and this data is currently not (or probably never?) accessible by the AI. So the only way for an AI to support NewGRFs is trial and error: Buy the engine, try to attach the wagons, and see if it fails or not.
Next step will be to automatically buy wagons until almost all money is used (up to a maximum length), and extending the station before the first train arrives, in order to optimize the first run of the train.
Re: FelicitusAI - Development Progress
Posted: 21 Feb 2009 09:03
by planetmaker
Hi,
I'm quite impressed by the speed of your progress and I'm really looking forward to a first playable version of your AI
Felicitus wrote:Unfortunately, it's currently not possible to use this AI (or probably any AI) with NewGRF trains which have specific checks, for example, the North American Train Set. This is due to the fact that the NewGRF itself decides wether a wagon can be attached to an engine, and this data is currently not (or probably never?) accessible by the AI.
Reading that, I wonder whether
AIEngine Class shouldn't support that (quote from NoAI API docs):
Code: Select all
static bool CanPullCargo (EngineID engine_id, CargoID cargo_id)
Check if the engine can pull a wagon with the given cargo.
I see that it is a query for a cargo and not for a specific wagon, but cargo is the more important thing, isn't it?
Re: FelicitusAI - Development Progress
Posted: 21 Feb 2009 22:56
by Felicitus
Unfortunately, CanPullCargo is only reliable if it returns false - if it returns true, it doesn't mean that it is reliable. Example: You can build a train with the North American Train Set which can pull only light cargo. In my tests, the Engine was built, CanPullCargo returned true, but I was only able to attach ONE wagon. Subsequent wagons couldn't be attached - that's a check implemented in the NewGRF.
Re: FelicitusAI - Development Progress
Posted: 22 Feb 2009 10:36
by Felicitus
This doesn't work as expected (see attachment

Re: FelicitusAI - Development Progress
Posted: 22 Feb 2009 13:32
by planetmaker
It doesn't compile here...
for simplicity I moved it also to content_download. I also replaced the library folder therein by the one you supplied as instructed:
Code: Select all
Error /Users/ingo/Documents/OpenTTD/content_download/ai/FelicitusAI/info.nut:1/8: expression expecteddbg: [misc] [squirrel] Failed to compile '/Users/ingo/Documents/OpenTTD/content_download/ai/FelicitusAI/info.nut'
Re: FelicitusAI - Development Progress
Posted: 22 Feb 2009 16:29
by Morloth
Hi Felicitus,
Great to see you working on your AI! I'll be following your progress with great interest as I haven't implemented trains as of yet in my own AI. I really like your incremental approach to station building and I curious what solutions you find to building train connections and how it compares to AdmiralAI's approach. Best of luck and I look forward play testing your AI

.
Bram
Re: FelicitusAI - Development Progress
Posted: 23 Feb 2009 13:08
by Felicitus
The first release is here!
Features:
- Builds quite distant source and target stations
- Automatically buys new trains if there's too much cargo waiting
- Tries to connect everything on the map
Right now there are still quite a lot of issues:
- FelicitusAI currently only builds dual track mainlines. This is due to a problem where it doesn't build trains when doing single line tracks, I don't know why this happens, so I disabled all stations using a 1 track layout (which only makes one station type remaining

)
- No connecting of lines possible at the moment
- Doesn't use terraforming at all
- Sometimes it cannot build a train or finish the line, the whole process will be broken apart so that it can resume the partial building later. Maybe I will also introduce some kind of cash management (where different parts of the AI can "reserve" money so that other parts don't use the money needed).
Next Release will include:
- Fixing the bugs above
- Terraforming for stations
If you try this out, please leave comments and of course, if something looks wrong or if the AI crashes for some reason.
Download:
Felicitus AI v0.2
Thanks,
Felicitus
Re: FelicitusAI v0.2
Posted: 23 Feb 2009 21:58
by GeekToo
Real nice work.
I've tested it for a while now, and so far it looks pretty stable.
Just a few remarks:
-Early in the game, the long trains are really slow, as the engines are not so powerful. I like how it looks, but I doubt it gives optimal income.
-It uses a lot of level crossings with roads. When the roads are busy, the road vehicles stop for a train in one direction, and block the track in the other direction, just waiting to crash one of your trains.
But overall, keep going, I think this AI shows big potential.
Re: FelicitusAI v0.2
Posted: 24 Feb 2009 05:40
by railnut
Congrats on getting it out there ...
Am having problems playing it on my favorite scenario ... see screenshot below ...
Secondly, which rail pathfinder library version does it need ? 'main.nut' says v2 - but only v1 available ?
Re: FelicitusAI v0.2
Posted: 24 Feb 2009 07:08
by Felicitus
The version 2 is bundled, if you get the error that you get, everything is alright. I think it fails to find a route, can you send me that scenario for testing?
By the way, the AI will NOT work with OpenTTD beta 1. You need at least the nightly r15553 or later.