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

Post Reply
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

CivilAI

Post by PikkaBird »

CivilAI version 37 is now on Banananananas, released January 9th 2022. OpenTTD 12.0 or later is required.


v20 was a major update which finally introduces passenger, mail, food and goods trains, and tidies up and reworks existing features to make CivilAI faster and better than ever before!
Please report any crashes or odd behaviour! Discussion of the latest version starts here.

v7 was 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.

An AI which builds a road network and fills it with buses and town cars.
CivilAI is my first AI, and one I've been meaning to make for a while. It builds an inter-city road network and entraffics it with buses and, if available, town cars (which it defines as "vehicles with 0 running cost and a capacity of less than 10"). It's non-competitive in that it will avoid building a bus network in towns which already have good passenger service, but it does usually manage to sustain itself. Give it a go, see how it does! And if you look at the code, don't laugh too hard; I was learning as I went.
You can download CivilAI from Bananas - the current version is version 6. It has no dependencies except the default road pathfinder, but it does enjoy a good road vehicle set and some eyecandy town cars. OpenTTD 1.4 or later is required.
Last edited by PikkaBird on 09 Jan 2022 01:45, edited 33 times in total.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CivilAI

Post by Kogut »

It works, it connected nearby town - but instead of adding some bus service it started connecting next towns. Is it expected ("builds an inter-city road network and entraffics it with buses")?

Due to low number of RV it was unable to sustain itself in my test.
Last edited by Kogut on 09 Feb 2014 11:45, edited 3 times in total.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: CivilAI

Post by Brumi »

Nice to see you developing an AI :)

I got a crash on the first run, and it crashes with the same reason even after restarting:
civilai.png
civilai.png (20.09 KiB) Viewed 9828 times
I am using OpenTTD 1.3.3, and no NewGRFs were used which should affect your AI.
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:Nice to see you developing an AI :)

I got a crash on the first run, and it crashes with the same reason even after restarting:
civilai.png
I am using OpenTTD 1.3.3, and no NewGRFs were used which should affect your AI.
Ooh... I guess it needs a newer version than 1.3.3 then. :)

Yep... HasCargoRating is new in 1.4.0... I should change the required version number. Whoops.
User avatar
kamnet
Moderator
Moderator
Posts: 8532
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: CivilAI

Post by kamnet »

Seems nifty so far! I like how the passenger cars all get individually named. Eyecandy Road Vehicles also works pretty well.
User avatar
Dave
Moderator
Moderator
Posts: 17243
Joined: 26 Dec 2005 20:19
Location: North London

Re: CivilAI

Post by Dave »

Another Pikka creation that will become a cornerstone of my game, I've no doubt.
Official TT-Dave Fan Club

Dave's Screenshot Thread! - Albion: A fictional Britain
Flickr


Why be a song when you can be a symphony? r is a...
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Kogut wrote:It works, it connected nearby town - but instead of adding some bus service it started connecting next towns. Is it expected ("builds an inter-city road network and entraffics it with buses")?

Due to low number of RV it was unable to sustain itself in my test.
It's hard to tell without a save game or screenshot, but perhaps its initial town was too small or hilly to build its bus stops. In that case, if it manages to connect to another large town before it runs out of money, it will try building a bus network there. If not, oh well; not much it can do. :)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CivilAI

Post by Kogut »

It constructed bus stops in initial town but it was not enough to survive burden of 500k initial loan used to build roads. Are you interested in save where this happens or is it something expected for this special purpose AI?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Kogut wrote:It constructed bus stops in initial town but it was not enough to survive burden of 500k initial loan used to build roads. Are you interested in save where this happens or is it something expected for this special purpose AI?
Ah. Well, it certainly can overextend itself if it builds roads faster than it builds buses. :) Especially with a high initial loan and infrastructure maintenance costs turned on.

It really is a special purpose AI, so I'm not too worried about it. One thing I might do in future versions is randomise the starting location slightly, so that if it does start somewhere difficult and go bankrupt its replacement may try and start in a better place.
User avatar
kamnet
Moderator
Moderator
Posts: 8532
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: CivilAI

Post by kamnet »

One thing I noticed - the inter-city bus stations will be built with a small loop of road, but the buses won't actually use them, preferring to turn around at the end of roads.
Attachments
civilai.png
civilai.png (11.79 KiB) Viewed 36391 times
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

True! That's just the vehicle pathfinder, I guess, and nothing I or the AI can help. :)
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: CivilAI

Post by Michiel »

PikkaBird wrote: CivilAI is my first AI, and one I've been meaning to make for a while. It builds an inter-city road network and entraffics it with buses and, if available, town cars
Cool! And I just wanted to say that "entraffic" is a wonderful word :)
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: CivilAI

Post by skippern »

CivilAI is not showing up in my "download online content" menu, can it be that it has been released only for a newer version? I run OTTD 1.3.2 (should I be ashamed of myself?)
Skippern
OpenTTD Mac user
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CivilAI

Post by planetmaker »

skippern wrote:CivilAI is not showing up in my "download online content" menu, can it be that it has been released only for a newer version? I run OTTD 1.3.2 (should I be ashamed of myself?)
yes. And yes - because you didn't try a newer version like 1.4.0-beta nor read the first posting's last sentence:
PikkaBird wrote:A recent OpenTTD nightly or 1.4 beta is required.
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: CivilAI

Post by skippern »

planetmaker wrote:
skippern wrote:CivilAI is not showing up in my "download online content" menu, can it be that it has been released only for a newer version? I run OTTD 1.3.2 (should I be ashamed of myself?)
yes. And yes - because you didn't try a newer version like 1.4.0-beta nor read the first posting's last sentence:
PikkaBird wrote:A recent OpenTTD nightly or 1.4 beta is required.
:oops: :oops: :oops: Will update my version as soon as I get on a quicker and more stable internet line (before next weekend I hope) :oops: :oops: :oops:
Skippern
OpenTTD Mac user
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: CivilAI

Post by Wahazar »

I tried this particular AI to use within multiplayer game (dedicated server 1.4.3, see signature), but it fails.
One company slot is occupied by AI, but this company is "Unnamed" and do nothing (in multiplayer game).
If saved gamestate is loaded in singleplayer mode, AI works fine.
Of course Allow AIs in multiplayer is On, Disable road vehicles for computer: Off.
I'm not user if this particular IS failed, or it is my mistake.
I didn't tried others AIs, I just need one to build roads and use buses.

EDIT: I discovered, that ai_in_multiplayer = false is set in my server cfg - I set it true in scenario editor, probably it is ignored and taken from server cfg.
I never know which setting is client/company/server/game related.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CivilAI

Post by planetmaker »

McZapkie wrote:I tried this particular AI to use within multiplayer game (dedicated server 1.4.3, see signature), but it fails.
One company slot is occupied by AI, but this company is "Unnamed" and do nothing (in multiplayer game).
If saved gamestate is loaded in singleplayer mode, AI works fine.
Of course Allow AIs in multiplayer is On, Disable road vehicles for computer: Off.
I'm not user if this particular IS failed, or it is my mistake.
I didn't tried others AIs, I just need one to build roads and use buses.

EDIT: I discovered, that ai_in_multiplayer = false is set in my server cfg - I set it true in scenario editor, probably it is ignored and taken from server cfg.
I never know which setting is client/company/server/game related.
It's a bit tricky, but on the other hand it's not:
every setting which describes the map to some extend, which every player needs in order to continue the game is found in the savegame. All settings which are related to server operation, thus server-specific are not stored in the savegame. Neither are stored those settings which are player-specific (like language, unit settings, money settings, signal density...). There are only very few company-specific things, like company colour, which actually need exchange.
User avatar
Arexander
Engineer
Engineer
Posts: 99
Joined: 31 Jan 2011 16:51
Location: Farming stuff

Re: CivilAI

Post by Arexander »

I'm getting the following error from the AI whenever it tries to start a company. I got the same message in 1.4.2 and now, after updating, in 1.4.3 as well. Any clues?

Image
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CivilAI

Post by planetmaker »

Arexander wrote:I'm getting the following error from the AI whenever it tries to start a company. I got the same message in 1.4.2 and now, after updating, in 1.4.3 as well. Any clues?

Image
Did you in install the AI using the ingame content download?

You're missing one of the required libraries, road pathfinder in version 4.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: CivilAI

Post by Wahazar »

I got similar error, moving library from content_download/ai/library to ai/library solved problem.

On the other hand, AI still is refusing to build anything, despite of proper settings of ai_in_multiplayer = true both for server config.cfg
and scenario (server is starting with -g "scenario.scn" option).
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Google [Bot] and 6 guests