CluelessPlus

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

Kyzentun
Engineer
Engineer
Posts: 1
Joined: 16 Apr 2010 20:42

Re: CluelessPlus

Post by Kyzentun »

I got a crash using what I hope is the most recent version of CluelessPlus (v18). It said to report with a screenshot, so here you go. At the time, I was not actively competing with the AI, though one of my old sabotage efforts may have been in its way. You can see what I was doing to sabotage AIs in the screenshot. I don't know what info you might need besides the AI Debug window.
crash_screenshot.png
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

That's an intentional crash in the sense that the code found an error that it do not handle so instead it calls a function that do not exist with a long and descriptive name. Basically it is like an assert but with a name.

My guess is that the AI checked that the crashed vehicle was valid, then called a function to clone the crashed vehicle which had just disapeared when my clone function was called which "gracefully" handeled that by crashing the AI so that the error was found.


Thank you for the bug report. If you or anyone else see this again, please let me know so that I know if it is a frequent issue enough that I should get out a fix soon or if it can wait until the cargo compatible version of CluelessPlus is solid enough to be released. Please note that due to work with my masters thesis and some other stuff, I don't have a lot of time to spare for my AIs at the moment.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CluelessPlus

Post by Kogut »

Situations like this are way more likely for players with that kind of infrastructure.
More crashed RV -> higher probability to have crash due to vehicle crash.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Kogut wrote:Situations like this are way more likely for players with that kind of infrastructure.
More crashed RV -> higher probability to have crash due to vehicle crash.
Of course, the probablity is higher if the code in question is ran more often. However that was not really my question. My question was if any of the users has a problem with this crash occuring often. Even if crashing vehicles increase the risk of it happning, it could be anything from very uncommon to a rather common problem.

The bug happens because while executing step 2 in the following example the vehicle gets removed and when the security check is performed in 3 it does no longer exist and the AI crashes itself as a means of throwing an assert.

Code: Select all

1. Check if veh exist
2. do something
3. Check if the veh still exists -> fails
By moving 1 closer to 3 I've pretty much eliminated the chance of this bug to happen in my local working copy. However, these kind of concurrency bugs are hard to prevent completely. By before step 1 call AIController.Sleep(1) you can get 10 000 fresh op codes and hope that you will be able to reach down to 3. before the OpenTTD game loop continues, but totally preventing all of these possible problems is very hard.


While the currently in development CluelessPlus version is fairly good performance wise, it really needs better station placement/upgrading/management in order to reduce the heavy jams it produces from time to time. Also on my todo is making it close down/suspend connections when an industry closes down or drop production to zero. The reason for my question regarding the bug was to query the users if the bug happens often for them or not. If it is a real problem I can disable some of my last additions and make a new release that should work good, but if it is only a theoretical problem, then I rather spend my time on working on the cargo enabled version.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CluelessPlus

Post by Kogut »

[quote][/quote]
Attachments
Przechwytywanie.PNG
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Thanks for your report, I'll take a look at it.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Update - Version 19!

After several months of work on and off, here is version 19 of CluelessPlus! Most noticeable, it contains support for cargo transport using trucks.

Here CluelessPlus is supplying a Fizzy drinks factory with supplies and transports the fizzy drinks to a town. The company "Cluemore" is CluelessPlus version 19 and "Clueless" is version 18.
AI Observer, 7th Feb 1955.png
AI Observer, 7th Feb 1955.png (58.06 KiB) Viewed 4079 times
Settings
CluelessPlus19-settings.png
CluelessPlus19-settings.png (7.62 KiB) Viewed 4079 times
Of course, there is a setting where you can disable transport to/from industries. In town-to-town only mode it however do transport mail on top of passengers.

Another new setting is if CluelessPlus should compete against other companies or not. It works on the transport volumes last month, so if you have just built the stations it could still use that industry. Another case is if you visit the source very seldom and let the cargo pile up for more than a month so that the transported last month is sometimes zero.

The new Log-level setting is mostly there to not spam the log more than necessary.

In the "think and build slower" mode, the build speed for straight road has been increased by about 100%. It is still fairly slow though, but not as badly slow as before.

Download
Preferable, use the in-game content download system to get CluelessPlus as it will get all the required libraries for you. If you need to download manually. Make sure you also download:
  • SuperLib v3
  • Pathfinder.Road v3
  • And all dependencies for Pathfinder.Road which I don't know exactly which they are.
CluelessPlus-v19.tar
(200 KiB) Downloaded 142 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Version 20

It's too long since last release, so I forgot to not only change the unique 4-letter ID to non-SVN id, but also change the AI name so that it does not contain "SVN". Version 20 is now named "CluelessPlus" correctly without the SVN ending.

BaNaNaS do not let me change the uploaded file, so therefore I have to push out a new version. It is probably good that it force you to do updates correctly though. :-)

Please see the notes in the post above about downloading dependencies manually if you download manually. It is recommended to use the in-game download system if you can.
CluelessPlus-v20.tar
(200 KiB) Downloaded 135 times

Edit: There was a more serious error than the name that I found which will be addressed, but the fix will take some time and until then I've disabled the AI on the in-game content downloader.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: CluelessPlus

Post by Brumi »

Congratulations Zuu, Clueless is getting more and more clueful :D
I'm running a quick test, the only strange thing is that Clueless hasn't built an industry-to-industry route yet, althgough it is 1959 (started in 1950). AI settings are default, I started it from the console without any extra parameters.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Update - Version 21

Hopefully the last quick-fix of the version 19 release. See below for what has been fixed.

As always, if you download manually, make sure to get the dependencies as well. See the download info for version 19.
CluelessPlus-v21.tar
(200 KiB) Downloaded 168 times
Brumi wrote:I'm running a quick test, the only strange thing is that Clueless hasn't built an industry-to-industry route yet, althgough it is 1959 (started in 1950).
That was one of the bugs I found and has now fixed. It was due to me finding a spelling error in a function name, renamed it just before the release, but forgot to rename it in both the declaration and the definition. :-)

In addition to that I found out that there was an error in the code that loads old pre version 19 save games, which has now been fixed. Loading of suspended connections should now as well work better.


So please update to version 21 and it should make industry connections as well. :-) Though since towns provide cargo in both directions it is quite common that it do quite a few passenger connections in the beginning if there are large towns at the start.
Congratulations Zuu, Clueless is getting more and more clueful :D
Thanks.

I've decided to remove the "simple" banans tag now that it does a bit more than basic passenger transportation and changed the description to focus more on its load balancing than simpleness. That said, a PI-regulator for the vehicle buy/sell logic would be nice to have to not overshoot the target too much. :-)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CluelessPlus

Post by Kogut »

I think that limit for maximum pathfinding time may be usefull.
Clueless wasted here about 1,5 year.
//AIAI just have wasted 1 year in the same place, I also may improve sth in that area (after trains)
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (14.94 KiB) Viewed 4040 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

It does have two maximums:

* Maximum number of loops
* Maximum cost of found path (about 5/2 times the cost of an optimal path plus a fixed start value)

But it can surely be improved
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CluelessPlus

Post by Kogut »

static ENCODE_CHARS = ":)D|(/spOo3SP><{}[]$012456789abcdefghijklmnqrtuvwxyzABCEFGHIJKLMNQRTUVWXYZ?&;#=@!\\%";

Why "\" is used 2 times?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CluelessPlus

Post by planetmaker »

it's an escape character and it escapes itself. Most probably.
deamonhunter11
Engineer
Engineer
Posts: 56
Joined: 10 Mar 2010 08:23

Re: CluelessPlus

Post by deamonhunter11 »

\ is used for division so \\ is used to show \ that isn't division.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: CluelessPlus

Post by Yexo »

deamonhunter11 wrote:\ is used for division so \\ is used to show \ that isn't division.
That makes no sense as you can't do division within a string.
planetmaker wrote:it's an escape character and it escapes itself.
Correct.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CluelessPlus

Post by planetmaker »

A small comment dedicated to this AI as based from my (short) competitive run with a number of other AIs: you do well and manage to build nice road networks :-)

Best areas of improvements now seem to be from this brief test: Some of the vehicle management could probably be improved (see the additional screenshot). I've seen other AIs stop vehicles which are waiting; it saves running costs :-). Maybe one could also add trains, but that's a big task :-)

Attached a screenshot which compares this AI with the best AI (AIAI) and the best train-using AI (simpleAI)

All in all: kudos, you did a great job :-)
Attachments
cluelessplus.png
queue
queue
clueless2.png (104.62 KiB) Viewed 3866 times
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Thanks for the warm words!
planetmaker wrote:I've seen other AIs stop vehicles which are waiting; it saves running costs :-)
I personally think this kind of micro management is an abuse of the monitoring benefits of an AI. I will probably not implement this. I do some other micromanagement stuff but that is regarding statistics collection, not actual modification of vehicle states.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CluelessPlus

Post by Kogut »

And with multiple vehicles it may be extremly hard to handle it in efficient way.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Darmarius
Engineer
Engineer
Posts: 5
Joined: 25 Jul 2010 15:51
Location: Canada

Re: CluelessPlus

Post by Darmarius »

I've hit another problem with CluelessPlus: it seems to hog the CPU resources for about 10 sec, in which I can't do anything with the game (and the game cannot render itself). It's not very long, but it's annoying since it freezes a couple of time per game year.

I first stumbled into this when playing a game with all ECS vectors loaded and a couple of other newGRF (2cc train, eGRVTS, av8, among others). So, I did some quick testing: I started a fresh new game, year 1950, 1024*1024, without any newGRF loaded, started CluelessPlus with the console command (start_ai CluelessPlus), and patiently waited for the game to freeze by moving my mouse franticly around the screen. It DOES freeze (around 2nd Jan), but merely for a second or two, so I might of hit that before but hadn't noticed ;) Then, I started another game with the previous newGRF configuration (and, of course, map configuration) and did the same thing; it froze for a good 10 seconds. I made yet another game, this time with 512*512 map size without any newGRF, and it freezes for a split-second so it's barely noticeable, could be passed of as a glitch of the mouse... Me thinks it might be related to some industry kung fu, since with ECS there's a LOT more industry present in the map.

This never happened with 10 AI loaded (without CluelessPlus), so it's clearly a CluelessPlus-related issue (or maybe you use a NoAI feature that nobody else does?).

I'm running OpenTTD 1.0.2 on Linux and CluelessPlus version is v21. All other newGRF used are the latest version on BaNaNaS.

p.s.: I can provide screenshot to "show" behavior if needed.
p.s.2: I know it was rejected and I agree with the arguments given, but this might be a nice argument for multi-core support ;)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 21 guests