CivilAI

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

User avatar
Arexander
Engineer
Engineer
Posts: 99
Joined: 31 Jan 2011 16:51
Location: Farming stuff

Re: CivilAI

Post by Arexander »

planetmaker wrote:Did you in install the AI using the ingame content download?

You're missing one of the required libraries, road pathfinder in version 4.
I did, and it worked just fine the last time I tried. Only today did it start disagreeing with me. I'll redownload it and see if it fixes it.

EDIT: Nope, it still crashes with the same error.

EDIT2: Downloading the library manually solved the problem. I'm guessing there's a missing dependency somewhere along the line?
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

I often see this happenning(screenie)with your great CivilAI...should i report it as a bug ? it s not completely locked...but it s pretty far from optimal as they all struck each others and probably make an average speed of 2 or 3km/h...

Also when replacing vehicules, it seems to keep the old in the depot quite a while.

also, even though i setted the town to serve from minimum 500 pop, it doesn t serve many....the second town to have service waited 50 years of service

and last, but i suspect it s wanted behavior, this AI never make bus network, or try to make an intercity connection to the towns and cities i serve already...even sometimes town where i only deliver food and do nothing else there. so is that intented ?

anyway, other than that i find it really good at linking town by road, good job on that.
Attachments
Marnham Transport, 14 Mar 2096.png
(394.83 KiB) Downloaded 7 times
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

sorry for the bump, i have a feeling that pikka probably never seen my last report...so here is one more report for the same problem in a hope to see a fix to this gridlock made by civilai's bus.

also i have a few question : how CivilAI decide to make intercity service ? it seems to always fails to set any intercity lines in my games. It also seems to fail often at creating "inner city" bus network as after 100 years, my civilAIs tend to serve around 2/3 towns/city (i use some newgrf or settings that makes it harder than a vanilla game maybe ? ). As an exemple, even setting lower population to start creating a network don t make the AI more "activ".
Attachments
CivialAI bug 1.png
(370.04 KiB) Downloaded 6 times
CivilAI bug 1.2.png
(350.5 KiB) Downloaded 6 times
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

That's quite a mess. :) Perhaps I can add some more sensibility checks - on the other hand, clogging up the inner cities with traffic is kind of the point of this ai. In the meantime, perhaps reduce the maximum number of buses the ai is allowed to build?

To the other question, the ai "plays nice" and will not build buses in towns which already have reasonable passenger services.
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

thanks for the answer Pikka,

about limiting max number of bus, i avoided that solution because "i wanted" to see the civil AI taking care of many "city/town" or "intercity" service.

about the traffic jam result of "entraffic" roads, well if the bus were full of passenger i d probably think that traffic jam are normal results...but here there is way too many bus for the demand (and capacity of roads). The Ai seems to not adapt number of bus to the "demand" (wich would be damn nice if it did).

just to be more clear on how this bug might happens, it takes a really long time ingame (i d say around 100years) to see the bus gridlock (ai need to have made quite a bunch of money before it happens...and turning off or having a very low infra road cost is necessary to see it happens, otherwise the AI goes bankrupt before reaching that point)

and thanks for clarification on the limititation of the AI to build in "already serviced" towns.

now is here a few other bugs i ve seen with CivilAI:

- i ve seen AI building their HQ in cities and then not being able to build a depot... this seems to happens when the ai choose a town that don t have a "road" piece on the town seed tile (one tile under the name). -> problem with that is the AI stay for years before bankrupting (it s says in its name it failed though) and "relaunching" this AI is no solution as the AI will pick up the same town to start with (the one with most population on the map and not yet serviced) . solution to this problem is to build manually the road on the seed tile, or to demolish a few building (reducing pop to not be the largest unserviced town) Then relaunch the Ai.

- old vehicles are sent to depot but not sold on arrival...they stay there for really really long time (I m not sure they are even selling them at some point)

- it picks always the bus with the max capacity, would be nice it was a bit more "random" or even better adapted to the number of passenger produced per town (i don t think towns producing 200 passengers needs to start with 4 bus with over 200 of capacity each )

- the intercity lines never get set up in my games.... is there a " max distance" limit ? a minimum population for the two towns that would be linked via intercity bus ?( i understand it don t pick the town i service, but there is really plenty of unserviced towns or cities in my game.)

- probably a few more things i forgot right now and dont have time to think about, but i will report back when i get time ;)
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

here is one more strange behavior , the max number of bus this AI should have is 500 bus..I haven t touched that setting since the AI started so i wonder what s happening.
Attachments
CivilAI Maxbussetting bug.png
(400.81 KiB) Downloaded 4 times
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: CivilAI

Post by Alberth »

Company merger?
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

nope no merge happened ;)
and most vehicles are stopped in the depot !
the others ones are strucked inside those massive traffic jam showed before :mrgreen:


Edit : i wonder if it s just because those Bus are so cheap to run that the AI just keep spamming them (they cost 38£ of maintenace per year, in other words next to nothing)

Edit 2 : the problem of multiplicating bus over the limit seems to happen at autoreplacement of vehicles. It buy a new one but don t sell the old one (in depot) and stop caring about the max bus limit of Civil AI. (look at vehicles number in company window inside the screenies )
Attachments
CivilAi multiplicatin bus 1.png
Civil Ai claim that it won t build more bus... and then autoreplace starts
(287.07 KiB) Downloaded 3 times
CivilAi multiplicatin bus 2.png
number of max bus ? who cares ;)
(266.61 KiB) Downloaded 3 times
CivilAI multiplicatin bus 3.png
ok the banker said stop it s enough !! lol
(298.28 KiB) Downloaded 3 times
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

romazoon wrote:now is here a few other bugs i ve seen with CivilAI:

- i ve seen AI building their HQ in cities and then not being able to build a depot... this seems to happens when the ai choose a town that don t have a "road" piece on the town seed tile (one tile under the name).
Towns not having a road seed tile causes all kinds of problems (it prevents the town from growing) and only happens if a player or scenario builder has manually removed the tile. Currently the AI checks for this while road building, I'll add a check during initial town selection. I think I'll randomise the initial town selection a little too.
- old vehicles are sent to depot but not sold on arrival...they stay there for really really long time (I m not sure they are even selling them at some point)
The AI has a couple of depot-cleaning cycles a year. However, if one of its other cycles takes too long it gets "distracted" and might miss a cycle. It's not that big a problem, is it?
- it picks always the bus with the max capacity, would be nice it was a bit more "random" or even better adapted to the number of passenger produced per town (i don t think towns producing 200 passengers needs to start with 4 bus with over 200 of capacity each )
It picks the largest bus for local services and the fastest for intercity. Over 200 capacity is not "normal" for a OpenTTD bus.
- the intercity lines never get set up in my games.... is there a " max distance" limit ? a minimum population for the two towns that would be linked via intercity bus ?( i understand it don t pick the town i service, but there is really plenty of unserviced towns or cities in my game.)
Intercity services are only established between cities which already have bus stops in them. Again, I can take a look at the criteria it uses to set them up. If you have a very large map (and I notice in your settings you have the maximum spread set much higher than default) this might also be the result of pathfinding taking so long that it skips other cycles.
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

PikkaBird wrote:Towns not having a road seed tile causes all kinds of problems (it prevents the town from growing) and only happens if a player or scenario builder has manually removed the tile. Currently the AI checks for this while road building, I'll add a check during initial town selection. I think I'll randomise the initial town selection a little too.
well they do are able to grow "nowadays", it s true in the oldtime though that seed tile were important, but now i think road can be somewhere around 3 to 4 tiles away from the seed and it s no problem for growth.
but now i guess you are right on the fact that i play a handmade scenario and there is probably a few towns that have seen change in their original road layout.
and yay for randomizing starting point ;)
PikkaBird wrote:It's not that big a problem, is it?
no sure it s not a big problem, or is it ? the max bus limit will be hit sooner (ok it s not really caring of the bus in the depot so far, but i ve yet to see it reach max number of roadvehicles and maybe that will become a problem ?)
PikkaBird wrote:It picks the largest bus for local services and the fastest for intercity. Over 200 capacity is not "normal" for a OpenTTD bus.
well that s a matter of taste mostly isn t it ? and since Cargodist is in trunk they are a necessity. At least for the players liking to connect many stations inside large towns. and while thinking about it, even your CivilAI would not be able to cope with the passenger it has to carry if there were not those "super heavy duty" bus from Ikarus set.
PikkaBird wrote:Intercity services are only established between cities which already have bus stops in them
yes i think i found out, it need existing stops and many people waiting in them. i made a new test game with a few civilAi and seen at least once an intercity service getting built....and driving directly the company to bankrupcy because it could not handle the flow of people sent by cargodist and the trip was a huge detour for most of the traveller (no complain here just reporting what i see, i understand it s impossible to make an AI that deal with cargodist, so maybe an idea would be to make it a parameter, allowing the AI or not to set intercity services to avoid that problem).

and on the subject of max spread, yes i was hoping the civil ai to build all the roads for me on a 2048x2048 map :mrgreen: , but i reduced that in my test, and i effectively see a "more active" AI, building more roads and bus services with settings lower than 512.


Also i have a new question regarding using more AI at the same time, are they all sharing the opcode limit ? I use a scenario with 10000 opcode limit, and i was wondering if this could also impact on the effectiveness of the AI if there is not enough opcode because too many AI or too big maps.
And if there is an impact, if there is a way to increase that opcode limit in a running game ( i swear ;) i searched and found next to nothing about opcodes)
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Alright, version 4 is now on Bananas. I've addressed most of the issues you had but bear in mind that the point of this AI is to clog up the inner cities with traffic. ;)

Changes:

- Increase default network size from 256 to 512 tiles radius.
- Disallow setting up in towns with no centre road tile.
- Set up in a random town which meets the size and unserviced criteria, rather than the largest.
- Replace "monthly" tasks with a constant cycle. AI now builds faster and will not skip tasks.
- Tweaked conditions for building intercity bus routes to make them more common.
- Slightly reduced maximum number of buses per route to relieve city crowding.
- Added building small airports and air routes. Yes, really!
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

There was a small crash bug in version 4. There is now a version 5. :)
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon »

This is Awesome sir !!! Thank you very very much ;)
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

I've taken my somewhat naive coding style out for another spin. :) An update is now available on Bananas.

version 6:

Air network tweaks:
- Prevent building new airports too close to all existing airports.
- Redirect a few existing aircraft to newly built airports to refresh the air network.

Road network tweaks:
- Make our vehicle list nicer to look at by grouping cars and buses separately.
- Build a depot in large towns even if we're not building buses, to keep town cars spread out.
- Remove rail crossings and rebuild as bridges following collisions.

I think the next task is moving CivilAI into "proper AI" territory and building some trains. :) That's a big job though.

Next version I'll also take the no-random flag out, because it's a pretty competitive AI now I think - and also runs multiple instances quite happily.
xarick
Transport Coordinator
Transport Coordinator
Posts: 336
Joined: 26 Feb 2015 00:52

Re: CivilAI

Post by xarick »

Hi. It survived my test of 100 years without crashing. There are some nasty bus jams, though. It seems to me that it would benefit better if it built bus stations near the outer edges of already large towns, it focuses in the inner center most of the time.

It is relatively slow and has a hard time starting up and making money. But it's still impressive to watch it slowly expanding the road network across the map.
Attachments
Refingley Market Engineering, 1st Apr 1950.sav
(456.16 KiB) Downloaded 169 times
openttdCore6.cfg
(10.77 KiB) Downloaded 163 times
Refingley Market Engineering, 2051-01-26.png
Refingley Market Engineering, 2051-01-26.png (286.61 KiB) Viewed 8353 times
Formerly known as Samu
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

CivilAI version 7 is now on Banananananas.

This is a major update, and adds trucks and trains to the AI's repertoire, as well as tidying up a lot of its earlier behaviour. It should now be considered a "normal" competitive AI rather than a specialist oddity, although hopefully it's kept its general "civility" and pleasant construction style.

Changes in v7:

- Added better company and owner names.

Trucks added:
- CivilAI will now build trucks for mail, goods and food.
- Truck stops are added to busy bus stops for mail pickup and goods delivery.
- Supply depots are built near goods- and food-producing industries to supply cargos to towns.

Trains added:
- CivilAI will build short train lines to support goods- and food-producing industries, power plants, and water towers.
- Known issue: since (by design) the AI only builds non-electrified railways, it can't build default trains after the 20th century.

Air network tweaks:
- Increased the default minimum air route distance from 80 to 128 tiles.
- Made sure redirected aircraft are redirected from the correct airport.
- Improved land levelling for airport construction.

Road network tweaks:
- simplified the ugly "loop" built at outer bus stops - these never worked properly and were just clutter.
- Tweaks to when and how many vehicles are bought.
- Improve road network integrity by scanning for lost vehicles.
- Simplify crossing replacement code (which never really worked).
- More conservative network construction:
- Road network construction search now limited to towns the AI can build in.
- The AI will only expand the road network once it has built up the network it has, to avoid spending all its money on roads early on.

- CivilAI no longer funds roadworks, because that's not very civil.
- Various other tweaks and fixes.
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: CivilAI

Post by Brumi »

Whoa, this is a very welcome addition, I need to try it :)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: CivilAI

Post by Brumi »

Seems very good so far!

First I accidentally started a game with FIRS (with OpenGFX+ Trains and Road Vehicles). The AI didn't scream at all, was working without problems. But when I realized it, I started a vanilla game.

Some highlights:
  • It reuses already existing train stations and rails! Cool!
  • I also really like the names it gives to its trains :)
  • No crashes whatsoever so far.
But: for some reason, all its trains have Kirby Paul Tank engines, even in 1987. Maybe the AI got its train valuator upside down?
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Brumi wrote:But: for some reason, all its trains have Kirby Paul Tank engines, even in 1987. Maybe the AI got its train valuator upside down?
Hehe...

The AI likes little engines for its short railways. :) Obviously with the default trains, it doesn't have too many options.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Well, a few people have downloaded the update and I've had no bug reports, so here's v8.

Changes:

- Added Water to the cargos to be trucked to towns.
- Cargo truck selection now prefers native vehicles over refits, like train wagons.
- Minor bug fixes.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: xarick and 10 guests