Page 1 of 9

CluelessPlus

Posted: 17 Jan 2009 01:53
by Zuu
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:
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.
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.
release_of_buses.png (77.27 KiB) Viewed 2961 times
graphs.png
graphs.png (26.73 KiB) Viewed 2855 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)

Re: CluelessPlus

Posted: 17 Jan 2009 21:59
by Zuu
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.

Re: CluelessPlus

Posted: 18 Jan 2009 00:03
by Zuu
Version 3

Fix: Don't place signs when selling vehicles. That was a debug thing that I missed to remove.

Re: CluelessPlus

Posted: 04 Apr 2009 08:51
by Topher
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.

Re: CluelessPlus

Posted: 04 Apr 2009 19:47
by Zuu
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)

Re: CluelessPlus

Posted: 12 Apr 2009 09:44
by Timmaexx
Will you update CluelessPlus? Or is this the end of CluelessPlusAI?

Re: CluelessPlus

Posted: 12 Apr 2009 10:13
by Zuu
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.

Re: CluelessPlus

Posted: 16 Jul 2009 06:34
by Zuu
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 626 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.

Re: CluelessPlus

Posted: 17 Jul 2009 05:02
by Zuu
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?

Re: CluelessPlus

Posted: 24 Jul 2009 16:53
by Wold
Got an error :

Re: CluelessPlus

Posted: 27 Jul 2009 20:39
by Rantanplan
Hi,
Wold wrote:Got an error :
i also keep getting this one. Hope you can fix it. Nonetheless, this is some terrific AI. :)

Re: CluelessPlus

Posted: 27 Jul 2009 23:50
by Zuu
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.

Re: CluelessPlus

Posted: 29 Jul 2009 04:19
by Zuu
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)

Re: CluelessPlus

Posted: 29 Jul 2009 09:26
by Rantanplan
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. :)

Re: CluelessPlus

Posted: 30 Jul 2009 01:12
by Zuu
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).

CluelessPlus - version 10

Posted: 02 Sep 2009 19:46
by Zuu
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.

Re: CluelessPlus

Posted: 03 Sep 2009 16:20
by Zuu
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.

Re: CluelessPlus

Posted: 09 Oct 2009 21:00
by Menno
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)

Re: CluelessPlus

Posted: 09 Oct 2009 23:33
by Zuu
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.

Re: CluelessPlus

Posted: 10 Oct 2009 15:00
by Menno
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.