[AI] CityLifeAI 3.0
Moderator: OpenTTD Developers
[AI] CityLifeAI 3.0
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!
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
Requirements:
- OpenTTD, v. 14.x or newer.
- SuperLib v. 40, SCPLib v. 45, AIToyLib v. 2 (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 3.0 (2024/10/06)
- download link
- mod: Merged changes of v2.4 into v1
- new: Parameter to control car density
- new: Parameters to obsolete slow cars (horses)
- new: Cars are bought sequentially several per town to spread them more evenly
- fix: Updated AIToyLib
- rem: Road building
Version 2.4 by WalkedBy (2021/10/10)
Version 1.0 (2021/07/12)
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!
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
Requirements:
- OpenTTD, v. 14.x or newer.
- SuperLib v. 40, SCPLib v. 45, AIToyLib v. 2 (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 3.0 (2024/10/06)
- download link
- mod: Merged changes of v2.4 into v1
- new: Parameter to control car density
- new: Parameters to obsolete slow cars (horses)
- new: Cars are bought sequentially several per town to spread them more evenly
- fix: Updated AIToyLib
- rem: Road building
Version 2.4 by WalkedBy (2021/10/10)
Version 1.0 (2021/07/12)
- Attachments
-
- Release1.png (1.02 MiB) Viewed 18845 times
Last edited by Firrel on 06 Oct 2024 15:29, edited 5 times in total.
Re: [AI] CityLifeAI 1.0
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.
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
-
- Traffic Manager
- Posts: 174
- Joined: 07 Sep 2020 15:12
- Location: Usually near some interesting rail systems. :P
Re: [AI] CityLifeAI 1.0
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.
Thanks!
MLG
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.
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.
Formerly known as MLG.
You can write to me in English, or Czech. Můžete mi psát česky nebo anglicky.
Formerly known as MLG.
Re: [AI] CityLifeAI 1.0
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.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.
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.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.
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.
- justaplayer
- Engineer
- Posts: 40
- Joined: 12 Dec 2020 12:37
Re: [AI] CityLifeAI 1.0
i searched on BaNaNaS and couldn't find SCP LIB anywhere
- Attachments
-
- The problem
- Senza titolo.png (15.26 KiB) Viewed 25444 times
Re: [AI] CityLifeAI 1.0
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.
- justaplayer
- Engineer
- Posts: 40
- Joined: 12 Dec 2020 12:37
Re: [AI] CityLifeAI 1.0
I just found the SCPlib. I tried the AI Its very good. 5/5Firrel wrote: ↑13 Jul 2021 15:16Sorry, 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.
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
In the STGFX set - Cng Fuel icon.png (6.83 KiB) Viewed 25397 times
- The real Icon from the Iveco Urbanway 12m
Re: [AI] CityLifeAI 1.0
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,
Let me know if there's any particular testing you'd like me to do to get to the bottom of this one,
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
-
- Traffic Manager
- Posts: 174
- Joined: 07 Sep 2020 15:12
- Location: Usually near some interesting rail systems. :P
Re: [AI] CityLifeAI 1.0
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.
Formerly known as MLG.
You can write to me in English, or Czech. Můžete mi psát česky nebo anglicky.
Formerly known as MLG.
Re: [AI] CityLifeAI 1.0
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.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,
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.
Re: [AI] CityLifeAI 1.0
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.Firrel wrote: ↑18 Jul 2021 19:09Thanks 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.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,
Looking forward to the update
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
Re: [AI] CityLifeAI 1.0
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)
- 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.
Re: [AI] CityLifeAI 1.0
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.
Re: [AI] CityLifeAI 1.0
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.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)
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
Re: [AI] CityLifeAI 1.0
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: 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 307 times
Last edited by WalkedBy on 10 Oct 2021 06:58, edited 2 times in total.
Re: [AI] CityLifeAI 1.0
Nice, I'll give this version a shot. Thanks for the quick turnaround!WalkedBy wrote: ↑10 Oct 2021 06:42Some 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(
Edit: Right on the money! Works a treat!
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.
14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
Re: [AI] CityLifeAI 1.0
Hitting a few birds with one stone here:
1. Can we get an update to support random vehicles for tramways? Quast65 and GarryG have been working on "eyecandy" tramways with invisible tracks for non-traditional vehicles (bicycles, motorcycles, animal herds, etc) to move along paths without blocking road vehicles. This makes for some interesting combinations and I think CityAI would be more helpful if it used these, it would be nice to have a setting to enable/disable the use of roadways or tramways.
2. If you need to edit a previous post and can't do so, a mod may be able to make a request, but it's usually better to leave it for historical reasons and just make a new post.
3. Money for AIs? IIRC there's a library for that which should probably be implemented.
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Re: [AI] CityLifeAI 1.0
Tried this AI, and it's pretty nice having roadveh running over the map
but, how can i add this AI on a multiplayer game run from a dedicated server ?
but, how can i add this AI on a multiplayer game run from a dedicated server ?
Re: [AI] CityLifeAI 1.0
I don't know if this AI is still maintained, but the call
in town.nut:156 is quite inefficient, as this call is expensive when there are lots of vehicles, and given the script does not rate limit itself, it will tank performance.
It can be replaced with the following line instead
which uses a saved count of road vehicles and thus avoids counting every single vehicle in game every time. It can be several hundred times faster...
Code: Select all
local company_vehicles_count = AIVehicleList().Count();
It can be replaced with the following line instead
Code: Select all
local company_vehicles_count = AIGroup.GetNumVehicles(AIGroup.GROUP_ALL, AIVehicle.VT_ROAD);
He's like, some kind of OpenTTD developer.
Re: [AI] CityLifeAI 1.0
It would be awesome if the above code change could be implemented, and then checked against OpenTTD 14 and uploaded to Bananas. This is a huge Quality of Life upgrade that many players don't know exists.
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Who is online
Users browsing this forum: No registered users and 1 guest