Page 2 of 6

Re: DictatorAI

Posted: 06 Aug 2011 13:10
by krinn
Here's a new version for ones that like to test before release.
This is version 106, HIGHLY in an unstable state !!! Many things change in the code but it's mostly code handling and optimizing, so don't expect too much new features.

But you can test the new tasks handling function, the ai find jobs in a more smooth way and plan better next job to do.
I have highly optimize it to run on big maps too, the ai now can start working 10 times faster (and it's a bare minimum, really expect big improvment here).
More optimizations to the building functions should also higher ai incomes (still need more testing, but first results are promising vs older versions).
I took care of not busy too much the squierrel VM, other ai will like it.
Also add terraforming functions, for now only used by airports functions, but this will ease trains (still plan to add them, but for that big task i prefer waiting until my free time is higher)

I've done few stability tests, but really too few, and as i'm planning others stuffs, they nearly cannot end. So this version is more an alpha than anything else. Please submit bugs you might found (specially crashs). I cannot promise a quick fix, but it will be done asap.

Re: DictatorAI

Posted: 07 Aug 2011 10:52
by Brumi
Good news that this AI is still being developed :)
I'm running a test right now, no crash so far. The only problem is that it still eats my CPU :(

Re: DictatorAI

Posted: 07 Aug 2011 18:28
by krinn
can't do much more, even i could save some cpu cycle, i just cannot saved all cpu cycles, or no, in fact i could, but i would then rename it to idlemore++

i think you should give up with the zx81 and buy a real computer brumi :)
here's what that save game (see file attach, it's one of you i think no?) do here in fast forward:


edit: i've update to 106b (not b as beta, but b as more recent and need another name) the file so you can test with an even newer version (same as the one i've use for that screenshot), correct some bugs (one when loading that scenario ^^ and a few others)

Re: DictatorAI

Posted: 07 Aug 2011 18:55
by Brumi
I have a 3.01 GHz AMD Athlon II X2 250 :P
Have you tried putting some AIController.Sleep(1)'s into the code where some serious calculation is going on?

Re: DictatorAI

Posted: 08 Aug 2011 00:16
by krinn

Code: Select all

grep -R Sleep * | wc -l
56
That's not a proof i've put them in the right place, and i might have forget some somewhere, but i have put plenty and take care to put them where it's need (mostly, big loop, so the VM have a chance to take back the hand).
It's working fine here, i have some hipcup sometimes, but my desktop is no more less responsive, vlc doesn't even miss a picture...
I have few newGRF only, and never really use them :P but i suppose it could make a big difference.
My cpu is a i7 950 and ttd can only busy a core fully (sometimes 98%, but more near 90% average) but on that big map with many vehicles and running it fastforward.

Here's another one with the same savegame and another openttd and some applications and my full desktop.
See, nothing really that bad, you must have something on your computer that take your cpu down.

Re: DictatorAI

Posted: 08 Aug 2011 09:00
by Brumi
Hmm... Sorry, 'it eats my CPU' doesn't describe the problem precisely, as OpenTTD on normal speed with DictatorAI only consumes about 10% of my computing capacity (and I tend to take care not to run unneccessary background tasks). But it is certainly true that OpenTTD lags visibly when your AI is running, especially on fast forward. The construction speed of competitors is set to 'very fast' when I'm testing AIs, which further increases the load.
So sorry, my wording was not correct...

Re: DictatorAI

Posted: 08 Aug 2011 09:07
by planetmaker
Brumi wrote:But it is certainly true that OpenTTD lags visibly when your AI is running, especially on fast forward.
Fast forward means "run as fast as you can". A lag is quite what can be expected then...

Re: DictatorAI

Posted: 03 Sep 2011 09:40
by krinn
I think i found your issue brumi, i have a big loop (with sleep) that call a test function that itself valuate engine type to find multi-answer... (that's for the story)
now for the problem: if the list of engines avaiable is big, that function is time consuming by itself (well, i can't do anything against that, you just have many engines and i must play with that), but i'll work to find a way to cache that result or another solution, because as-is the function is doing nearly nothing with default engine, but with a huge list of engine this indeed exhibit a noticeable slowdown. Must be why you were having trouble and i wasn't.
I'll work on that, and see in corners to improve it. I'll look for other functions that might be affect as well.

Re: DictatorAI

Posted: 01 Nov 2011 06:40
by Kogut
http://www.tt-forums.net/viewtopic.php? ... 71#p978171 - user reported freezes caused by this AI

Re: DictatorAI

Posted: 28 Nov 2011 00:53
by krinn
This is my current work, for now trains aren't still enable and savegame isn't working (well it is, but i didn't check if it need an update).
So it's just a work in progress release, i might upload that version to bananna once i fix bugs, savegame and some others things i need to do, but not as it is right now, so you could only grab it from here (see first post)

Re: DictatorAI

Posted: 27 Feb 2012 00:05
by krinn
So, i finally found a long standing bug that was crashing openttd, so faith is back...

Here's the latest version i've made, maybe not yet totally stable, but should work ok.
I change and improve many things, specially for big maps. The AI should handle huge 2048x2048 maps easy.

Re: DictatorAI

Posted: 13 Mar 2012 12:25
by krinn
I've stabilize my AI to version 1.53 you should be able to get it thru download content or from first page.

I'm still not releasing it with trains as i need some more work, but it's close to be end.

Savegame format has change, so please use this version if you need to convert an old savegame to the newer format, as next version should use newer API functions that will drop old savegame support.

Thank you for trying it and reporting bugs

Re: DictatorAI

Posted: 17 Mar 2012 12:29
by krinn
Another update, correct some bugs, add few functionalities (allow terraforming for road station now, try to solve a lost vehicle...)

Re: DictatorAI

Posted: 21 Mar 2012 00:43
by krinn
For ones curious to see, here's version 155 in progress, this is the first version with trains enable :D
(this imply be nice with the handling as it's still early and don't expect 0 crash...)

Anyway, if you're in mood to help, try it and report bugs, thank you.

Re: DictatorAI

Posted: 21 Mar 2012 20:05
by Brumi
Good to see that there is another AI coming which uses both trains and road vehicles, gladly testing it now :)

I've seen a crash with the ECS vectors and some vehicle sets loaded (probably UKRS/NARS, eGRVTS, Aviators, FISH, but I don't remember...), I don't know if it's because of these NewGRFs or not:
crash.png
crash.png (16.59 KiB) Viewed 9843 times
Otherwise it's working well so far in the vanilia edition :)

EDIT: Not anymore...
crash2.png
crash2.png (35 KiB) Viewed 9841 times
EDIT2:
I noticed that there is a single locomotive running on rail line which is already being used by another train. This locomotive has no orders.
trains.png
trains.png (95.95 KiB) Viewed 9838 times

Re: DictatorAI

Posted: 22 Mar 2012 00:22
by krinn
thank you brumi for trying and reporting those errors

- error 1 was already found and fix, a stupid one
- error 2 is more problematic and need more handling to fully correct the "why it happen", for now i already fix the "don't crash if it happen" anyway i've add a check to try to order a vehicle to goes to a "null" homedepot.
- error 3 worry me a bit more, as the no order solve depend on the error 2 (no order, trying to set new ones), but the train running alone is a bit more sad, as i have already think it could happen (running low on money after building the train and 0 cash to pay the wagons), and the AI should have catch it, and instead of starting that empty train, should have sell it. I suppose i didn't do it as good as i think :)


For the newgrf, i didn't test every grf that exist, but i have test some of them, and you could see the AI should handle them pretty well (the ones i test, like eGRVTS).
For the Aviators, if it's av8 something, my AI and all AIs i've saw, and even for human player, it looks impossible to make money with the costs and running costs those aircrafts have, i really like the drawing and the details of the aircrafts, but the settings ruin totally the fun of this grf (for me at least). I'm not sure how i should handle this one, except my generic handling of newgrf engine doesn't work with it, but i think it comes more from the newgrf maker than a "poor" handling of my AI.
In fact, the only one that bug me seriously was the Ikarus Set that report articulated vehicle as non-articulated ones.
Anyway i could confirm none of the errors you report comes from newgrf usage as you could get them too without them.

I didn't test yet non engine newgrf (stations or industry stuff like that).

Here's an update version with many fix and the error 2 (half-fix), that should run a bit better before crashing
I named it 155a, not as alpha, even it could fit nice, but just as i need a different name so people catch it's an update one.

Re: DictatorAI

Posted: 31 Mar 2012 19:33
by krinn
Here's another "update" of the work in progress with trains, the AI mostly remain the same, even some little change as been made to economy, some bug fixes that were affecting the AI (nothing related to trains)
A real lot of bug fixes for the trains part (the brumi's bug with trains going without wagons attach was a b**** to fix, but it's properly fix now). The ai now build its rails and plan its path in short interleaves and pause /resume the task later, so the ai isn't stuck for years waiting an answer from pathfinder with big distances.
The ai also now can retry when it fail building its route, stepping back a bit to replan a new path to avoid the error. This was originally in the AI (because of brumi's function to retry on failure) but it's now extend to calling itself the pathfinder as a subtask of the first goal and take a farer distance to replan the path.
I didn't add those functions to road pathfinding, as road pathfinding distances are always short and the ai always try to find its way from A to B using existing routes instead of pathfinding a good way to reach B. But i'll think about that later as it was a huge improvment to handling pathfinding and building big/long routes with troubles that might appears because you took a lot of time to pathfind and build a path and the world as change while you were doing that.

I still need some more work, but the ai is working ok "more or less" with trains now.

So you can grab the 155b (still not as beta) and give it a try.

Didn't think it would be that hard to handle trains at first, but cost of engine (putting a huge bill to build a route and so a huge risk for the AI safety), and also the API make it a great challenge, but it's funny to see the ai "trying" to play with trains, i just like trains a lot :P

Re: DictatorAI

Posted: 31 Mar 2012 21:46
by Zuu
Sounds great with the pathfinder tricks you have implemented and the ability to do other tasks from time to time.

Re: DictatorAI

Posted: 01 Apr 2012 09:34
by krinn
And it work great, i could share it with superlib, might need a lot of change to be handle by a lib, but i have already think i could ask a callback function to "build route"... even i'm not using superlib, you know i really like the idea of a "glibc" for noai :P

Re: DictatorAI

Posted: 16 Apr 2012 14:08
by MAG101
I seen a prodren since AI crashes due AL_ET_TOWN_FOUNDED does not exist.

First 2 ai crashes after its places a train station. and last pink ai crashes after building 2rd line