Any "casual" AI available?

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

sucinum
Engineer
Engineer
Posts: 17
Joined: 06 Apr 2009 19:46

Any "casual" AI available?

Post by sucinum »

Hi there,
before starting to whine, i want to say that i really appreciate the work on OTTD and the AIs. Keep it up, i'm a happy, but mostly silent customer.

I play TT(D) very casual, maybe 1 or 2 times a year, for the last 10+ years now. I discovered OTTD recently and gave it a shot. I was really impressed by some of the new features, mainly small usability stuff like the fast forward button, which are maybe small additions, but increase the fun a lot. I was excited when i stumbled over 0.7 and decided to play my yearly round of TT. The new AIs looked promising so I installed some of them (including all required libraries, mentioning that just in case) and launched a game.

The settings in my games are always the same: hard difficulty, large map (i choose 1024² since OTTD). I play the first map i get and start with some bus stations (coal trains are too risky and i don't want to waste an hour for a decent start, so busses will do). My goal is to get 1000 points when the game ends; which is not that hard, actually i manage to do that since my very first TT game back in the 90s. I enjoy having some AIs as obstacles.

When starting my last game (now getting to the facts), i had several AIs installed (Admiral, Cab, Convoy, Fan) and set the competitiors to get a random AI. At first i was impressed as the AIs showed some clever moves, like using the connections i have built. Very quickly most of them had large networks of busses and started to launch the first airplanes. Some of the AIs went broke, but i didn't regard too much, that happened before as well. I simply bought their shares and let new ones start.
But later i found out the mess: all of the AIs where crammed together in the same spots. This resulted in huge traffic jams and not only once i could watch 50 or more busses in traffic jams. Still those buses managed to get some small revenues and so werent replaced/sorted out, but the whole place was a mess. At the same time, the connected cities grew extraordinarily fast, resulting in even more bus stops and traffic jams. New AIs couldn't evolve because they tried to get their share of the same cake. Others went broke because they couldn't handle starting with 200k on ugly terrain.

I personally think the AIs are focussed too much on competition and not enough on endurance. While i enjoy some competition, it doesn't make the game better if the whole map is crowded with traffic jams. I'd prefer some more random behaviour, like going for some "safe" routes with lower revenues. I'd rather have some "obstacles", which play to lose, but still build some decent and eye-catching networks and steal some of "my" routes (adds up with 7 of them). Especially problematic was running multiple of the same AI scripts, since they basically did the same.

Also, I still outperformed any AI with merely 50 vehincles, while some of them already had 500 and couldn't expand further since they hit the limit. I think the AIs should have a look at that, because if i removed the limits, there would be over 100,000 vehincles around by 2051. An AI should be able to fare well without spamming, a bit more efficiency would be appreciated.

So very hard to make suggestions. I like the edge the available AIs have over the "old AI" and i don't mind them being a bit more aggressive, leeching my roads and creating huge networks. But i think the competitional side is a bit overdone, both the cherrypicking of transport routes and the spamming of vehincles.

Anyways, keep up the good work. I will pass time with duelling some of the AIs and ofc Civ4 ;). Just wanted to say...

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

Re: Any "casual" AI available?

Post by Morloth »

Hi sucinum,

Thanks for sharing your experiences. Some of your issues have already been brought up by other people in various topics. AIs going for the same resource and jamming roads are quite common and it's a well known problem. An interesting part in your post is however:

"Also, I still outperformed any AI with merely 50 vehincles, while some of them already had 500 and couldn't expand further since they hit the limit."

This is a very interesting insight, it's a shame you didn't put up a save file as it would be quite interesting to see which connections your exploited to win from the various AIs. Although I program an AI for OpenTTD I don't play it myself so expert information like this in invaluable. If you still have a save file around could you upload it to the forum? Would be interesting to see how the AIs performed.

Thanks for sharing your thoughts and experiences :).
Bram
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Any "casual" AI available?

Post by Bilbo »

Regarding all AI's serving the same lines - that is caused by 2 things:
1. AI's are not enough random - Some AI's pick "the best" industry to serve and if there are multiple AI's, they pick all the same route.
They should be modified not to pick "the best" but rather "one of the best".
2. Due to flaw in AI API design, it is impossible for AI's to see stations and vehicles of other companies (see bug FS#2776), therefore they can't tell whether someone already built some route at their target.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
sucinum
Engineer
Engineer
Posts: 17
Joined: 06 Apr 2009 19:46

Re: Any "casual" AI available?

Post by sucinum »

Here you are:

It's actually 83 (i couldn't help some counter-spamming) vs. 273 vehincles in this game and i didn't play very well by myself, more or less sandboxing and wasting lots of cash on "straight train lines" and other stuff. I mainly rely on valueables. I'm surely no expert in TTD, I just play along.
I'd go as far and say that Admiral has clearly overspammed, most vehincles don't run very well and have very low revenues.
Some towns simply look ridicolous with more transport stuff than houses, for example "Tonberg".
The other AIs never managed to establish (think i had only Cab and Admiral activated in that game, but not too sure).

I dismissed the other games, so that's the only one i can provide.
Attachments
sucinum Transport.sav
(1.63 MiB) Downloaded 157 times
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: Any "casual" AI available?

Post by Zutty »

What do you think is the best way to avoid over-servicing an industry? As Bilbo suggests, an AI lacks the player's ability to immediately appraise this condition.

I was thinking AIIndustry.GetAmountOfStationsAround() but it seems rather arbitrary, as those stations might be poorly serviced. I was hoping to find some kind of pattern in AIIndustry.GetLastMonthTransported() but couldn't seem to find a good way to rely on that either.

Is there some significance to the percentage of cargo transported? Does it ever reach 80%+? I couldn't see anything on the wiki, but them I am dumb!

Cheers
PathZilla - A networking AI - Now with tram support.
User avatar
RFHolloway
Engineer
Engineer
Posts: 5
Joined: 11 Jan 2008 10:13

Re: Any "casual" AI available?

Post by RFHolloway »

Perhaps its as simple as evaluating the potential of a route based on the undelivered cargo plus a proportion of the delivered cargo. My initial estimate would be the potential market is the undelivered cargo plus 1/n of the delivered cargo where n is the number of competitors (ideally for the route but total would be the first guess).

If you understand how the cargo is actually allocated you could probably come up with how much cargo will be generated from an additional 80% satisfaction rated station which would probably be the best estimate.
sucinum
Engineer
Engineer
Posts: 17
Joined: 06 Apr 2009 19:46

Re: Any "casual" AI available?

Post by sucinum »

As human, I don't care for delivered cargo rates (station ratings) at all. I rather look if my vehincles are fully loaded, have direct routes and no time to wait. If the game was harder/more realistic, this would actually be clever and business-orientated behaviour. As it is now, spamming might reduce the efficiency of a single vehincle, but the highly increased load you get with a better rating makes this pay off.

Parts of the scoring does rewards me (Minimum profit of vehicles at least two years old), but not too much.

But basically that isn't a problem of the AI alone, but also of the game balancing. Spamming = profit, so any competetive AI will do.

I'm also not too sure how much the AI factors waiting times. If the calculation is only "1 bus = $ ->2 busses = $$", spamming will always occur until you hardcode a cap of x vehincles per station.

That's one of the reasons why i'd prefer a casual AI.. This AI could have goals like "connect one of each good types", "use at least each one of each vehincle type", "get a score of about 900 after 100 years" or similar. Including special station designs or advanced signalling for the look would be icyng the cake. I wouldn't mind some leeching here and there or basic tricks, but at least part of the gameplay should be partly creative and not only competetive - like i play as casual player. The two main rules for an AI should be:
only build profitable connections (low and short term gains at the start, high and long term gains later)
only build connections they can afford
Everything after that can be randomized in my book.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Any "casual" AI available?

Post by Bilbo »

sucinum wrote: Spamming = profit, so any competetive AI will do.
Actually ... no. Or not always. While there are situations where it is more profitable to compete with opponents for goods from good industry, often it is better to pick industry that is slightly worse, but unserviced - as you will get all of its output, compared to "perhaps about half" when competing with another company.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
sucinum
Engineer
Engineer
Posts: 17
Joined: 06 Apr 2009 19:46

Re: Any "casual" AI available?

Post by sucinum »

Of course spamming has its limits and even with the largest stations, you can still have another bottleneck. A bus/truck having a breakdown on a bridge can cause a really ugly traffic jam for example.

The game i provideed isn't that bad as others i dismissed, but you can see an ugly jam at Dortmund Mine for example. There are about 20 trucks on a connection where 3-4 would suffice and gain almost the same revenue. So maybe the AI is good at milking stations, but not so much at milking vehincles.
To have it get really ugly you need 2 or more AIs at the same spot, that's a jam guarantee (and i want to play with 7). I mean, a single Admiral or NoCab doesn't do a bad job in filling the map and staying alive (all i want from them), but several of them crowd the map too much.
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Re: Any "casual" AI available?

Post by Moriarty »

On the matter of the AI choosing routes to service:

Why can't the API (given this would be required for all non-passenger AI's) - create a list/array/whatever with all possible routes plus distances in it.
Say you have 10 coal mines and 10 power plants, that's 100 possible routes in a nic shiny list. I realise it could add up quickly in size, hence my API suggestion. Calculate all routes/distances once a year (optimisation - wouldn't need to re-check the distances), maybe even split the calculation up over the course of a year so it doesn't freeze the game on Jan 1st.
Then the AI's could look in the list and it could then randomly select a coal route from the list longer than distance X.

Or am I missing something?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Any "casual" AI available?

Post by Yexo »

Moriarty wrote:On the matter of the AI choosing routes to service:

Why can't the API (given this would be required for all non-passenger AI's) - create a list/array/whatever with all possible routes plus distances in it.
Say you have 10 coal mines and 10 power plants, that's 100 possible routes in a nic shiny list. I realise it could add up quickly in size, hence my API suggestion. Calculate all routes/distances once a year (optimisation - wouldn't need to re-check the distances), maybe even split the calculation up over the course of a year so it doesn't freeze the game on Jan 1st.
Then the AI's could look in the list and it could then randomly select a coal route from the list longer than distance X.

Or am I missing something?
It's so easy to create such a list yourself that I see no need to add it to the API. Plus if you have to craete that list yourself you'll notice how big it can become, hiding such expensive functions in the api is not a good idea imo. Again, feel free to write a library that does these kind of things.
defaultluser
Engineer
Engineer
Posts: 34
Joined: 01 Mar 2009 19:56

Re: Any "casual" AI available?

Post by defaultluser »

I thought I'd throw this into the fray:

Did you save and reload your game at any time during this play-through? Convoy is notorious for not having Load/Save support.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Any "casual" AI available?

Post by Bilbo »

Moriarty wrote:On the matter of the AI choosing routes to service:

Why can't the API (given this would be required for all non-passenger AI's) - create a list/array/whatever with all possible routes plus distances in it.
Say you have 10 coal mines and 10 power plants, that's 100 possible routes in a nic shiny list. I realise it could add up quickly in size, hence my API suggestion. Calculate all routes/distances once a year (optimisation - wouldn't need to re-check the distances), maybe even split the calculation up over the course of a year so it doesn't freeze the game on Jan 1st.
Then the AI's could look in the list and it could then randomly select a coal route from the list longer than distance X.

Or am I missing something?
Well, it is not important to where do they deliver the coal - only from which mine they take it. And since AI tend to pick the "best" route, they usually all pile up at the single coal mine that happends to have highest production. That is the best decision - if there wouldn't be any competition. Especially competition that thinks same...

So you have to be random and sometimes pick a route that seems to be a bit worse. If you are too little random, you will unnnecessary compete. If you are too much random, you will select random (and usually worse) routes.

The approach you suggested would work, BUT you need to calculate or estimate the value of X well. Too low and you get inferior routes. Too high and all AI's pile up at one coal mine.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Any "casual" AI available?

Post by GeekToo »

defaultluser wrote:I thought I'd throw this into the fray:

Did you save and reload your game at any time during this play-through? Convoy is notorious for not having Load/Save support.
And there's a good reason for that, it wouldn't benefit much if it did, and I explained it some time ago:
http://www.tt-forums.net/viewtopic.php?p=773535#p773535, but did not see any response, except a lot of request for save/load.

Convoy also does take into account when stations are nearby, so in contrast to what the new buzz word seems to be: "randomness", I think it's a better approach to take into account the stations that are already built in the neighbourhood, when there are stations, the spot to build a new station is not so attractive anymore. That is completely deterministic, but will provide nice results when competing against itself.

Convoy also has a setting aggressive, if it is false, it will try to keep away from opponents stations

Btw Convoy is undergoing major restructuring atm, and I'm adding train support. It does already make a profit with trains, but a lot less than with buses, so there's still some work to do.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Any "casual" AI available?

Post by Morloth »

I just messed around a bit with NoCAB and actually found a solution that works quite neat. Code follows below:

Code: Select all

function GetProduction(cargoID) {
   if (AIIndustry.GetLastMonthTransported(id, cargoID) == 0)
      return AIIndustry.GetLastMonthProduction(id, cargoID);
   else
      return AIIndustry.GetLastMonthProduction(id, cargoID) / (AIIndustry.GetAmountOfStationsAround(id) + 1);
}
This seems to work quite well. I tested on a small 128 x 128 map with 8 NoCAB AIs. I started with 4 and added the other 4 after 5 years, at that point most industries were already connected and the new NoCAB instances simply sat put and didn't build anything, except for one who daringly created a bus connection with 2 busses... All instances made profit (except the ones who didn't do anything). I'll experiment a little bit with this setup and see if improves performance when playing against other AIs.

For those who want to test I've included a download below. One disadvantage of this method is that it doesn't take into account how much cargo is transported by the opponents, but simply assumes all of it is (which is quite reasonable). A bigger issue is how this deals with industries which produces multiple types of cargo. We do not discriminate nor can we due to API restrictions, so this will have to suffice for now.

Just did a small test with 4 AdmiralAI instances on the same map with 1 NoCAB instance and it seems AdmiralAI is quite hell bend on the 'best' industry, it also crashed a couple of times but these are known issues. It was quite funny to watch how NoCAB stayed away from industries 'occupied' by AdmiralAI and did quite well. I think this is a way forward but I think it will take a while to come up with a good estimate of how to take the competition for a certain resource into account. Adding functions to the API to reveal more information will certainly help.

- Bram
Last edited by Morloth on 08 Apr 2009 01:19, edited 1 time in total.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Any "casual" AI available?

Post by Bilbo »

But how can you know that the station is used to service that industry (it could service some town nearby...) and in what way? Especially with factories it is important to know whether the station is used to bring in raw materials or take goods or both.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Any "casual" AI available?

Post by Morloth »

Bilbo wrote:But how can you know that the station is used to service that industry (it could service some town nearby...)
http://noai.openttd.org/api/classAIIndu ... 8b978e208f
Bilbo wrote:... and in what way? Especially with factories it is important to know whether the station is used to bring in raw materials or take goods or both.
These last are unfortunately restrictions of the current API I haven't found a way to overcome (if it's possible to do so). But like I said this solution would suffice for now.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Any "casual" AI available?

Post by Morloth »

GeekToo wrote:
defaultluser wrote:I thought I'd throw this into the fray:

Did you save and reload your game at any time during this play-through? Convoy is notorious for not having Load/Save support.
And there's a good reason for that, it wouldn't benefit much if it did, and I explained it some time ago:
http://www.tt-forums.net/viewtopic.php?p=773535#p773535, but did not see any response, except a lot of request for save/load.

Convoy also does take into account when stations are nearby, so in contrast to what the new buzz word seems to be: "randomness", I think it's a better approach to take into account the stations that are already built in the neighbourhood, when there are stations, the spot to build a new station is not so attractive anymore. That is completely deterministic, but will provide nice results when competing against itself.
Funny :). Yeah I do think randomness can have some advantages but ultimately you want to make more informed decisions where to build. I think this approach will work just fine. I only notice that Convoy stops building after some time, so you might want to review your settings. I've got a feeling they are a bit strict at the moment. I'll also check if Convoy is set to aggressive on default, this might help solve this problem.
GeekToo wrote:Btw Convoy is undergoing major restructuring atm, and I'm adding train support. It does already make a profit with trains, but a lot less than with buses, so there's still some work to do.
Great! Can't wait :D. What pathfinder are you using, the one from the library or a default one? Still looking for a implementation of trains in which stations can 'evolve', i.e. grow over time. FelicitusAI looked really promising but its author has been busy with another project :cry:. I'm still looking for a good implementation to port 8).
sucinum
Engineer
Engineer
Posts: 17
Joined: 06 Apr 2009 19:46

Re: Any "casual" AI available?

Post by sucinum »

A station only collects good which are actually transported. For example, if you connect 2 banks and have lorry stations in the middle of the town, you will never see a single piece of mail there unless you start sending mail trucks. This works the same for factories. If there are no goods and no rating for it, they are not collected. That's ofc what i check as human, the AI might handle this differently ;)
I'm quite sure that was different in vanilla TT btw.

I'm also not too sure if it's fun to play against an AI which is "done" after 5 years, when the whole game lasts 100 yrs. It would be awesome to drop old lines and replace them by longer/more expensive ones (with higher revenues). Surely this will take longer on a 1024² or even larger map.

Going to test the attached file, can upload a save later if you like to check. It's a game on hard diff, no ther AIs involved, 1024². I just play along as usual (maybe a bit more expansive compared to when i played with the vanilla AI ;))

/edit: uploaded the file, not much to see. Of 7 AIs (all friendly noCab), only 1 did any actions, the others simply idled. Restarting them didn't help. The one actually build some decent ship lines and managed to stay even with my gains, even though i had a headstart of half a year. Wasted some cash on a bad connection, though. We didn't interfere.
Attachments
sucinum niceCab-test, 3. Dez 1944.sav
(1.38 MiB) Downloaded 114 times
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Any "casual" AI available?

Post by Morloth »

sucinum wrote: /edit: uploaded the file, not much to see. Of 7 AIs (all friendly noCab), only 1 did any actions, the others simply idled. Restarting them didn't help. The one actually build some decent ship lines and managed to stay even with my gains, even though i had a headstart of half a year. Wasted some cash on a bad connection, though. We didn't interfere.
Autch... loading time is really nasty if it has to load 7 of those :X. But I don't understand why they don't do anything... it really makes no sense. I also notice that it get stuck after loading on a larger map. See what I can do, thanks for testing! :)

\edit Arg! Same issue as before, the name of all AIs after the first was to long... New version! :)
Attachments
NoCAB.tar
NiceCAB - Based on version 1.17
(280 KiB) Downloaded 132 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Ahrefs [Bot] and 12 guests