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

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

Re: CluelessPlus

Post by Zuu »

Nice that you had debug signs enabled. Looking at the bus stop sign it only has a usage of 141. I don't remember what the threshold for not building more buses is but the threshold for selling buses is as far as I remember above 141. Probably rather close to 200. (A non-drive-through bus stop can get a maximum usage of 300 which corresponds to two buses at the stop and one waiting to enter.)

Apart from this usage number CluelessPlus do not try to detect queues and jams further away from the bus stops.

What difficulty setting did you use? CluelessPlus can expand and build more bus stops, but it has a maximum limit per town that is dependent on the difficulty setting unless explicitly set in the AI Config dialog. (on easy the limit is 1 bus stop per town IIRC)

Thanks for doing these tests and taking yourself time to post the results for each AI.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CluelessPlus

Post by planetmaker »

Zuu wrote:What difficulty setting did you use? CluelessPlus can expand and build more bus stops, but it has a maximum limit per town that is dependent on the difficulty setting unless explicitly set in the AI Config dialog.
I use custom difficulty settings. And sure enough all those AIs are worth the detailed feedback, they all are a lot of work, they do a good job and are fun :-) so this is the least I can do.
Attachments
difficulty and AI settings
difficulty and AI settings
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Okay, it is probably still the low usage level that is the cause then. I didn't want to spam towns with bus stops unless they are needed so I think I put the usage limits quite high, but clearly it needs an additional measurements to detect queues.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: CluelessPlus

Post by planetmaker »

If it helps, here's the savegame (OpenTTD r19154+). You'll need a lot of AIs, though, but everything's on bananas.
Attachments
AI-battle.sav
(522.64 KiB) Downloaded 473 times
Last edited by planetmaker on 20 Feb 2010 09:33, edited 1 time in total.
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 338
Joined: 13 Jul 2008 00:57
Contact:

Re: CluelessPlus

Post by Michiel »

Zuu wrote:Thanks for doing these tests and taking yourself time to post the results for each AI.
Just wanted to second that :)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

This is mostly an error report to serve as a reminder to myself.

The AI should from time to time check the bus stops and see that they are connected to the town-roads. This probably happened because there was a bus in the way when it tried to connect the road. (or insufficient with money)
Attachments
Unnamed, 14th Aug 1952.png
Unnamed, 14th Aug 1952.png (39.89 KiB) Viewed 5537 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 »

Update - version 16

First I should say that I have not addressed the queuing issue that PM raised.

Changes:
* Bridge over rail/canals/rivers
* Penalize rail-crossings in case it don't find a bridge path immediately .
* Bus stops that are not connected to the 'front' tile are now detected and are either connected or removed (if connection fails due to other issues than vehicles in the way or no funds). The last bus stop will never be removed though since that would require me to implement closing down lines or finding a new spot for the station. (the later shouldn't be very hard, but I haven't spent any time on it)
* When repairing connections that seems broken (quickly reduced profit), give a higher penalty than normal to building new road to reduce the parallel roads that the previous CluelessPlus version could create sometimes. Only if re-building with these higher penalties fails, then try again with CluelessPlus-normal penalties.

An update has already been uploaded to BaNaNaS.
Attachments
CluelessPlus-v16.tar
(96.5 KiB) Downloaded 167 times
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 »

Sth strange happened with that nice AI
Everything to that one station, vehicles are 2 years old.
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (115.35 KiB) Viewed 5470 times
clueluss fail.sav
(65.34 KiB) Downloaded 155 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 »

Thanks for your report.


The reason why this happened is:

* It probably bough a lot of buses in one go. The selection of number of buses to buy in CluelessPlus is let say very primitive. I was surprised to see that it doesn't even take into account the capacity of the buses. :-D Only the amount of waiting passengers and no maximum limit.

* The station in the screenshot has three bus stops but the buses only uses one of them at the moment, so the usage rating of the station overall isn't too bad. Only ~ 90 in usage on a scale from 0 to 300 since the two other bus stops are completely unused. If you let it play for a while it will distribute among two of them.

* Finally, in order to sell vehicles, there is no condition related to the amount of passengers waiting at the bus stop, only the overall profit of all vehicles on that connection and the station usage ( sell on usage > 200 or profit < 0). In this case the usage criteria is not met and it will take a while before the profit criteria is met.


Of course there is many things here to improve to avoid this situation. Just wanted to explain why it happened since you was so kind and provided some feedback.

The reason why it doesn't look at the amount of passengers waiting at the stations could be for historical reasons (when Clueless was initially written NoAI API did not provide that information). That said todays CluelessPlus do some checkings on the waiting amounts so it can't only be blamed on historical reasons. That said some of the inner workings of eg. station placement is fairly the same from the old times when you just knew if an action had succeeded or not but almost no information could be acquired from the map.

I noticed a bug in the loading code that would remove all stations that it could leaving only stations that did not have a bus on them when the game was saved. Now thats a nasty bug. :-)
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 posted that situation - without any fatal bugs, because 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!).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: CluelessPlus

Post by Kogut »

Like in that game

=====
bug
On minimal loan CluelessPlus refuses to start construction.

it is caused by following code in main nut

Code: Select all

1009 // ... check if we can afford to build some stuff
1010 if(this.GetMaxMoney() > 100000 && !engine_list.IsEmpty() && !AIGameSettings.IsDisabledVehicleType(AIVehicle.VT_ROAD))
I suggest to change 100k into 90k.
Attachments
example.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 »

Version 17

Many have we been playing evil games with the AIs by crashing their road vehicles. Now here comes an AI that fight back by build bridges over the rails! Well, I should say that it is not fool proof and I'm sure most players that want to crash CluelessPlus' road vehicles in an evil manner will figure out ways to dot it also in the future. However, I think it is a good addition for the cases when AIs or players are to lazy to build bridges over CluelessPlus' roads.
Larningville Transport, 7th Aug 1957.png
Larningville Transport, 7th Aug 1957.png (16.44 KiB) Viewed 5355 times
Changes/News:
  • I have tried to address the situation in clueless_fail.sav by doing some improvements in the right direction. I'm sorry it is a few weeks since I did this so I don't remember exactly in detail what I did.
  • In addition to the changes in v16 that made CluelessPlus bridge existing rail a new functionality has been added that under some conditions replaces level crossings with bridges. This can happen when it "repairs" a connection or when a bus gets hit by a train. (when there is an accident and the rail crossing can't be replaced yet the tile is stored in a wait list and the level crossing is replaced later) Note that only if CluelessPlus owns the road, it is able to replace the level crossing with a bridge.
  • Most utility functions in the Helper class has been removed and instead the new SuperLib is used. Some functions were to specific to CluelessPlus and has been placed in a new ClueHelper class.
  • The minimum OpenTTD version at BaNaNaS (for v16 and v17) has been set to 19008 (1.0 beta 4). I need yet to verify that it actually works with 1.0 beta 4. The probably newest feature that CluelessPlus uses is ingame changeable settings.
The last suggestion by Kogut to reduce the limit for construction to less than 100 000 has not been included in version 17 and that is simply because I forgot to look through the thread for not yet addressed issues before releasing v17 after having been working quite a bit on figuring out how to organize SuperLib.


Dependencies
SuperLib - version 1
Pathfinder.Road - version 3

If online content do not work for you you can download them from here: BaNaNaS (my guess is that SuperLib will become available after next time the binary mirrors gets updated)

CluelessPlus-v17.tar
(116.5 KiB) Downloaded 184 times
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 »

Zuu wrote:Now here comes an AI that fight back by build bridges over the rails!
Great idea, I'm going to try it :D

EDIT: The feature is working well, but it seems that CluelessPlus v17 doesn't buy any buses if the Generic Tram Set is loaded. The connections are built nicely, they are only lacking the buses.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: CluelessPlus

Post by Zuu »

Version 18
Not a lot, but a few changes and tweaks:

Changes:
  • Don't try to buy trams
  • Lowered the money limit to 95 000 so we start building when the loan is maximum 100 000.
  • Replace level crossings with bridges also if the road is built 90 degree against the slope direction of a tile with just two raised corners
  • SuperLib 2
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 »

Zuu wrote: Note that only if CluelessPlus owns the road, it is able to replace the level crossing with a bridge.
1) I use your great idea in new (unpublished) version of AIAI, so also AIAI roads are safe!
2) Small idea - what about carring tourists ECS tourists? Imagine: first AI fully combatible with ECS :P
3) I think what to do with vehicles trapped under bridges.
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (33.81 KiB) Viewed 5245 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 »

3. You could look for your own vehicles by going through the list of all vehicles and check if their location is under the bridge. Then you could wait until there is no vehicles on the rail before removing the road. Your opponents vehicles are harder to check for because you can't see where they are. A problem is that AIRoad.RemoveRoad[Full] does not fail if removing road on a piece of rail fails.

I realized now that you could probably afterwards check if the rail tiles has road transport type to see if removing road failed and act upon that. You would probably have to remove the road tiles one by one and only proceed if the previous tile succeeded so that you don't cut of the exit road for trucks.

That said, in a situation when the trucks got hit by a train on a regular rail (not a sabotage-rail) chances are that if a truck got hit once, there will come more trains that will kill the stuck trucks/buses and then they will not be a problem anymore. :-)
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 »

I'm working on generic cargo support for CluelessPlus. One of the issues that came up was how to make the save/load code work in all cases. CluelessPlus do not store any extra data in the save game file about it's connections, instead it reads the vehicle orders and detect which stations that are connected and from them check which town is closest. However with industry support you either have to be very constrained about where to place your stations or you can't trust that the closest industry/town is what you are serving by the station. It is true that the vehicles' cargo type can give some information, but what if there is an industry that supply/accept passengers at a central location of a town? etc. etc. So the old method of just taking the closest town would not work very good by adding industries to that as well.

A not to hard to implement way to go would be to make use of the NoAI support for adding data to the save game files. Unfortunately, that has a big drawback - you can't recover connections from crashed AIs. What I need to store for each station is if the object is an industry or town, the industry/town id and the cargo id. This can be fitted into the station name, and that is what I've done. Since there can only be one station in the entire game with the same name, I figured out that I need to add a unique string at the end so that multiple CluelessPlus instances are supported, or if the same instance builds more than one station at the same industry.

First I added a number at the end, but only using base 10 is not really good since there the station names are limited in length. So I decided to add the upper and lower case alphabet plus some special chars too and ended up with base 83. 2 digits in base 83 gives 6889 possible values. But having a number 01, 02 etc. looks a bit boring, so I got the brilliant idea to reorder my symbols a bit in my base 83 so that ':' is zero and then there comes various brackets etc. so that in most cases you'll see a smiley as the unique string. :-)
CluelessPlus19-teaser.png
CluelessPlus19-teaser.png (42.02 KiB) Viewed 5187 times
I'll see if I can encode the first parts into a number and transform that into something prettier. I will of course still have to support old CluelessPlus saves by reading closest town and then rename the stations.
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 about similar problem - what when station serves 2 or more industries?
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 »

As of the way the connections are more specifically the nodes are stored, that can not happen. Yes I know in OpenTTD it could happen that you cover two industries, but that is very hard to in the first place detect using the available API functions since you can't detect if a given tile is an industry or even less which industry it belongs to.
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 »

I did some calculations to see that the data stored fits with the maximum length of 30 chars in the sign and come up with the result that my current way of storage + unique string at the end uses 13 chars. I've realized that I do not really need to store the cargo id as that could be read from the vehicles. With base 10, each industry/town id takes up to 5 characters, so there is plenty of room for storing one or two more industry IDs in case the AI had that information. The cargo id takes 3 chars of data plus one space as delimiter so that frees up 4 chars.

So as of storage space, it would not be a problem to fit in 2 more industries. Yes you can't fit in infinitely amounts of industries there, but you could move from base 10 to 83 or even more if you take care and lookup all special chars that OpenTTD allow in station names.

If I'm doing this correctly the number of values you can store with base 83 of 30 chars becomes (rounded down) 83^30 = 3.7 * 10 ^57. A 16 bit int (that's what industry and town ids use) give 2^16 possibilities. Now 83^30 / (2^16) = 5.6 * 10^52 gives the amount of industry Id's you could store if that was the only thing you stored in a station name. This should be sufficient for any practical needs. Taking a few bits from that to store how many industries/towns there are and if they are towns or industries shouldn't change much in the big picture.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 6 guests