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


McZapkie
Tycoon
Tycoon
Posts: 1176
Joined: 18 Jan 2014 18:10

Re: CivilAI

Post by McZapkie » 05 Jun 2018 13:46

Is it possible to change company settings from the AI level?
I found AIGameSettings::GetValue, but not SetValue.
What I want to do is to change company setting to enable sharing depots (using IS patch).
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 05 Jun 2018 14:20

What I want to do is to change company setting to enable sharing depots (using IS patch).
Not sure how this is related to CivilAI, but have you tried switching into the company (via the cheat menu) and turning on the IS options yourself?

McZapkie
Tycoon
Tycoon
Posts: 1176
Joined: 18 Jan 2014 18:10

Re: CivilAI

Post by McZapkie » 05 Jun 2018 14:37

Sorry for hijacking your thread :)
The problem is, that I'm using CivilAI on my server, and it is not possible, AFAIK, to jump into AI in multiplayer mode,
therefore was my attempt to change AI code.
Saving game and restarting server with changed save is not convenient due to password issues.
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

User avatar
romazoon
Tycoon
Tycoon
Posts: 1288
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon » 06 Jun 2018 12:19

Very nice to see that awesome AI get even better, Thank You Pikka !

Now i ve made some observation in a small test game :

- Choice of vehicle from AI is debatable, in my test, AI thought it s a good idea to use the very slow but high capacity vehicle from HEQS to transport Food. The vehicle loose money and the AI don t seems to care about it (it s sent to depot after loosing money for a moment, only to be replaced with the same vehcile), also it cause jams on the roads. I understand we can t avoid totally those jams with articulated vehicle, but maybe your AI could avoid selecting amongst the slowest vehicles when it intend to travel relatively far (in my game it choosed a slow vehicle to travel over 140 tiles (flight distance, i haven t counted the exact road distance). Imho those kind of vehicle should probably not be used for distance over 40 tiles.
Muir & Co., 17_01_1997.png
(267.12 KiB) Not downloaded yet
- Road construction from AI, i have been surprised on how the AI build a lot of roads for nothing, doubling existing ones, creating dead ends.... I would say it s not enough reusing existing roads, it tries to be more efficient that way i supose (but fails at it in a few cases). It makes some very ugly road.
Muir & Co., 17_01_1997#2.png
(344.82 KiB) Not downloaded yet
In this screenie all the doubling of road have been made by AI, and they are all useless. In the down right corner of the screen, it s two Civil AI competing to lay as most road as they can it seems...even though a "not owned road, from the scenario" was already going through there.

If you wanna test and see for yourself how Civil AI is not enough reusing existing roads imho, i ve done my Test in Cindini, wich does already have a relatively dense road network from start.


- Ships, lovely addition, but is full load really a good idea ? i think with cargodist being used full load should be avoided (i imagine nowadays the majority of players uses it)... but at the same time i can understand why full load is a good idea if cargodist is off (avoid that busses let not enough passengers for the ships).


I haven t seen much else wrong for the moment, and i ve been rather impressed by the couple trains lines some of the Civil AI have built, they seemed very reasonable for AI !

McZapkie
Tycoon
Tycoon
Posts: 1176
Joined: 18 Jan 2014 18:10

Re: CivilAI

Post by McZapkie » 06 Jun 2018 13:19

Once more about roads: seems that it have problems with connecting to bridges, many times I observed dead ends like in attached picture.
Another issue is, that AI cannot handle with sea shore, if removing of water is blocked (via patch or high base costs),
see left corner - unfinished route. Similar problem with bridges on sloped sea shore, it should start one tile earlier with higher bridge to avoid possible bridge building failure (such bridge also looks better without ships clipping glitches).
Attachments
civilai-b.png
(214.42 KiB) Not downloaded yet
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

vrn
Engineer
Engineer
Posts: 63
Joined: 07 Mar 2018 17:00

Re: CivilAI

Post by vrn » 06 Jun 2018 16:18

romazoon wrote: - Choice of vehicle from AI is debatable, in my test, AI thought it s a good idea to use the very slow but high capacity vehicle from HEQS to transport Food. The vehicle loose money and the AI don t seems to care about it (it s sent to depot after loosing money for a moment, only to be replaced with the same vehcile), also it cause jams on the roads.
Yes, these crawlers seem to be a popular choice among AIs (not only CivilAI), which is why I only enable the core vehicles and trams of HEQS when playing with them.

By the way, when playing with DBSetXL, CivilAI chooses two different wagon types for the same train. It's not a big problem since both can load the same amount of wood, I just found it funny and don't know if it is intentional.
Attachments
DB AIs, 22nd Jan 1962c.png
DB AIs, 22nd Jan 1962c.png (190.42 KiB) Viewed 4920 times

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 08 Jun 2018 11:57

McZapkie wrote:Another issue is, that AI cannot handle with sea shore, if removing of water is blocked (via patch or high base costs)
I'm not sure it's reasonable to expect the AI to cope with arbitrary base cost changes, much less patched versions of OpenTTD. It's a road building AI and will struggle in an environment hostile to road building. That said, I suspect setting buildroad.cost.coast to a high value at line 2191 might help.
romazoon wrote:- Choice of vehicle from AI is debatable, in my test, AI thought it s a good idea to use the very slow but high capacity vehicle from HEQS to transport Food.
I hadn't considered HEQS when testing - I can certainly tweak the vehicle selection code to avoid such wide outliers. :)
romazoon wrote:- Road construction from AI, i have been surprised on how the AI build a lot of roads for nothing, doubling existing ones, creating dead ends.... I would say it s not enough reusing existing roads, it tries to be more efficient that way i supose (but fails at it in a few cases). It makes some very ugly road.
Pathfinder values are always a difficult balancing act (and "ugly" is in the eye of the beholder). The AI does do a lot of rechecking connections, and this can result in some duplicated roads. You could try tinkering with buildroad.cost.no_existing_road at line 2168, and see if you can find a value that produces more pleasing results.
romazoon wrote:- Ships, lovely addition, but is full load really a good idea ? i think with cargodist being used full load should be avoided (i imagine nowadays the majority of players uses it)... but at the same time i can understand why full load is a good idea if cargodist is off (avoid that busses let not enough passengers for the ships).
Very short ('water-bus' style) ship routes don't use full-load. For the longer routes, they're more analogous to aircraft - they're better off sitting raising the station rating than zooming back and forth empty. Cargodist or not, full-load or not, ships rarely make the AI much money; the ships, and the AI in general, are primarily to create pleasant background movement for human players, rather than to play the game as efficiently as possible itself.
vrn wrote:By the way, when playing with DBSetXL, CivilAI chooses two different wagon types for the same train. It's not a big problem since both can load the same amount of wood, I just found it funny and don't know if it is intentional.
Yes, it's intentional - the AI will build mixed trains (if more than one suitable wagon exists) for piece cargos like wood.

McZapkie
Tycoon
Tycoon
Posts: 1176
Joined: 18 Jan 2014 18:10

Re: CivilAI

Post by McZapkie » 08 Jun 2018 12:17

I got client crash with following error:

Code: Select all

Error: Assertion failed at line 281 of ~/JGR/src/ai/ai_core.cpp: c != NULL && c->ai_instance != NULL
Not sure if it should be report to JGR patch maker, seems that is is AI related?
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 08 Jun 2018 18:18

McZapkie wrote:Not sure if it should be report to JGR patch maker, seems that is is AI related?
I don't know, but there's certainly no point reporting it to me.

User avatar
romazoon
Tycoon
Tycoon
Posts: 1288
Joined: 20 Jun 2010 23:16

Re: CivilAI

Post by romazoon » 09 Jun 2018 00:37

thanks for the answers ;)
PikkaBird wrote:Pathfinder values are always a difficult balancing act (and "ugly" is in the eye of the beholder). The AI does do a lot of rechecking connections, and this can result in some duplicated roads. You could try tinkering with buildroad.cost.no_existing_road at line 2168, and see if you can find a value that produces more pleasing results.
of course "it s ugly" is as subjective as it can be and that s not a point i should have raised, inneficiency would have been a more proper term i guess...anyway you knew what i meant i think.
Now i d love to try tinkering a bit with this value, unfortunately i think would not know where to look for this value so i guess i ll just hope someone find pleasant settings and share the customized AI then ;) (or is that value modifiable in game with an AI developer setting turned on ? )
PikkaBird wrote:Very short ('water-bus' style) ship routes don't use full-load. For the longer routes, they're more analogous to aircraft - they're better off sitting raising the station rating than zooming back and forth empty. Cargodist or not, full-load or not, ships rarely make the AI much money; the ships, and the AI in general, are primarily to create pleasant background movement for human players, rather than to play the game as efficiently as possible itself.
i haven t seen the short ship route yet, so it s good to know AI do adapt orders to profile of the route. and indeed ships were not good money maker in my test...but my settings for ships were far from optimal running cost wise too, so wasn t too surprised about that ;)
Now my concern about full load and cargodist was more about how it (might ?) mess cargodist links calculation. I m no sure about it, but i always thought (feeling from user experience, so i ll be happily proven wrong) full load cargo would end up making cargodist believe the capacity of line is zero and so in the AI case, that means ships staying for very very long, which indeed they were, but can t say the outcome on the long run as test stoped quite shortly after last report i made. i shall test further and report when i get some time ;)

User avatar
andythenorth
Tycoon
Tycoon
Posts: 4927
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: CivilAI

Post by andythenorth » 10 Jun 2018 06:27

romazoon wrote:full load cargo would end up making cargodist believe the capacity of line is zero
FWIW, cargodist does not measure route capacity when assigning cargo to a next hop. So that should not be a problem here ;)

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 24 Jun 2018 03:36

Okay, Version 16:

- Intercity road connections are now built via a middle point, to make connecting cities faster and more reliable.
- Tweaks to the road pathfinder values to (possibly) reduce route duplication and messy road junctions.
- AI will not build trucks with top speed below 40km/h if faster vehicles are available (to avoid building HEQS crawlers).

Now up on Bananae.

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 28 Jan 2019 07:13

Version 17, just a couple of minor bug fixes.

- do not include mail, goods and food trucks in towncar count (Apparently I haven't tested town cars since version 6!)
- fixed the AI not building airports when noise level feature is disabled.

BW89
Engineer
Engineer
Posts: 79
Joined: 10 May 2015 11:42

Re: CivilAI

Post by BW89 » 30 Mar 2019 10:14

Could you add a setting to disable Aircrafts and Airports completely?

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 30 Mar 2019 10:21

There's a game setting to disable aircraft for AI. Is there some value to being able to turn them on and off on a per-AI basis, do you think?

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 03 Apr 2019 19:39

Version 19 is now on Bananas. This is a major update and requires OpenTTD 1.9.0 or later.

Unfortunately, passenger trains didn't quite make it in - they'll be in v20. ;)

Changelog:

Version 19:
- Minimum OpenTTD version is now 1.9.
- This update has extensive rewrites of a lot of existing code. Please do report any odd behaviour or crashes.

Features:
- Added 2cc company colours, and different colours for different vehicle types.
- AI has a configurable option to not build an intercity road network, but just to build within towns in its radius.

Tweaks:
General:
- Reworked selection code for vehicles and added company biases towards big, cheap, or fast vehicles, to add some variety between companies and games.
- Reworked the freight train route selection code, for performance and extendability.
Aircraft:
- AI has alternative behaviour to build airports if road vehicles are disallowed.
- AI will build an initial aircraft as soon as it has two airports.
- AI will attempt to replace small airports with commuter airports (attached to a different station in the same town) after commuter airports become available.
- Increased the maximum number of aircraft servicing each small and commuter airport (from 3 and 6 to 5 and 10 respectively).
Ships:
- AI will now build only two ship docks per town.
- AI will not build ferries with a capacity less than 50 if larger ferries exist (to avoid building FISH/Squid trawlers).
Road Vehicles:
- Increased the maximum maximum bus count from 500 to 5000, as requested by Samu on IRC (the default maximum remains 250).
- AI will now build only two mail truck stops per town.
- AI will wait 10 years before trying to build a bus network in a town it previously failed to build enough stops in.

Bug fixes:
- fixed the AI sometimes failing to build goods trucks (because it was trying to build them in another company's depot, whoops).


Version 18:
- There is no version 18 - version number bumped to 19 to coincide with OpenTTD 1.9.

buttercup
Traffic Manager
Traffic Manager
Posts: 131
Joined: 22 Jan 2007 20:19

Re: CivilAI

Post by buttercup » 06 Apr 2019 03:42

PikkaBird wrote: AI will build an initial aircraft as soon as it has two airports.
In my test games with infrastructure maintenance turned on (running costs on medium; no NewGRFs), CivilAI only ever built a single airport but its income wasn't high enough to cover the maintenance cost of even that one, so it kept going bankrupt.

Is it possible to check whether infrastructure maintenance is turned on - or perhaps even check what the actual current maintenance cost of an airport is - and postpone building any airports until it can afford it?

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: CivilAI

Post by PikkaBird » 06 Apr 2019 04:11

I've generally been avoiding adding setting tests - there's just too many variations. This one seems to be a common enough cause of bankrupcy that I suppose I can make the exception. :)

Edit: done, will be in v20.

BW89
Engineer
Engineer
Posts: 79
Joined: 10 May 2015 11:42

Re: CivilAI

Post by BW89 » 06 Apr 2019 15:52

Could you add a feature that the AI would add a Busstop in Villages when a IC bus would drive through it without stopping?

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests