DictatorAI

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

krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

i've upload the "f" version, that should be what 1.7 will be after fixing some few more things that need it. Anyway you can test it, it also add boats
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: DictatorAI

Post by Brumi »

Cool, a new ship-using AI 8)

Unfortunately it crashed on my first run:
crash.png
crash.png (24.67 KiB) Viewed 4370 times
... and on my second run with the same bug as I was writing this.

I have one little suggestion anyway: please reorder the settings of the AI so that similar settings appear adjacent to each other, like the "Use [VEHICLE_TYPE]" ones.
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

Thanks for the report brumi, i'm afraid i will need a savegame to fix that one, the stationID = 5 fail as it fail to find the station type of the station (and all station type are checks, so i don't see why it cannot find it). Are you using newGRF altering industry ?
I could fix it by ignoring bad station type to avoid the bug, but i would prefer see the conditions to met it.


I have group settings in revelant order: road option after road vehicle type, train options after trains... So there's a logic at placing them like that.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: DictatorAI

Post by Brumi »

Sorry, I don't have a savegame, the "index does not exist" crash made me think that it wouldn't need a savegame.
I was using the Generic Tram Set and the Temperate Oil Welly Only Decrease Neutraliser, so I suppose that's a yes and a no for the question whether I was using NewGRFs.

Currently I'm running another test game, this time with 3 DictatorAIs, in hopes of getting that crash again. Earlier this day I got it twice in a quick succession...

One little thing I noticed in this game:
terraforming.png
terraforming.png (340.58 KiB) Viewed 4370 times
I suppose you don't want your AI to terraform this much, this one seems quite expensive. It didn't drive the company out of business though. I wonder if running multiple instances could cause this.


And I'm OK with these order of settings as well, I just thought for some reason that they were still in the order of introduction :)
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

For the first bug : i have a bug that may destroy a road station i'm looking at, when station is removed (industry closing or the bug), you can met this condition too. Something i have problem to reproduce but i know it. I will fix the issue but i prefer the AI to crash for now to stopped when this happen.
Bet your luckier than me at reproducing it :)

The terraforming is done if the AI have the money to do it, so it's normal, the AI look at possible terraforming solutions and discard ones undoable by lack of money. But changes may invalidate the solve.
But i would says the solve found was good, but another instance/ai/human built a road there and invalidate the solve.
Like when the AI is looking at a place, if the AI see someone it will decrase its value (depending on the ai mode, in easy mode, any opponent lower it to 0, while other mode decrease it more or less), but if both instance look at the same place in the same time, both won't see each other and consider the place a good bet.
Nothing i could really do, chance it happen are at max with other dictatorai instance, as they both use the same logic to pickup a place to work on.
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: DictatorAI

Post by R2dical »

I've been using some AI's to test my own one's competitive abilities, and Dictator is proving useful as we have similar starting strategy and route selection.

So I don't know how useful or relevant feedback will be as my test setup is quite specific, but one thing I thought I'd mention regardless:

With Opengfx Airports++ Dictator builds an airport in early game and quickly runs bankrupt every time (to be fair this would happen to player or anyone as the costs are heavy, even though grf is set to normal = 1x cost). Dictator tries to recover, by selling vehicles but needs to sell (or not build) the airport. Sounds like a need for AIAirport.GetMaintenanceCostFactor() or even some function to see where there is a large loss every month.

This is repeatable with default settings for everything (game, grf and AI) and only Opengfx++ gfs used.
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

Well, if it's only opengfx airport, i don't see why the AI bankrupt.
And if you play with infrastructure maintenance, then i see why, but it's something i will just not fix or handle, as i just find that option stupid : even a human cannot handle an airport, instead of put stupid costs, it would be easier to disable them.

And i'm pretty sure, 99% of AIs will just bankrupt too. As AIs almost always do point to point connection, except some that handle network of connection, that option is sure death. And an AI with network airport couldn't live if start building them early, so need also to handle the costs... Way to complicate for a mode i will never play, and the hardcores players that will cry this mode is fun are the same that keep saying : i never play with an AI.

So if you don't use infrastructure costs, yes might be a bug, but opengfx airports works for me. And if you use it, all is fine.

I have kinda put dictatorAI on hold for now, as a bug, hmmm, bug me, and i took a fresh air at coding the GS, that's new for me and fun.
The version in bananas is stable and can do the job for some more time. If i invest time in dictatorai, it will be to end boats/trains and stabilize it, certainly not, and never, to handle infra costs.
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: DictatorAI

Post by R2dical »

Indeed it is with maintenance costs...

I understand not wanting to provide support for game features you wont want to play with (especially since there are so many and it would be a huge effort to make an AI that works consistently for all configs), but maybe its worth considering a message or something somewhere telling player that with that setting AI will bankrupt since this is a part of trunk.

Its only airports really, road is fine and a long enough train route will make enough profit to cover costs. Ships I haven’t tried yet.
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

To output a message to user you can :
- Put that in the debug window, something a user will not see if he is not a dev
- Throw an error

I don't want throw an error and crash the ai because of an unsupported option, that the user may turn off/on on the fly. If the option goes off the AI cannot restart itself. So no message but the AI just wait for the option to goes off, and keep going.
And going bankrupt because of that option is somehow what you could expect from it.

Instead of a message, if i check for that option, i would just disable airport.

But i keep thinking that infra cost is flow by design : have oneAI build road from X->Y, have twoAI using road from X->Y.
Nice option, oneAI keep paying maintenance for using X->Y while twoAI is just making money.
And worst : if oneAI goes bankrupt : twoAI still have the road for free.
Not a great and fair option...

And seriously no AI can really support such an option because of saving : if you don't save your roads, you will lost what roads you own on reload, or need to read the entire map to reget them, it's something i do for rails, that stuck openttd when loading while the AI read a huge map. It's certainly not something i would do for roads.
So if your AI lack the knowledge of its own roads parts, how could you manage/remove... roads parts you are not aware of ? Because that's the way to handle infra cost, unused part should be removed, else nobody could claims supporting infracost option, at best, just live with it : well, isn't what my AI is doing too?
User avatar
Core Xii
Traffic Manager
Traffic Manager
Posts: 228
Joined: 08 Apr 2008 09:47
Location: Finland

Re: DictatorAI

Post by Core Xii »

krinn wrote:But i keep thinking that infra cost is flow by design : have oneAI build road from X->Y, have twoAI using road from X->Y.
Nice option, oneAI keep paying maintenance for using X->Y while twoAI is just making money.
And worst : if oneAI goes bankrupt : twoAI still have the road for free.
Not a great and fair option...
It's a good point and AIs and players alike might wish to avoid constructing public infrastructure (i.e. roads) where possible. Can tram tracks be used by anyone?
krinn wrote:if you don't save your roads, you will lost what roads you own on reload, or need to read the entire map to reget them, it's something i do for rails, that stuck openttd when loading while the AI read a huge map.
You needn't read the entire map... search from road stations/depots, following roads and testing for ownership. Granted, you still have to search every road tile.. but it's considerably less than every tile.
R2dical
Traffic Manager
Traffic Manager
Posts: 163
Joined: 18 Mar 2013 22:22

Re: DictatorAI

Post by R2dical »

krinn wrote:To output a message to user you can :
- Put that in the debug window, something a user will not see if he is not a dev
- Throw an error
What about build a sign at middle of map/AI HQ/Player HQ/biggest town warning about chance to go bankrupt? And maybe loop or disable airports till sign is removed...

Its only really airports that are the problem, at least for Dictator. I've ran many games now with Dictator and maintenance costs, sure there are some high expenses especially in late game once the multiplier adds up but for roads it can always make a good profit. Even if Dictator builds EVERY road (quite kindly for my AI to use :P ). Its just a pity to see otherwise good AI die so quickly.

I will be looking to handle costs in my AI, road and ships will be ignored past the planning stage, rail will be sold on route closure, airports only require a small function to check costs vs my existing route profit evaluate function). This should be fine as far as I see.
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: DictatorAI

Post by Brumi »

I just found some kind of bug:
disconnected.png
disconnected.png (124.26 KiB) Viewed 12583 times
A train is actually running on that line, but I didn't find road vehicles that run northbound from the power station. And there is another problem in the picture, albeit hidden: the second truck station in the bottom of the picture is not connected properly to the other one, probably a truck was in the way when the AI tried to construct the road.
Névtelen, 15. Júl 1951.sav
(508.37 KiB) Downloaded 363 times
EDIT: After loading the savegame above, the AI actually corrected that rail line. Really nice work. The truck station remains unconnected though.
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

R2dical wrote:What about build a sign at middle of map/AI HQ/Player HQ/biggest town warning about chance to go bankrupt? And maybe loop or disable airports till sign is removed...
Viewing other companies signs is an option, well, i'm pretty sure 100% devs have it enable and 100% non dev users have it disable
Core Xii wrote: You needn't read the entire map... search from road stations/depots, following roads and testing for ownership. Granted, you still have to search every road tile.. but it's considerably less than every tile.
Yep agree, still not worth the effort for me :)
Brumi wrote:I just found some kind of bug:
A train is actually running on that line, but I didn't find road vehicles that run northbound from the power station. And there is another problem in the picture, albeit hidden: the second truck station in the bottom of the picture is not connected properly to the other one, probably a truck was in the way when the AI tried to construct the road.
EDIT: After loading the savegame above, the AI actually corrected that rail line. Really nice work. The truck station remains unconnected though.
For the train part, it's something i should fix, as it get fix when loading, but should be catch before building a train : lowering costs and troubles.
The fix when loading is not there to fix them when they are bork because i fail at building it, but fix them when they are bork because in middle of upgrade/creation when user has save the game :)
The road station might just be ok : if a road station cannot be use but at least one part of the station is ok, the AI might kept the station if no solve to fix it is found. Sometimes is just because of short of money, sometimes an item blocking the front... But as long as one entry is working.
The AI gets complex and i even allow the train part to destroy roads parts, generally roads parts can be redone easier than a train parts with less trouble, per example a road bridge is ~ 0 effect for a road, while a train will get hurt to climb it. So i decide to remove roads part that block a rail, favor flat area for train, even if it bug roads.
I think i have add so many rules and exception i'm a bit lost in them, and one of them is the bug that remove the road station :)
Something i will fix fisrt when i reput my hands in my ai's code. But as i said, it will take some few more times before it happen as this time i will try to finish something before doing something else.
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

I have nearly endup my works with trains (yeah, it's not like i tooked my time)
In the main thread i have put a version of the current AI (with plenty debugs message/break... in it and a limit to create only one work with trains and no other engine type).

But if you want see how dictatorai handle trains now, you could have fun watching it upgrading its stations to keepup with the demand.
I don't expect really anyone to produce some bug report as this version is in itself full of them ; but i'll be glad to get them if you find some nasty ones.
ps: it need a new update of cEngineLib (v8, that is now in bananas)
Brumi
President
President
Posts: 921
Joined: 18 Jul 2009 17:54

Re: DictatorAI

Post by Brumi »

Woohoo, another use-all-transport-types AI on the way :)

I'll definitely give it a try when I have some free time on my hands.
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

Here's an update, this time, this version should be playable (still lot of debug code... in it) but it should "kind of works", not like the previous version that was crashing quickly.

Now my trains part:
- Handle any cargoes
- Handle upgrade of trains locos
- Handle upgrade of wagons to use better ones
- Handle upgrading rails to upgrade another train (or keeping old ones if new train can also run on it)
- Handle balancing of load to trains if possible
- Handle adding new wagons to existing trains (well, it looks like Mr Obivious, but AI train maker could tell you about this for sure, as wagon lost in depot are just... lost forever)
- Handle different signals, and upgrade them when need
- Handle upgrade of stations (can makes them grow when need, but never shrink, not really in my todo list tbh)
- Handle dead platform (a no more usable plaftorm might not stop the station to works)
- Handle sharing of station (but actually limited to some case, on my todo list)
- Handle using both side of station (but only one will be use, on my todo list)
- Pathfinder calc substask and divide its work other them
- Pathfinder can create itself subtask (if a task fail, pathfinder will try to get back a few, and add another subtask to the subtask to finish it)
- Pathfinder calc and time is distribute over all tasks/subtasks
- Pathfinder build rails asynchron and can build over existing and working route without interrupt, and time from start to end of building could also be delayed (lack of money...)
- Handle rails speed limit
- Handle trains speed limit over rails/wagons
- Handle wagon speed limit
- Handle newgrf vehicle (but not yet station)
- Handle multihead/engine, length limitation to train or station size (but cannot yet work if length is change while in game, it's just buggy, and far in my todo list)
- Handle repairing of broken path
- On loading, refind rails and handle them: call the repairman, or calling the end the upgrade or just remove them if no more use...
- Handle removing stations, rails... to clean up any mess, failure...
- What it doesn't handle is 90° turn limit (i'm unsure if i will handle this, the way i have done the ai with the repair... as depot could be remove/rebuild elsewhere, making depot with the turn limit more complex to handle)
- Of course many other changes to road, aircraft... but it's more tuning previous feature than new ones.

Maybe some other features i can't remember (hence the time tooked)
You need a not yet release bugfix version of my enginelib i will provide with in thread #1 with the ai so you can test (this time, for real, well, there's still bugs, but it really should be playable)
I also plan to release the pathfinder as a lib if some are wishing (the part that create/handle tasks, and asynch calc & build) as i think i did a not bad job at improve handling of real long path under tiny time while keeping high the looking and usuability of the path.
I still have so many things on my todo list, and so many bugs, that i might just stabilize it like it is and frozen that too huge todo list as i'm not seeing an end to this and the previous stable version is old, quiet old.

If you have time to test, at least the AI looks quiet funny to watch as it gave a "living" feeling with all the upgrades and change the AI can do to any route.
Noob
Engineer
Engineer
Posts: 9
Joined: 06 Aug 2015 05:54

Re: DictatorAI

Post by Noob »

Hey Krinn, i'm new here and just download this game yeasterdsy, i've opened up a muitlplayer server and added a couple of ais in it, however, your ai crashed, i've already posted the screenshot of it but it was in the wrong thread so here a another one.
Attachments
Screen Shot 2015-08-06 at 21.43.21.png
(1.29 MiB) Downloaded 1 time
Noob
Engineer
Engineer
Posts: 9
Joined: 06 Aug 2015 05:54

Re: DictatorAI

Post by Noob »

Here's the saved game. :)
Attachments
Server1.sav
Here's the saved game.
(69.69 KiB) Downloaded 261 times
User avatar
Core Xii
Traffic Manager
Traffic Manager
Posts: 228
Joined: 08 Apr 2008 09:47
Location: Finland

Re: DictatorAI

Post by Core Xii »

Reporting a crash.
Unnamed, Dec 24th, 1950.png
Unnamed, Dec 24th, 1950.png (35.37 KiB) Viewed 4363 times
krinn
Transport Coordinator
Transport Coordinator
Posts: 342
Joined: 29 Dec 2010 19:36

Re: DictatorAI

Post by krinn »

Thank you both for the report (that seems the same problem), i just get internet back (isp change), and will work on dictatorai again, i'm unsure i will fix the 169 still, as i prefer finish that (never ending) new version.
If really you care to get 169 fix and working, i will sent you a patch.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests