I've written a simple AI for openttd, called BorkAI.It's a truck-only AI that creates routes between industries and to towns (but not passengers or mail).

As the proud product of a couple of weeks of trying to learn the NoAI frameworks, it sportsthe following features (yes, features, not bugs )

* slow-as-hell pathfinder. Abusing the RoadPathfinder isn't the best option, and it shows on big maps,when it can get literally stuck. It's still fine on small ones though.* approximate estimation of number of trucks needed. Expecially when competing with others, or transporting hundreds of goods from factories. Prepare for a few traffic jams .* Bad NewGRF support. Shouldn't crash, but because of some assumptions won't work very well in a nondefault setting.

Well it has a few *nice* features also

* Does most of the things needed to survive: renewing trucks when they get old, upgrading to faster ones, handling of economy changes (industries appearing/disappearing).* It's eco-friendly. Try not to build unneeded roads. Actually this is a tunable so you can force it to build the absolute minimum of road required to get from oneplace to the other. Nice when playing against it. Or you can let it build as much road as needed to the shortest route available.* In fact, on the small maps, it's more or less competitive with the other AIs. It won't die easily.

Any feedback is welcome, expecially from someone playing against it (I don't like to play against an AI), or using any kind of customization.

I've been testing your AI for a while, no bugs or crashes so far I didn't actually play against your AI, but from a player's point of view, I think it would be good not to transport only the "best" cargo. Anyway, on sub-arctic and sub-tropical climates, gold/diamonds are not always the best choice, as production is substantially low.

You're right, at the moment the transport selection algorithm is quite naive,but my first priority was to obtain a "complete" bot, at the cost of a simple behaviour.

Beside improvements to the algorithm itself (like taking into account the amount of goods produced), I plan toadd some randomness to the behaviour of the AI, and make it tunable, so that one can decide between a varied AI and a tougher (iif boring) one, to play against other AIs for example.

I uploaded a new version.The new one has much better performance, making it usable also on medium-sized maps (eg. 512x512).I also fixed a number of bugs, mostly related to the construction of road/stations/depots, and how ordersare handled.Also, this version shouldn't crash any more when used with some particulare NewGRFs.I also added some support for mail and passenger transport. If far from perfect, as it won't work very wellin scenarios like sub-tropical. For this reason is disabled by default but can be enable with a setting.Other two settings available are mostly for when you play against it.One sets how much the AI will try to re-use existing roads, while the other adds some randomness to thedecisions of the AI (at the moment, it only affects which goods will be transported). This should allow for a more pleasing game.In the end the AI should also perform better against other AIs.As always, some feedback is very welcome.

The setting to enable/disable buses and mail could be made a tri-state setting.

Off

Climate dependent

On

If Climate dependent is selected, you only use mail trucks and buses if the climate is temperate. Via AIGameSettings you can access virtually any setting that exist in openttd.conf. The easiest way to figure out their names is to open openttd.conf and search for string that you think the setting name would contain. Or browse it from top to bottom until you find something likely. Another option is of course to make two openttd.conf files with only a change to the ladscape that differs and then diff the files.

I suspect main.nut:871. If I read your code correctly you create a list containing every possible route, which means that list can be quite long. Since array.sort() cannot currenctly be suspended while it's running, it must run to completion. Not only does it take quite some time to sort an array containing 50000 elements using squirrels qsort implementation, it even runs out of stack causing OpenTTD to crash.

I'm considering to reimplement the sort() function in squirrel instead of in C++. While this would make your code work again, it'd also cause a big slowdown. I'd advise you against using such big arrays completely.

Ok. I couldn't find a way to implement sort() in squirrel (at least not as correct replacement for the current C++ version. After a suggestion from Rubidium I replaced the custom qsort function in squirrel by the C++ std::sort and now it works properly. This means you're AI still works.

I've tried to run your AI on a few very big maps, and every time it takes a very long time before it does anything at all. After 2 years in-game time I've just stopped the game when your AI still didn't build anything at all.

Hi, thanks for the feedback, and sorry for the delay in answering (I had notifications disabled).I'll address this issue and post an update as soon as possible.In any case at the moment the AI is of little use on big maps for that reason and for many others.With time I'll fix them too.

I uploaded a new version that addresses the problem at hand.Beside that, it provides much better performance on big and high density maps.It still far from optimal, but the AI should do something interesting now.I have a few more changes in mind that will solve the problem, but first I'll try to fix the performance of the planner (it take ages to build a route,even on short distances).

Hi,I tried to play with your AI today and it builds some nice routes and makes good profit.Then it had a little bit bad luck and a train crashed into a vehicle and it seems that it doesn't like that and crashed too.

I replaced the loop which doesn't work with

foreach(route in this.routes){

but it does only have a few routes stored, it seems. So I don't have a clue what to do exactly to fix this.

Hi,I tried to play with your AI today and it builds some nice routes and makes good profit.Then it had a little bit bad luck and a train crashed into a vehicle and it seems that it doesn't like that and crashed too.

I replaced the loop which doesn't work with

foreach(route in this.routes){

but it does only have a few routes stored, it seems. So I don't have a clue what to do exactly to fix this.

Here's the AI Debug window:

Attachment:

bork1.png

Fixed ! Thanks for the bug report.Now it should work as expected.

It seems that nobody ever had a vehicle crash. Or at least nobody ever reported it.Even including myself ...

The fixed version is already on Bananas, together with passenger handling enabled by default.There's a little bug (in some scenarios/configurations bus won't be used) that I fixed only after uploading the new version... I'l re-upload another one tomorrow.

Who is online

Users browsing this forum: No registered users and 5 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum