NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.1.3

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

bokkie
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 19 Jan 2007 19:26

Re: NoCab - Making AIs cry since 2008 [Update: revision 186]

Post by bokkie »

Something I noticed is that because planes use 'full load', they have to wait until both passengers and mail capacity is filled. 'Full load any' would be more appropriate because now planes are waiting ages for more mail to come while the passenger capacity is filled. Because of this, throughput is mediocre and planes are waiting in the hangar.

EDIT: it even went bankrupt in my game because of this! :D
Attachments
Geen naam, 1 Mrt 1945#1.png
(213.13 KiB) Downloaded 125 times

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Making AIs cry since 2008 [Update: revision 186]

Post by Morloth »

Thanks for the feedback! To address your bugs / questions:
SirkoZ wrote:Now for some comments about your otherwise nice AI (r186):
-it doesn't use shared orders (why?)
I haven't heard of shared orders (I'm not a regular player, I like my computer do the work for me ;) ). But this sounds like a great idea! One of the next things I'm going to introduce is the updating of existing connections, so the AI starts of with relative short connections to make some money; Later these will be extended to longer connections to make more money. Shared orders will certainly help, thanks for the tip!
SirkoZ wrote:-no matter how much money it has, it always borrows whenever buying new vehicles (I 'cheated' and built it some air-lines to bring in some money)
This is simply the implementation of the current algorithm. I have no intention to change this as it doesn't effect the overall performance.
SirkoZ wrote:-it overexpands the unloading stations (which are almost empty after introduction of faster lorries)
This is true and intentional, ideally we want no vehicles waiting for cargo on both ends of the connection. So in the beginning more and more stations will be build if the AI detects that vehicles are waiting on either side. As a consequence less stations will be used as less vehicles are needed to transport all cargo, I have no intention to change this as it can never hurt to have more stations :).
bokkie wrote:Something I noticed is that because planes use 'full load', they have to wait until both passengers and mail capacity is filled. 'Full load any' would be more appropriate because now planes are waiting ages for more mail to come while the passenger capacity is filled. Because of this, throughput is mediocre and planes are waiting in the hangar.

EDIT: it even went bankrupt in my game because of this! :D
Autch! Bankrupt ey? :( I will adopt your solution as I did notice this when I was testing but because the planes in 1950 can only transport 8 packages of mail it didn't pose a problem. But I see your planes can carry more, so I will include this fix in the next revision :).

* On a more general note:
I'm currently rewriting some parts of the AI to make the code more readable and to eliminate code duplication. The code is as good as finished, I'm only polishing it up so it is as good (or even better) as the current version :). So look out for a new release this week!

- Bram

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: NoCab - Making AIs cry since 2008 [Update: revision 186]

Post by SirkoZ »

...So look out for a new release this week!
That's really nice!

BTW - another suggestion - in that savegame of mine (a few posts back) NoCAB hasn't built any airports, it did try once that I know of. It would really help the AI to build at least a few heliports/helicopters once every so many years because with inflation and default road set it's really difficult to stay afloat with having to renew/replace all those vehicles (profits (with default vehicle set) are meager as soon as the connections have inclines/turns).

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Making AIs cry since 2008 [Update: revision 186]

Post by Morloth »

New version is out :D. Its quite a code overhaul and made a couple of optimizations as well. Nothing really special, but this will prepare the way for my next 2 implementations:

* Connection upgrade manager; If a connection is established it's now fixed and won't change. We want to be able to alter the connection by redirecting all vehicles to a longer route or replace a small airport with a larger one, etc.
* Ships! I already started on this implementation and won't take to long to implement.
SirkoZ wrote:
...So look out for a new release this week!
That's really nice!

BTW - another suggestion - in that savegame of mine (a few posts back) NoCAB hasn't built any airports, it did try once that I know of. It would really help the AI to build at least a few heliports/helicopters once every so many years because with inflation and default road set it's really difficult to stay afloat with having to renew/replace all those vehicles (profits (with default vehicle set) are meager as soon as the connections have inclines/turns).
This will be implemented as one of the next features for this AI. I fully agree this is necessary. Also note that the situation will likely not occur any more, because I lifted the min 1000 population restriction on airplane connections. Instead I fully rely on my heuristics.

More to come soon peeps, I'll give you a teaser as soon as I have ships working as well ;). Don't expect it to soon though, I'm currently overloaded with school work :(.
- Bram


Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Making AIs cry since 2008 [Update: revision 192]

Post by Morloth »

As promised:

TEASER ALERT!
Ships teaser.png
Ships teaser.png (18.01 KiB) Viewed 3575 times
Don't expect a release to soon though, I'm still very very busy with school (in fact I shouldn't have implemented this ;)). So don't expect a release till after next week. Happy building everyone! :D

- Bram

User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: NoCab - Making AIs cry since 2008 [Update: revision 192]

Post by athanasios »

Will the ships travel diagonally?
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: NoCab - Making AIs cry since 2008 [Update: revision 192]

Post by SirkoZ »

What kind of a question is that, athanasios?

Anyhow - I have run the latest version (r192) through with the r14578(76) OTTD and it went quite well except for:
-still no shared orders
-AI was somewhat slow to autoreplace its vehicles despite year being over 2000 and having built 2 backup plane rides at the beginning (AI had enough money).
-oh and the third one: quite a few loading and unloading stations are simply huge with some being sqeezed against the hillside....too many bays (vehicles don't/can't use them all).

EDIT: And there's a really strange thing - it appears there is a bug in the AI framework because if look at the Autoreplace window for my planes (only heli's and DC-9's) there are other planes in there and the numbers are way off - several ten thousand of them :!:

Here's the savegame:
Attachments
Harzdorf Transport, 10th Jun 2053.sav
savegame
(671.04 KiB) Downloaded 91 times

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Making AIs cry since 2008 [Update: revision 192]

Post by Morloth »

An other quick teaser :)
ships teaser 2.png
(45.74 KiB) Downloaded 93 times
athanasios wrote:Will the ships travel diagonally?
Well.. yes :)
SirkoZ wrote: Anyhow - I have run the latest version (r192) through with the r14578(76) OTTD and it went quite well except for:
-still no shared orders
Jup, this will be implemented after I finished ships.
SirkoZ wrote: -AI was somewhat slow to autoreplace its vehicles despite year being over 2000 and having built 2 backup plane rides at the beginning (AI had enough money).
Hmmz... I haven't tested that feature in detail. I solely rely in the autoupdate feature. But I expect that I didn't save up any money to do the actual auto replacement. Will look into it!
SirkoZ wrote: -oh and the third one: quite a few loading and unloading stations are simply huge with some being sqeezed against the hillside....too many bays (vehicles don't/can't use them all).
I'm currently rewriting / updating the pathfinder so it can handle more generic cases. The current implementation simply finds an other route from any empty tile next to a road station without taking the usability of that tile into consideration. Will look into that as well once I'm done with ships :).
SirkoZ wrote: EDIT: And there's a really strange thing - it appears there is a bug in the AI framework because if look at the Autoreplace window for my planes (only heli's and DC-9's) there are other planes in there and the numbers are way off - several ten thousand of them :!:
That's odd... For some reason I'm unable to open your save game so I couldn't check myself. But thanks again for the feedback and expect a release within 2 weeks :D.

- Bram

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: NoCab - Making AIs cry since 2008 [Update: revision 192]

Post by SirkoZ »

That's nice. Anyhow - for my saved game you need the NewGRF found in my signature (link) - the Only_decrease neutraliser (forgot to mention). ;-)

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Making AIs cry since 2008 [Update: revision 192]

Post by Morloth »

It's here!!! Ships are implemented 8).

While there is still a lot to do, some highlights of this release:
* Shared orders are implemented! (by popular request ;)).
* Buoys are nicely spaced from on another so they don't overcrowd the map.
* Some map analysis is done to determine which industries / towns can be served by ships. At the moment this binding is static, so if towns grow this won't be taken into account (yet). Oil rigs are also served :).
* Pathfinder partially rewritten which is now way more dynamic :D.

Stuff to do before next release:
* Code clean up
* Documentation
* More testing!

I hope some of you can help me with the latter, because as the AI gets bigger and bigger it's more important to detect small flaws so I don't have to repair them way later which might affect other aspects of the AI. Thanks to all of you who helped me so far, it's really appreciated and help me a lot! :)

To sign off with, a picture of the latest version and reply to some forum posts:
Unnamed, 26th Sep 1953.png
Unnamed, 26th Sep 1953.png (39.24 KiB) Viewed 3258 times
SirkoZ wrote:That's nice. Anyhow - for my saved game you need the NewGRF found in my signature (link) - the Only_decrease neutraliser (forgot to mention). ;-)
That worked, thanks :). I notice NoCAB doesn't replace airplanes as is to be expected because it won't build 'big' planes on small airfields. Next step will be to update existing connections (my next big project before I tackle trains). But nice to see in action though, I never ran my AI for so long; Good to see it can survive for more then 100 years :D.

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 197]

Post by Morloth »

I'm a bit fuzzy about Shared orders at this point. Now that I've implemented it I see some weird behaviour coming from (but possibly not limited to) ships. It seems that if one ship decides to go for maintenance, all ships follow suite! Only for a couple of seconds where they all decide not to go to the depot at all and return to their routes, only to turn around again 20 seconds later...

Anyone any clue what could be going on here?

Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 197]

Post by Yexo »

Morloth wrote:I'm a bit fuzzy about Shared orders at this point. Now that I've implemented it I see some weird behaviour coming from (but possibly not limited to) ships. It seems that if one ship decides to go for maintenance, all ships follow suite! Only for a couple of seconds where they all decide not to go to the depot at all and return to their routes, only to turn around again 20 seconds later...

Anyone any clue what could be going on here?
Can you post a savegame that demonstrates this problem?

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 197]

Post by Morloth »

Yexo wrote:
Morloth wrote:I'm a bit fuzzy about Shared orders at this point. Now that I've implemented it I see some weird behaviour coming from (but possibly not limited to) ships. It seems that if one ship decides to go for maintenance, all ships follow suite! Only for a couple of seconds where they all decide not to go to the depot at all and return to their routes, only to turn around again 20 seconds later...

Anyone any clue what could be going on here?
Can you post a savegame that demonstrates this problem?
Alas I don't. But I've removed the AIOF_SERVICE_IF_NEEDED order for ships which seems to be helping. Now I only use it for road vehicles, but I'm not sure how they are affected by this.

I'll look into this into more detail later this week.

Good night!
Bram

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 205]

Post by Morloth »

Hey everyone,

I quickly want to say sorry for the vast amount of updates over the last couple of days, development has been going very quickly and I didn't want to leave you in the dark ;). Now that the main features are implemented I will slowly move towards a stable release cycle like Yexo and Zutty use for AdmiralAI and Convoy respectively. I will consider this implementation with busses / trucks / ships and airplanes as the release candidate for version 1.

The roadmap look as follows:
Version 1, RC1 (revision 205) - now
Version 1, RC2 - Only if bugs show up
Version 1, FINAL - Somewhere this month
- Code clean up + documentation.

Version 2:
* Advisor to update existing connections, which means:
- Migration to larger routes.
- Vehicle replacement.
- Replacement of airports.

Version 3:
* Trams / Trains implementation.

Version 4:
* Start looking at terrain analysis, mainly to speed up the algorithms.
* This version should be able to compete with average / good human players.

Version 5:
* Make a 'human friendly' version which will focus more on aesthetic qualities like the use of smart rail road design, etc.

This is the plan for the coming X months, hope it's worth the ride :). As a last note, bug fixes between releases will have a simply numbering system like 1.4, 3.2, etc. You can always get the very latest version of the SVN server (see first post), but consider this as a bleeding edge version which might (it should...) not work or contain other bugs.

Take care and happy building,
Bram

User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 205]

Post by athanasios »

Seems ships do not go so diagonally-ship goes wrong way=zig-zag. Pretty good old pathfinder wise. :cry:
Attachments
drunk_ship.png
drunk_ship.png (12.27 KiB) Viewed 3142 times
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 205]

Post by Morloth »

athanasios wrote:Seems ships do not go so diagonally-ship goes wrong way=zig-zag. Pretty good old pathfinder wise. :cry:
Thx for your feedback athanasios, but could you be a little bit more specific about this/ Just showing 1 line doesn't make it look zig-zaggy to me ;).

But you're right that the pathfinder doesn't find the optimal routes in this sense and this has been by design. Non-admissible heuristics produce results faster but you lose optimality, that's the trade-off. However, I'm currently looking into admissible heuristics and for road vehicles they are quite promising and very fast ^^. For ships I am exploring the same capabilities and again it looks very promising. For those interested: The general idea is to do a reachability analysis first before finding an optimal path, thus during the planning phase we use a non-admissible heuristic to find a path ASAP. But then during the construction phase we calculate the proper route.

I will do some more testing and include an optimal algorithm in version 1 final.

Thanks for your feedback! :)

P.S. There was a little flaw in the pathfinder where it would count diagonal tiles as straight once and vice-versa. This will be fixed in the final version.
Last edited by Morloth on 19 Nov 2008 13:02, edited 1 time in total.

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 205]

Post by SirkoZ »

Wow - quite a lot changes since I've last been here. :D

I really like your development plan, Morloth, I can hardly wait version 3. ;)

I have still to test the ship-added version 1 (r205).

BTW - athanasios ships not going diagonally is dependent upon pathfinder (Original) and not on AI implementation, however it might be possible to make AI so it uses its own pathfinder? I don't know.

Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 205]

Post by Morloth »

SirkoZ wrote:I really like your development plan, Morloth, I can hardly wait version 3. ;)
Thx, lets hope it works out as well as it looks on paper ;).
SirkoZ wrote:BTW - athanasios ships not going diagonally is dependent upon pathfinder (Original) and not on AI implementation, however it might be possible to make AI so it uses its own pathfinder? I don't know.
athanasios actually has a valid point here. The pathfinder in r205 constructs zig-zag patterns, becaues of the heuristic it doesn't discriminate between diagonal and straight nodes, so the zig-zag pattern will look as good to the pathfinder as a straight line. So /\/\/\/\/ == ---------. In fact it will prefer zig-zag lines because the diagonal lines will take it close to the goal (it thinks).

See the following example:

Code: Select all

w = water
s = start
g = goal
# = land
* = found path

g##########
w####w#####
w###www####
wwwwwwwwwws
wwwwwwwwwww

Non-admissible:
g##########
*####*#####
*###*w*####
w***www***s
wwwwwwwwwww

Admissible (optimal!):
g##########
*####w#####
*###www####
w*********s
wwwwwwwwwww
The path it finds goes into the bay because it is strongly attracted by the goal (non-admissible). With an admissible algorithm we produce an optimal plan which is the last picture. This is exactly the difference between r205 and r206 :).

- Bram

User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: NoCab - Trucks, Busses, Airplanes and Ships! [Revision 205]

Post by athanasios »

SirkoZ: I suppose that is what Morloth is up to. And that is what we want to get rid of. :wink:

I hope you can find a solution, because it looks very ugly. There is open sea there without obstacles (no land in the middle), but the ship prefers to zig zag. Good luck.

Code: Select all

Current:
g***wwwwwww
www*wwwwwww
wwww***wwww
wwwwwww*www
wwwwwww*www
wwwwwwww*ww
wwwwwwww**s

Optimal:
g****wwwwww
wwwww*wwwww
wwwwww*wwww
wwwwwww*www
wwwwwwww*ww
wwwwwwwww*w
wwwwwwwwwws

http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests