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

xarick
Transport Coordinator
Transport Coordinator
Posts: 335
Joined: 26 Feb 2015 00:52

Re: CivilAI

Post by xarick »

CivilAI-25 has a bug function GetVersion() { return 24; }
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 »

Whoops. :roll:

I also took the opportunity to fix some logic which was largely preventing the AI building new cargo trains once it had a passenger network.

Version 29:
Bug fixes:
Trains
- Fix AI getting stuck trying to build a junction on a station tile.

Version 28:
Tweaks:
Road Network:
- Unified and revised the road depot building code, removing the old concept of "Home Depot."

Version 27:
Bug fixes:
Trains:
- Fixed AI getting stuck building wagons if it fails to build a locomotive.

Version 26:
Bug fixes:
- Correctly updated version number in-game.
Trains:
- Fixed AI not building new rail lines if it has existing termini with available connections but no supplying industries.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5649
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: CivilAI

Post by andythenorth »

Hurrah! More trains! :D

Found something weird in v29, got a train with only one order. It's plugged up that route. :twisted:
Attachments
Civil29.png
Civil29.png (605.8 KiB) Viewed 11417 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 odd. I'll look out for that. In the meantime, I guess it will sell such trains after 2 years when they fail to make any income. :)

Version 30:
Bug fixes:
- Fixed crash when loading a savegame (due to the changes in v28, oops!).
Trains
- Fixed crash when AI attempts to electrify tracks of another company (reported by andythenorth).
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

I really do enjoy Civi's naming + the "Silly" toyland townnames. :D
Image3.png
Image3.png (63.62 KiB) Viewed 11247 times
User avatar
Fairyfloss
Traffic Manager
Traffic Manager
Posts: 158
Joined: 03 Aug 2011 14:10
Location: Yes

Re: CivilAI

Post by Fairyfloss »

I've found a bug that's likely to do with the vehicle GRFs I use, but I thought it would be a good idea to bring this to your attention.

It bought a Metro Cammell EMU, then decided it wanted carriages, and proceeded to buy 827.7 tiles worth of carriages it could not attach to the train, for a total of about 2000-ish carriages?
uhm.PNG
uhm.PNG (1.54 KiB) Viewed 11215 times
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Thanks! Yep, clearly a problem with the wagons not being able to attach to the loco. Damn NewGRF authors and their BAD FEATURES. ;)

Which newgrf is it? I'll experiment and see what I can come up with. :)
User avatar
Fairyfloss
Traffic Manager
Traffic Manager
Posts: 158
Joined: 03 Aug 2011 14:10
Location: Yes

Re: CivilAI

Post by Fairyfloss »

PikkaBird wrote: 15 Jan 2020 01:15 Thanks! Yep, clearly a problem with the wagons not being able to attach to the loco. Damn NewGRF authors and their BAD FEATURES. ;)

Which newgrf is it? I'll experiment and see what I can come up with. :)
It's a NewGRF that goes by the name of UKRS2, you might have heard of it? :)
The carriages are from RUKTS, meanwhile, so the issue might be purely because of NewGRF mixing? Still, maybe it's fixable?
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Darthrafael wrote: 15 Jan 2020 05:37 Still, maybe it's fixable?
I'm sure it is. I'll try out the GRF combination, thanks. :)
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

I figure I've got enough bug fixes and tweaks to release another version. :) I really need to focus on the new pathfinder for v32 though, as the route building is what's really slowing the AI down now.

Version 31:
Features:
Trains:
- AI can now build stations and trains of varying lengths, instead of always 3 tiles.
- AI will build additional freight trains to meet demand.
Road Network:
-Building the intercity road network has been disabled.
Tweaks:
- AI will now avoid planting trees on farm fields.
- Most parameters (max buses, minimum air route distance etc) have been removed from the player-adjustable AI options.
- If you're an advanced user and really want to change these numbers, you'll find them at the end of saveload.nut.
Trains:
- Made avoiding double-connecting industries more reliable.
- Tinkered with locomotive selection to avoid using high-speed locomotives for freight.
Aircraft:
- AI can now buy a cheaper aircraft if its ideal aircraft is too expensive.
Bug fixes:
Trains:
- Fixed wagon selection bug that was preventing electrified freight trains from renewing.
- Disallowed PBS-locked track loops at station entrances.
- Fixed AI ripping up newly built routes because it couldn't quite afford the locomotive yet.
- Added code to handle NewGRF wagons not being attachable (thanks Darthrafael).
Goods Trucks:
- Fixed the AI repeatedly trying to build goods pickup routes to unroutable factories.
- Fixed the AI buying lots of goods trucks if the dropoff station stops accepting goods.
- Fixed the AI building a goods pickup depot when it cannot afford the trucks.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5649
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: CivilAI

Post by andythenorth »

I broke it again, sorry :oops:

2 types of crash, see attached :)
Attachments
civil-crashed.png
civil-crashed.png (369.14 KiB) Viewed 3835 times
civil-crashed-2.png
civil-crashed-2.png (670.15 KiB) Viewed 3835 times
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Excellent. Fun fact: this bug did not manifest before v31 because of a typo that was causing it to build a passenger car if it couldn't find a mail van. Fix a bug, make a bug. :)

Version 32:
Bug fixes:
Trains:
- Fixed crash when there is no appropriate mail van available for a new passenger train (reported by andythenorth).
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 490
Joined: 11 Aug 2019 18:15
Contact:

Re: CivilAI

Post by 2TallTyler »

I got a crash when playing before any trains or ships were available. The only NewGRFs loaded are eGRVTS and a town set I'm developing.
Attachments
crash.PNG
(56.36 KiB) Not downloaded yet
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

I don't think I've done anything with ships since I allegedly fixed a similar bug in v20, but nonetheless please update to the latest version of the AI (v32) and let me know if the bug persists.
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 490
Joined: 11 Aug 2019 18:15
Contact:

Re: CivilAI

Post by 2TallTyler »

My apologies. I've got the latest version on my Windows partition but haven't updated on MacOS and was running version 6... :oops:
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 490
Joined: 11 Aug 2019 18:15
Contact:

Re: CivilAI

Post by 2TallTyler »

Upgraded to Version 32 and still getting the same crash before ships or trains are available.

Savegame is attached. I just published the town set on BaNaNaS, but if you need to look at the code it's here.
Attachments
civilAI_crash.PNG
(52.01 KiB) Not downloaded yet
crash.sav
(116.74 KiB) Downloaded 149 times
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: CivilAI

Post by PikkaBird »

Ta, I'll look into it.
RockyPapery
Engineer
Engineer
Posts: 16
Joined: 08 Apr 2020 13:23

Re: CivilAI

Post by RockyPapery »

I love how this AI focuses on expanding the city and then spread out to other city near it. But what bothers me is that they seems only build small airport and 2 type of small planes. Then, it has a habit of merging a station, which is fine, but the buses just taking the most cargo, resulting in very low income train and airplane. It didn't even upgrade the plane. After 50 years it only has 2.000k operating profits. The other AI has around 6.000k - 40.000k / 3 months.

My settings:
airplane speed factor: 1/1
Maintenance cost: high
construction cost: high
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 490
Joined: 11 Aug 2019 18:15
Contact:

Re: CivilAI

Post by 2TallTyler »

Not a crash this time, but a train line where one station and the main line is rail, but the other station is monorail. Version 32.
Attachments
wrong_track.PNG
wrong_track.PNG (798.96 KiB) Viewed 9397 times
Timberwolf
Transport Coordinator
Transport Coordinator
Posts: 318
Joined: 22 May 2006 18:25
Location: London-ish.
Contact:

Re: CivilAI

Post by Timberwolf »

I have the same crash when no ships are available with CivilAI 32, it looks like it's caused by line 163 of ship.nut where it does the following:

Code: Select all

cost = cost + BuyAFerry(dock1, dock2, beams1, beams2, intersect, depot, true, null);
When there are no ships available the function returns null, and causes a crash. I fixed it in my local copy with a quick null check, but that was just a hack to get things working without having to dig around too much in what BuyAFerry() actually does.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 15 guests