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

Post Reply
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

CluelessPlus

Post by Zuu » 17 Jan 2009 01:53

Hi all,

Background
Long time ago I wrote an AI called Clueless, it was actually the first posted user AI for the NoAI framework. It has been broken for long time as that was almost a year ago, minus a few months.

Clueless was not a very smart AI, thus the name. ;) One of the problems back then was that there existed lot less functions to query information from the map. Also in the beginning there was no friendly error messages when the AI crashes etc.

Now that the API has improved and matured a lot, and NoAI have been merged with trunk, I got the idea to get Clueless back into a non-broken form. This is actually not the first such attempt. I did some such work in June 2008. All this has resulted in CluelessPlus.


The two most annoying things with Clueless has been addressed. It does no longer spam towns with 10-30 road stations and then picks the best one. Instead it uses test mode and just records which places a station can be placed and after that picks the best one using same old criteria. As this new method is not as failsafe as the old one it restart the process if it can't build at the selected location.

Another thing that has changed is the pathfinder. Clueless now uses the library road pathfinder so it is compatible with built on slope and can get around industries, which the old pathfinder couldn't. To say the truth, the old pathfinder sucked quite a lot :)

Other than that, it manages vehicles which I don't remember if original Clueless had, as I'm quite unsure if it was possible to get number of waiting cargo at stations back then. The number of AI names has been raised from 8 to 16 due to the increased number of possible companies in OpenTTD.

The AI today, early 2010
CluelessPlus has since I brought Clueless up to date got several updates and fixes here and there to make it a better AI. It still only do bus transport between towns, but tries to do that good without being to much in the way.
Kogut - Sun Mar 07, 2010 wrote:clueless is nice, quiet ai - never crashes (for me), always is profitable (usually it is not very high profit) but sometimes is the richest company (better than Rondje!)
Some screenshots:
release_of_buses.png
15 companies, on the map, all starting the same time. The connection from this town has just been completed and all companies has to rush to get their buses into the lead of the worm of buses that competes for the passengers.
(77.27 KiB) Downloaded 666 times
graphs.png
(26.73 KiB) Downloaded 560 times
Download
See last post for most recent version, or use BaNaNaS - the content service for OpenTTD

You can do manual downloads from the bananas website as well as using the in-game content system. It is recommended to use the in-game content download dialog as then you'll automatically get all dependencies as well. If you opt for manual download, then you must make sure you get the dependencies as well.

Dependencies: (AI libraries)
Pathfinder.Road - version 3
Queue.FibonacciHeap - version 2
SuperLib - version 7

http://bananas.openttd.org/en/ailibrary/ (library download at bananas website)
Last edited by Zuu on 09 Apr 2011 16:28, edited 7 times in total.
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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 17 Jan 2009 21:59

Version 2:

- Has Save/Load functions, that detect when user tries to save/load and tries to warn the user that save/load is not supported. Also Load function sets a variable so that stops the AI from doing anything, which is better than starting as if it was a new company.
Attachments
CluelessPlus-v2.tar
(57.5 KiB) Downloaded 713 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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 18 Jan 2009 00:03

Version 3

Fix: Don't place signs when selling vehicles. That was a debug thing that I missed to remove.
Attachments
CluelessPlus-v3.tar
(57.5 KiB) Downloaded 579 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Topher
Engineer
Engineer
Posts: 13
Joined: 10 May 2008 00:21

Re: CluelessPlus

Post by Topher » 04 Apr 2009 08:51

I've encountered an error while playing a game against Clueless and several other AIs. Just so you know, I'm not much of a beta tester. I was just curious to see how well the AIs did, so... yeah.

Anyhow, here's the error.
Attachments
Clueless bug.png
(150.22 KiB) Downloaded 229 times

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 04 Apr 2009 19:47

Topher wrote:I've encountered an error while playing a game against Clueless and several other AIs. Just so you know, I'm not much of a beta tester. I was just curious to see how well the AIs did, so... yeah.

Anyhow, here's the error.
It is known that CluelessPlus has not yet been upgraded to the last API changes some time ago. That is the reason you don't find it in the in-game content server when using a recent nightly (or 0.7.0).

Thanks for taking your time reporting it though. Perhaps you downloaded it manually from tt-forums where no compability check is made. (compared to the in-game content service, which has support for min/max required OpenTTD version)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Timmaexx
Transport Coordinator
Transport Coordinator
Posts: 301
Joined: 03 Jan 2009 17:55

Re: CluelessPlus

Post by Timmaexx » 12 Apr 2009 09:44

Will you update CluelessPlus? Or is this the end of CluelessPlusAI?

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 12 Apr 2009 10:13

Timmaexx wrote:Will you update CluelessPlus? Or is this the end of CluelessPlusAI?
I could update it if there is an interest for it. It should only be a few changes to make it compatible again. But for the moment the development is on PAXLink. But if there is an interest I can update CluelessPlus so it run on 0.7.0 and recent nightlies.

Update
While I was just sitting on the train, I decided to try to update it from my laptop. So here is version 4 that works with the current API. I also added a small feature, when there is no buses available (AIEngineList contains zero non-articulated buses) it will not construct any bus stops or roads. But will continue to check for buses and when they become available it will start building. Not sure if this works against turning of buses for AIs as I have no idea if that affects what AIEngineList contains. On the other hand, if you turn of buses then CluelessPlus can't do much of anything anyways.


Edit: There is a bug in the code that lead to clueless having lot of buses without orders after a while.
Attachments
CluelessPlus-v4.tar
Tested with last nightly (11 o clock UTC, 2009-04-12)
(58 KiB) Downloaded 466 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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 16 Jul 2009 06:34

CluelessPlus version 5

Changes:
* Does not get a lot of buses without orders anymore
* Renewal of bus fleet: Sells old buses, and then because of reduced capacity it buys new ones.
* Enhanced selling mechanism so that the AI don't need to wait for a bus to be sent to depot and sold before continueing with the next task.
CluelessPlus-v5.tar
(79 KiB) Downloaded 385 times

Edit: Another thing that changed (internally) was that I removed one data structure that contained all buses for a connection. Now that information is read from the map as the intersection of the buses that visit all the stations that belongs to the connection.
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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 17 Jul 2009 05:02

CluelessPlus version 6

Changes:
* Game loading support (including older saves as long as there is goto depot orders so it finds the depots)
* Use congestion detection code from PAXLink to detect congestion at bus stations.


The congestion detection code is tuned a bit differently from PAXLink, but does still has the problem that it sells/buys buses a bit to much to be good for its economy. The upside though is that it renews the bus fleet as it always sells the oldest bus of a connection. :-)


And yes, now you can use CluelessPlus in your games that you want to save and then load again. Good isn't it?
Attachments
CluelessPlus-v6.tar
(76 KiB) Downloaded 433 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Wold
Transport Coordinator
Transport Coordinator
Posts: 318
Joined: 03 Aug 2006 19:32
Skype: woldy_bg
Location: Bulgaria

Re: CluelessPlus

Post by Wold » 24 Jul 2009 16:53

Got an error :
Attachments
Fonnton Transport, 2nd Apr 1976.png
(80.27 KiB) Downloaded 86 times
Image

Rantanplan
Engineer
Engineer
Posts: 5
Joined: 27 Jul 2009 20:28

Re: CluelessPlus

Post by Rantanplan » 27 Jul 2009 20:39

Hi,
Wold wrote:Got an error :
i also keep getting this one. Hope you can fix it. Nonetheless, this is some terrific AI. :)

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 27 Jul 2009 23:50

Thanks for reminding me. I have looked on the code and a fix for the crash is easy. It is simply the case that it failed to build one of the stations and tries to get the station ID of a null tile. Though I wonder why it in first place failed to place a bus stop in the town. Do any of you have an idea of what settings/situation in your games that caused it to fail in the town mentioned in the log?

Save games are welcome if you have any.

I'll soon upload a fix to the crash, but I am interested if I can find any bugs/short comings in the station construction code.


Edit: I have not been able to reproduce the problem myself and would be very interested in a save game that might help me find out why it fails to build a bus station. Does it happens to you at the beginning of every game or just at some times? The best would be a save game before it happens, but having the AI crash-log + save game would help a bit I think.

For now I will not upload the fix, as while it fixes a bug in the error handling I would be happy to track down the reason the bus/truck/depot station placement routine fails.
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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 29 Jul 2009 04:19

Version 7

* Crash when failed to build bus stop in town fixed. (failure to build bus stop in those cases are however not fixed, but it should handle the failure without crashing again)
* Respect the disable road transport mode setting.
* Implements the MinVersionToLoad() function. (returns 1)
Attachments
CluelessPlus-v7.tar
(77 KiB) Downloaded 339 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

Rantanplan
Engineer
Engineer
Posts: 5
Joined: 27 Jul 2009 20:28

Re: CluelessPlus

Post by Rantanplan » 29 Jul 2009 09:26

Zuu wrote:Thanks for reminding me. I have looked on the code and a fix for the crash is easy. It is simply the case that it failed to build one of the stations and tries to get the station ID of a null tile. Though I wonder why it in first place failed to place a bus stop in the town. Do any of you have an idea of what settings/situation in your games that caused it to fail in the town mentioned in the log?

Save games are welcome if you have any.

I'll soon upload a fix to the crash, but I am interested if I can find any bugs/short comings in the station construction code.


Edit: I have not been able to reproduce the problem myself and would be very interested in a save game that might help me find out why it fails to build a bus station. Does it happens to you at the beginning of every game or just at some times? The best would be a save game before it happens, but having the AI crash-log + save game would help a bit I think.

For now I will not upload the fix, as while it fixes a bug in the error handling I would be happy to track down the reason the bus/truck/depot station placement routine fails.
It actually happens to me every time I load a saved game with a CPU player using this AI module, playing in Hard difficulty (unaltered). Although i don't remember this happening very early in the game.
Here's a savegame, hope it helps. :)
Attachments
Quito Transportes, 18º Abr 2038.sav
(502.19 KiB) Downloaded 572 times

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 30 Jul 2009 01:12

Thank you for posting the save game. The reason why it failed to place the bus stop was that it had a fixed maximum of number of road tiles to visit in order to find an empty road tile next to a road tile where it can build a bus stop. Now I have changed this limit so it depend on the population of the town so that it should have a possibility to find the edge of really big cities too.

Version 8
* Tuned the maximum tiles it search to find a place to build bus stops/depots in towns. It also now depend on town size (population).
Attachments
CluelessPlus-v8.tar
(77 KiB) Downloaded 359 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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

CluelessPlus - version 10

Post by Zuu » 02 Sep 2009 19:46

Version 10
Last version was marked as version 8 on BaNaNaS, but in info.nut it returned version 9, so therefore I jump directly to version 10.

Change log:
  • Expand stations up to N number of bus stops as the stations get overcrowded. N can be configured in the AI Settings. Default is {1, 2, 4, 2} for {easy, normal, hard, custom}.
  • Don't buy/sell vehicles if a buy/sell vehicle(s) operation was performed the last 30 days. => reduces the behavior of buying tons of buses and then selling them soon.
  • Sometimes use full load orders. (during the first year and if station rating is low while not too many passengers is waiting on either of the stations)
  • When selecting pairs of towns to connect some more things adds up to the score now:
    • If town center is on desert/snow
    • The equality of the pair (population difference and that either both or none are on desert/snow)
  • Reduced the number of buses initially built a bit
  • Now uses the AISignList instead of the deprecated function to get the maximum sign ID.

For those who like CluelessPlus for its not to overcrowded behavior compared to some other AIs should probably set maximum number of bus stops per station to 2 or maybe 3. That said, it will take some time before CluelessPlus reaches 4 bus stops since it requires the usage to be over 150% and number of waiting at least 150 passengers at either town before it adds another bus stop. 100% usage = one bus per station tile. Since bus stops can have up to 3 buses on the bus stop tile the usage can go over 100%. All statistics it uses for expansion decisions are sliding averages over time. If you enable showing debug signs, then you can reed these stats for each station in the following format:

w<num waiting> r<rating> u<usage in %> a<airport holding queue + num non-stopped in hangar>

While CluelessPlus don't build airports it shares this code with PaxLink which makes use of the amount of planes that wait to land or are stuck in the hangar.


If you download CluelessPlus manually you need to obtain and install version 3 of the road pathfinder library.
Attachments
CluelessPlus-v10.tar
(91 KiB) Downloaded 295 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: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 03 Sep 2009 16:20

Version 11

Change log:
  • Fixed the limits for when it will upgrade a station with more bus stops. (I had reduced all the limits by factor 10 in order to check the save/load code without having to wait too long for it to expand)
  • Bonus: Now CluelessPuls places the HQ close to the first bus stop. It only places the HQ next to roads and consider both the cost and distance to bus stop when it chooses the location to build it. If placing the HQ close to first town of first connection it will retry with the first town of the second connection and continue until it succeed.
Attachments
CluelessPlus-v11.tar
(95 KiB) Downloaded 449 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Menno
Tycoon
Tycoon
Posts: 1190
Joined: 05 Feb 2005 14:35
Location: Netherlands, Utrecht

Re: CluelessPlus

Post by Menno » 09 Oct 2009 21:00

I tried a game with Cluelessplus v11 among other AI's.
IMO it performed reasonably, though not more than that. After 10 years it had over 350 road vehicles, of which only incidentically one did have a 10k+ GBP profit per year. On average, each vehicle made about 3500 per year. Also, it had a habit of clogging up cities. Maybe using destinations further apart would improve both points?
See attached save game.
OpenTTD 0.7.3
NewGRFs: OpenGFX, better vehicles names, Av8 1.501

(I will post comparable posts in the other AI's topics)
Attachments
AI game.sav
(658.84 KiB) Downloaded 304 times
*hmz*

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu » 09 Oct 2009 23:33

Thanks for your report!


I loaded the save game you posted, but I can't really see where CluelessPlus have clogged up any of the cities. Yes it has quite some buses, and some of them sometimes break down, even if they are just 1-3 years old with a reliability of 80%, but I can't really see any serious traffic jams. CluelessPlus analyses how congested its stations are and makes sure not to overload them with to much buses so that there will not be a too long queue from its stations.

I can agree that in your scenario there are town pairs which have a bit too many buses and it could benefit from having less buses there which runs with a higher fill rate.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
Menno
Tycoon
Tycoon
Posts: 1190
Joined: 05 Feb 2005 14:35
Location: Netherlands, Utrecht

Re: CluelessPlus

Post by Menno » 10 Oct 2009 15:00

Zuu wrote:...

I can agree that in your scenario there are town pairs which have a bit too many buses and it could benefit from having less buses there which runs with a higher fill rate.
That was about what I meant to say (not really congestion, ok, sorry :) ). Also, when competing against other bus-AI's, towns get bus-filled much faster of course. That is something which certainly played a part in this game.
*hmz*

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Google [Bot] and 1 guest