[AI] CityLifeAI 1.0

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

How would you rate this AI?

5★ Metropolis
6
86%
4★ City
1
14%
3★ Town
0
No votes
2★ Village
0
No votes
1★ Hamlet
0
No votes
 
Total votes: 7

User avatar
Firrel
Engineer
Engineer
Posts: 90
Joined: 13 Aug 2019 17:06

[AI] CityLifeAI 1.0

Post by Firrel »

CityLifeAI

Have you ever been stuck behind a horse ridden carriage or a very rude cyclist when travelling to work? This will provide this experience and more!

Image

How this works:
Populates villages, towns and cities with traffic of eye candy vehicles available in several newGRFs. The vehicles are split into several categories: cars, mail trucks, service vehicles. The AI manages the number of each category dependent of the size of the city. No more five fire trucks in a small village.

By providing outstanding public services to the city, more people decide to use it, so the private transportation decreases. Also transporting mails decreases the number of small companies that provided this service, taking them out of business and out of traffic.

This AI was designed to support NRT roads of "any" kind. On top of that, when the city reaches enought population, they decide to finally connect to the nearby towns. However some of them are corrupt and use up the money without building anything or hire some questionable builder to build unconnected roads. But if they succeed, they celebrate it in a big way!

For more information, read the readme file:
readme.txt

Settings:
You can't change the decisions of the cities, they act on their own, no amount of trees can solve it.

Requirements:
- OpenTTD, v. 1.10.x or newer.
- SuperLib v. 40, SCPLib v. 45, AIToyLib v. 1 (all available in BaNaNaS and OTTD's "Online Content").
- Any eye candy road vehicle newGRF (with 0 running cost)
- Game Script which supports GSToyLib (otherwise it will bankrupt fast)

Recommended newGRFs and GS:
- Eyecandy Road Vehicles
- Funny Cars
- Generic Cars
- DROP
- Renewed Village Growth

Download:
The latest version can be downloaded from Changelogs and download links.
The development with source codes can be found in github: https://github.com/F1rrel/CityLifeAI

Changelogs and download links:
Version 2.4 by WalkedBy (2021/10/10)
CityLifeAI-2.4.tar
(69.5 KiB) Downloaded 6 times
[+] Spoiler
* ton of excessive unnecessary computations for Candy AI, makes 1.0 version unusable and blocks in game rewind
* buggy road building (bridges everywhere) which really should be optional
minor:
* AI/map car uncontrollable increase was possible because amount of cars was increasing lineary with city sizes
* candy cars are not updated with time, 1820 cars will stay all game up to 2100 and will block city traffic
* AI/map car overflow is prevented by using square root of population instead of linear steady grow
* some questionable calls removed from AI main loop to yearly/monthly/daily schedule
* AI will not try to build depots all game, only once
* all road building anyway not working and disabled, less safe part of script better be optional
* a bit more safety with small clean-ups and unnecessary while's replaced with for's
* numbers are adjusted for huge maps, i.e. slightly less density of cars per city
* added garbage truck (classic) other type
* (reupload 2.3) bugfix which prevented obsolete cars from updating without game save/load, should work fluently now in server mode

Version 1.0 (2021/07/12)
[+] Spoiler
- download link
* Initial release
Attachments
Release1.png
(1.02 MiB) Not downloaded yet
Last edited by Firrel on 10 Oct 2021 08:13, edited 4 times in total.
User avatar
Aegir
Tycoon
Tycoon
Posts: 2827
Joined: 09 Feb 2004 10:02
Contact:

Re: [AI] CityLifeAI 1.0

Post by Aegir »

This is amazing, I love it. Could do with some settings to control max amount of vehicles per population/etc. though as it can produce some VERY crowded maps. I guess that's part of the charm though? I mean I could run it fine on a 1k x .5k map in JGRPP on a Surface Go with no major slowdowns.
Former NewGRF Coder and Sprite Artist.

Currently working under the name 'reldred' on Github, IRC and Discord.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
MLG
Traffic Manager
Traffic Manager
Posts: 158
Joined: 07 Sep 2020 15:12

Re: [AI] CityLifeAI 1.0

Post by MLG »

Hi, I just went to test your AI, and have found a issue.
It builds roads with overhead wires even if it is pointless. Also it bulds roads with bridges and makes connection look absolutely ugly.
CityLifeAI.png
(711.81 KiB) Not downloaded yet
Would it be possible to put there a switch for roads construction? In JGRpp there are newly included prebuilt roads to every city.

Thanks!
MLG
Are you an eye candy player? Check out Invisible engine set! viewtopic.php?f=67&t=88934
You can write to me in English, or Czech.
Můžete mi psát česky, nebo anglicky.
User avatar
Firrel
Engineer
Engineer
Posts: 90
Joined: 13 Aug 2019 17:06

Re: [AI] CityLifeAI 1.0

Post by Firrel »

Aegir wrote: 13 Jul 2021 03:20 This is amazing, I love it. Could do with some settings to control max amount of vehicles per population/etc. though as it can produce some VERY crowded maps. I guess that's part of the charm though? I mean I could run it fine on a 1k x .5k map in JGRPP on a Surface Go with no major slowdowns.
Glad you like it. If you dont provide public service to the town, the people jump into their cars and produce traffic. You can control the amount of cars in the town by this, so there is no need for a setting. The values were chosen so that the towns are crowded without service, but even with 100% transported, there will still be some activity.
MLG wrote: 13 Jul 2021 04:28 Hi, I just went to test your AI, and have found a issue.
It builds roads with overhead wires even if it is pointless. Also it bulds roads with bridges and makes connection look absolutely ugly.

Would it be possible to put there a switch for roads construction? In JGRpp there are newly included prebuilt roads to every city.
The towns manage to have a budget for road construction after every 2000 population to up to 5 towns. If the connection already exists, another one will not be built. I will add the switch so that there will only be the JGRPP nicer roads.

You got very progressive governments in your cities, trying to electrify the intercity routes so you can run electric cars without needing to recharge. Also they are very environmentally minding by building bridges over wildlife areas so the animals can roam around uninterrupted. Otherwise, there is nothing I can do about it, tried to reduce the bridges, but increasing the cost of a bridge in A* either did nothing or failed the road finding. Also I have no easy way of knowing that the road is electrified, unless I parse the information from the name of the road, which may change with localization. Or I would need to check an electric vehicle for a road it cannot run, but an electric vehicle must exist at that time for it to work. Now it choses the fastest road that the eye candy vehicles can use.
User avatar
justaplayer
Engineer
Engineer
Posts: 33
Joined: 12 Dec 2020 12:37

Re: [AI] CityLifeAI 1.0

Post by justaplayer »

i searched on BaNaNaS and couldn't find SCP LIB anywhere
Attachments
The problem
The problem
Senza titolo.png (15.26 KiB) Viewed 2176 times
User avatar
Firrel
Engineer
Engineer
Posts: 90
Joined: 13 Aug 2019 17:06

Re: [AI] CityLifeAI 1.0

Post by Firrel »

justaplayer wrote: 13 Jul 2021 13:40 i searched on BaNaNaS and couldn't find SCP LIB anywhere
Sorry, used the name of the library that is used in the code. Its full name is Script Communication for AI. You can find it in BaNaNaS, here is its forum topic and it should be automatically downloaded if you download this AI from the online content downloader.

Added links to BaNaNaS content to the first post.
User avatar
justaplayer
Engineer
Engineer
Posts: 33
Joined: 12 Dec 2020 12:37

Re: [AI] CityLifeAI 1.0

Post by justaplayer »

Firrel wrote: 13 Jul 2021 15:16
justaplayer wrote: 13 Jul 2021 13:40 i searched on BaNaNaS and couldn't find SCP LIB anywhere
Sorry, used the name of the library that is used in the code. Its full name is Script Communication for AI. You can find it in BaNaNaS, here is its forum topic and it should be automatically downloaded if you download this AI from the online content downloader.

Added links to BaNaNaS content to the first post.
I just found the SCPlib. I tried the AI Its very good. 5/5

Edit: i just put DROP and the CityLife has decided to be very eco friendly. We should get an option for the ai to choose roads like the last road available in the road construction menu.

Edit of the edit: The ai is getting more and more ecofriendly (it's starting to use the CNG icon from the Slovak Bus set)
Attachments
Senza titolo.png
(327.84 KiB) Not downloaded yet
The real Icon from the Iveco Urbanway 12m<br />In the STGFX set
The real Icon from the Iveco Urbanway 12m
In the STGFX set
Cng Fuel icon.png (6.83 KiB) Viewed 2129 times
User avatar
Aegir
Tycoon
Tycoon
Posts: 2827
Joined: 09 Feb 2004 10:02
Contact:

Re: [AI] CityLifeAI 1.0

Post by Aegir »

Not sure what's happening, might need to do some more testing, but I'm getting an edge case where if the AI has already built the max amount of road vehicles allowed in the game settings, (I've tried 1000, 5000), it very quickly gets stuck in some sort of loop or something and starts chewing up a tonne of CPU time.

Let me know if there's any particular testing you'd like me to do to get to the bottom of this one,
Former NewGRF Coder and Sprite Artist.

Currently working under the name 'reldred' on Github, IRC and Discord.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
MLG
Traffic Manager
Traffic Manager
Posts: 158
Joined: 07 Sep 2020 15:12

Re: [AI] CityLifeAI 1.0

Post by MLG »

MLG wrote: 13 Jul 2021 04:28 Hi, I just went to test your AI, and have found a issue.
It builds roads with overhead wires even if it is pointless.
I just found a way around that. In U&RaTT is option to choose speed limit for highway road. I had it at 130 km/h, that electrified road is 140 km/h. I set it at 150 km/h and it fixed the issue.
Are you an eye candy player? Check out Invisible engine set! viewtopic.php?f=67&t=88934
You can write to me in English, or Czech.
Můžete mi psát česky, nebo anglicky.
User avatar
Firrel
Engineer
Engineer
Posts: 90
Joined: 13 Aug 2019 17:06

Re: [AI] CityLifeAI 1.0

Post by Firrel »

Aegir wrote: 18 Jul 2021 11:11 Not sure what's happening, might need to do some more testing, but I'm getting an edge case where if the AI has already built the max amount of road vehicles allowed in the game settings, (I've tried 1000, 5000), it very quickly gets stuck in some sort of loop or something and starts chewing up a tonne of CPU time.

Let me know if there's any particular testing you'd like me to do to get to the bottom of this one,
Thanks for the info, I remember that I tried to reduce operations when it cannot build more vehicles, but it was not fully tested. Will look into it.
MLG wrote: 18 Jul 2021 14:04
MLG wrote: 13 Jul 2021 04:28 Hi, I just went to test your AI, and have found a issue.
It builds roads with overhead wires even if it is pointless.
I just found a way around that. In U&RaTT is option to choose speed limit for highway road. I had it at 130 km/h, that electrified road is 140 km/h. I set it at 150 km/h and it fixed the issue.
It choses the fastest road that a (random) vehicle can run on. Changing the max speed surely solves it in a way. There is actually no good general way of chosing the road type, but I have some ideas (hacks) that I can try.
User avatar
Aegir
Tycoon
Tycoon
Posts: 2827
Joined: 09 Feb 2004 10:02
Contact:

Re: [AI] CityLifeAI 1.0

Post by Aegir »

Firrel wrote: 18 Jul 2021 19:09
Aegir wrote: 18 Jul 2021 11:11 Not sure what's happening, might need to do some more testing, but I'm getting an edge case where if the AI has already built the max amount of road vehicles allowed in the game settings, (I've tried 1000, 5000), it very quickly gets stuck in some sort of loop or something and starts chewing up a tonne of CPU time.

Let me know if there's any particular testing you'd like me to do to get to the bottom of this one,
Thanks for the info, I remember that I tried to reduce operations when it cannot build more vehicles, but it was not fully tested. Will look into it.
Definitely seems to be tied to how many road vehicles it's targetting to make, maps with smaller combined town populations (never hits game max vehicle limit) you don't get the slow down, games where there's enough towns+population to want lots of road vehicles it trips.

Looking forward to the update :mrgreen:
Former NewGRF Coder and Sprite Artist.

Currently working under the name 'reldred' on Github, IRC and Discord.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
WalkedBy
Engineer
Engineer
Posts: 18
Joined: 08 Aug 2021 11:45

Re: [AI] CityLifeAI 1.0

Post by WalkedBy »

There were lots of issues with this script 1.0, major:
- ton of excessive unnecessary computations for Candy AI, makes 1.0 version unusable and blocks in game rewind
- buggy road building (bridges everywhere) which really should be optional
minor:
- AI/map car uncontrollable increase was possible because amount of cars was increasing lineary with city sizes
- candy cars are not updated with time, 1820 cars will stay all game up to 2100 and will block city traffic

fast fixes were made:
- AI/map car overflow is prevented by using square root of population instead of linear steady grow
- some questionable calls removed from AI main loop to yearly/monthly/daily schedule
- AI will not try to build depots all game, only once
- all road building anyway not working and disabled, less safe part of script better be optional
- a bit more safety with small clean-ups and unnecessary while's replaced with for's
- numbers are adjusted for huge maps, i.e. slightly less density of cars per city
- added garbage truck (classic) other type
- (reupload 2.3) bugfix which prevented obsolete cars from updating without game save/load, should work fluently now in server mode

attached, tested a bit, but not carefully, this is just fast fix to make script actually usable
in general, that was probably the best available cars script of all, others are much less advanced
P.S. sorry, for 2.0 uploaded wrong files and found problem, updated with 2.1 (warning: still not well tested)
Last edited by WalkedBy on 27 Aug 2021 02:17, edited 2 times in total.
User avatar
Firrel
Engineer
Engineer
Posts: 90
Joined: 13 Aug 2019 17:06

Re: [AI] CityLifeAI 1.0

Post by Firrel »

WalkedBy wrote: 20 Aug 2021 13:09
Thanks for providing so many fixes. I knew there will be problems, it was not quite finished. I wanted to get to fixing them, I still keep it in mind, but still cant get to it. So I am happy you did 2.1, so it will work well now.
User avatar
Aegir
Tycoon
Tycoon
Posts: 2827
Joined: 09 Feb 2004 10:02
Contact:

Re: [AI] CityLifeAI 1.0

Post by Aegir »

WalkedBy wrote: 20 Aug 2021 13:09 There were lots of issues with this script 1.0, major:
- ton of excessive unnecessary computations for Candy AI, makes 1.0 version unusable and blocks in game rewind
- buggy road building (bridges everywhere) which really should be optional
minor:
- AI/map car uncontrollable increase was possible because amount of cars was increasing lineary with city sizes
- candy cars are not updated with time, 1820 cars will stay all game up to 2100 and will block city traffic

fast fixes were made:
- AI/map car overflow is prevented by using square root of population instead of linear steady grow
- some questionable calls removed from AI main loop to yearly/monthly/daily schedule
- AI will not try to build depots all game, only once
- all road building anyway not working and disabled, less safe part of script better be optional
- a bit more safety with small clean-ups and unnecessary while's replaced with for's
- numbers are adjusted for huge maps, i.e. slightly less density of cars per city
- added garbage truck (classic) other type
- (reupload 2.3) bugfix which prevented obsolete cars from updating without game save/load, should work fluently now in server mode

attached, tested a bit, but not carefully, this is just fast fix to make script actually usable
in general, that was probably the best available cars script of all, others are much less advanced
P.S. sorry, for 2.0 uploaded wrong files and found problem, updated with 2.1 (warning: still not well tested)
I'm finding this version straight up refuses to build any depots/vehicles with either U&RATT or no NRT set loaded at all. Let me know if there's any debugging you want me to do.
Former NewGRF Coder and Sprite Artist.

Currently working under the name 'reldred' on Github, IRC and Discord.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
WalkedBy
Engineer
Engineer
Posts: 18
Joined: 08 Aug 2021 11:45

Re: [AI] CityLifeAI 1.0

Post by WalkedBy »

Aegir wrote: 09 Oct 2021 05:22 I'm finding this version straight up refuses to build any depots/vehicles with either U&RATT or no NRT set loaded at all. Let me know if there's any debugging you want me to do.
Some additional info:
We were using version above for about 100 years on server, noticed some uncritical, but annoying problems (road chunks and depots were recreated on converting to scenario). Then I added some small updates and admin restarted server and recreated AI keeping savegame (and passwords). But overall, both versions did not cause gamebreaking problems or crashes. Lots of potential problems very probably can be fixed with just restarting AI. Using these scripts for about 250 server years by now.
There is 1 unfixed problem yet - some cities get too much cars(like 2x-3x of planned amount), should not happen. That's barely noticeable, though.
For the version we currently use, attached it. It's still hammer-fixed and can' be considered final, but should just work.

Now, for the problem you described - tested this script just yet on new game, worked fine. Probably you just need to wait for next month start. Attached, how normal log should look like:
Output.png
(80.96 KiB) Not downloaded yet
If still not happens, please attach a savegame or what happens in AI log - will look into them.

P.S. how can I edit previous post so people did not download worse version? Forum blocks editing now
P.P.S. Ai asks for the money, but it's some sort of legacy ask and probably not required. Wait for 1 month and it will probably get some money on itself.
Attachments
CityLifeAI-2.4.tar
(69.5 KiB) Downloaded 16 times
Last edited by WalkedBy on 10 Oct 2021 06:58, edited 2 times in total.
User avatar
Aegir
Tycoon
Tycoon
Posts: 2827
Joined: 09 Feb 2004 10:02
Contact:

Re: [AI] CityLifeAI 1.0

Post by Aegir »

WalkedBy wrote: 10 Oct 2021 06:42
Aegir wrote: 09 Oct 2021 05:22 I'm finding this version straight up refuses to build any depots/vehicles with either U&RATT or no NRT set loaded at all. Let me know if there's any debugging you want me to do.
Some additional info:
We were using version above for about 100 years on server, noticed some uncritical, but annoying problems (road chunks and depots were recreated on converting to scenario). Then I added some small updates and admin restarted server and recreated AI keeping savegame (and passwords). But overall, both versions did not cause gamebreaking problems or crashes. Lots of potential problems very probably can be fixed with just restarting AI. Using these scripts for about 250 server years by now.
There is 1 unfixed problem yet - some cities get too much cars(like 2x-3x of planned amount), should not happen. That's barely noticeable, though.
For the version we currently use, attached it. It's still hammer-fixed and can' be considered final, but should just work.

Now, for the problem you described - tested this script just yet on new game, worked fine. Probably you just need to wait for next month start. Attached, how normal log should look like:
Output.png
If still not happens, please attach a savegame or what happens in AI log - will look into them.

P.S. how can I edit previous post so people did not download worse version? Forum blocks editing now(
Nice, I'll give this version a shot. Thanks for the quick turnaround!

Edit: Right on the money! Works a treat!
Former NewGRF Coder and Sprite Artist.

Currently working under the name 'reldred' on Github, IRC and Discord.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest