Issues with NoCarGoal-9 and CluelessPlus-37

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
matsydoodles
Engineer
Engineer
Posts: 10
Joined: 22 Jun 2013 13:08

Issues with NoCarGoal-9 and CluelessPlus-37

Post by matsydoodles »

I've been working on a back end/front end for the latest version of NoCarGoal (9 I think) to store the game data in a database.

I figured to generate data it would be easier to let loose some AI's rather than me playing.

Anyway, I could only see that ClulessPlus (again the latest 37) AI works with NoCarGoal (someone feel free to point me to another that does!) but I've noticed it doesn't really work how I expected as it just seemed to always focus on Passengers, and generally ignore whatever Cargos were the goal, I even thought that maybe it was because something like Steel was beyond its grasp.

So I just assumed that it wasn't setup fully to play NoCarGo but I looked into the Game Script, and it seemed like it should of been as I can see we are filtering towns/industries (g_no_car_goal.GetNUncompletedGoals()) but when I started debugging I realised that the AI wasn't communicating with the game script.

First off I noticed I get the following messages at the start, I am assuming it is complaining that the NoCarGo doesn't have the correct API in place?

Code: Select all

dbg: [script] [18] [I] 1.3 API compatibility in effect.
dbg: [script] [18] [I] Script Communcation Protocol: version: 45 - API: 1.2 - CompanyID: 16 - GS mod
e - AIAIProtocol: disable Script name: CAGO Script version: 9
dbg: [script] [18] [I] You can get the source code here : http://dev.openttdcoop.org/projects/scriptlib-scp

dbg: [script] [1] [I] SCP: Adding a new command set : NoCarGoal
dbg: [script] [1] [I] SCP: Adding new command : CurrentGoal to set NoCarGoal
dbg: [script] [1] [I] SCP: Adding new command : Setting to set NoCarGoal
dbg: [script] [1] [I] SCP: Delaying message 231, cannot speak yet with 16-GS server
dbg: [script] [1] [I] SCP: Delaying message 31, cannot speak yet with 16-GS server
dbg: [script] [1] [I] SCP: Status update: signPoolID=1024 SignID=0 Command=0 Sender=1 Receiver=16 State=5 Index=0
dbg: [script] [2] [I] Script Communcation Protocol: version: 45 - API: 1.2 - CompanyID: 2 - AI mode- AIAIProtocol: disable Script name: CLUP Script version: 37
dbg: [script] [2] [I] You can get the source code here : http://dev.openttdcoop.org/projects/scriptlib-scp
I then started to do some debugging around in the CluelessPlus code to see what was happening (quick question is there a decent squirrel ide?).

I could see that the g_no_car_goal object wasn't pulling anything back.

Code: Select all

g_no_car_goal = SCPClient_NoCarGoal(this.scp);
local test = g_no_car_goal.IsNoCarGoalGame();
AILog.Info("test = " + test); 
Which returns false, which I would assume should be true..

Any ideas guys?
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: Issues with NoCarGoal-9 and CluelessPlus-37

Post by krinn »

Well, i could partially answer you.

the [18] speaking AI is in fact GS speaking for openttd
don't ask me why as it is far in my memory, but for scp, GS company is handle as 16 (let's say because 16 is next to 15), anyway except difference in numbering, it's not important there, just to help you get the picture.

the [1] is company 1 (note that openttd range it from 0-15, and company 0 should be human "always", i'm unsure if openttd could be start without any human company) ; anyway it's normal that first AI gets company #1

so if you follow the logic:
- GS [18] init scp
- AI as company #1 register two scp commands, and send its welcome message (the SignID=0), Sender=1 (company #1) to 16 (the GS so)

now at this point, what is going on can only be view if appropriate settings of scp are set on the GS side to show error, warning, and only view in the GS log, as you are logging GS and you don't see more messages from [18], scp is set to be silent (well, that's kind of normal, debug... are more aim to be use by GS and scp devs than user, and a release GS should have them disable), but at this point the GS-scp part answer to company #1 thru a sign build for company #1 (you can only see it if you enable "competitor signs and names displayed")

- and next to that, and that's the problem there, you can see scp part of CLUP init and stating its company is #2, you can also note it now speak as [2]

So, company start as #1, then gets push to company#2 : why? no idea (that's why the "partially answer"). As the company already sent its welcome message, it will never send another one waiting GS to answer it, and as GS should had answer or will answer to company #1, company#2 will never get any answer ; and no answer, just mean no GS support.
Alas, it mean nothing wrong with test = false, because it's the right answer.

It might comes from scp that cannot detect companyID change anymore, scp should catch company change thru event, you might think it's easy to catch a company change event, but for a lib it's tricky and scp do use trick to catch them, it might be your openttd doesn't enjoy that tricky part anymore (but i don't see any reason from 1.6.0 changelog), or something else. So no idea why your company change its id, and no idea why scp didn't catch it ; but these are the two questions to answer.

As you see, a long message to help you, that doesn't help you :D
xarick
Transport Coordinator
Transport Coordinator
Posts: 335
Joined: 26 Feb 2015 00:52

Re: Issues with NoCarGoal-9 and CluelessPlus-37

Post by xarick »

Company IDs are 1-15, in console they are [0]-[14]. If Company 1 is a Human company, then the first AI company that starts will be using Company ID #2, or [1] in the console. GS script plays as OWNER_DEITY, or [18] in console.
Formerly known as Samu
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Issues with NoCarGoal-9 and CluelessPlus-37

Post by Zuu »

matsydoodles wrote:

Code: Select all

g_no_car_goal = SCPClient_NoCarGoal(this.scp);
local test = g_no_car_goal.IsNoCarGoalGame();
AILog.Info("test = " + test); 
Which returns false, which I would assume should be true..

Any ideas guys?
This will not work straight away after booting up SCPClient_NoCarGoal. What happens when you create THe NoCarGoal client is that it send a command to the Game Script. This happens asynchronous as it involves placing signs on a specific tile at the map where all SCP communication occurs. Then the GS monitors this tile at some rate and need to read the message, make a response and place a sign for that. Finally CluelessPlus need to make SCP look at that tile to see if there is incoming messages which it does every now and then but not too often.

If you give it some time, Clueless plus will read the response, and at that time g_no_car_goal.IsNoCarGoalGame() will return true for example.

matsydoodles wrote:Anyway, I could only see that ClulessPlus (again the latest 37) AI works with NoCarGoal (someone feel free to point me to another that does!) but I've noticed it doesn't really work how I expected as it just seemed to always focus on Passengers, and generally ignore whatever Cargos were the goal, I even thought that maybe it was because something like Steel was beyond its grasp.

Do you play with any NewGRF industry set? Have you provided a road vehicle set like OpenGFX+ which support that industry set?

To give an example, I made some testing myself with FIRS without any road vehicle set. In my case NoCarGoal selected metal, clay and chemicals as cargoes. Both Clay and Chemicals have source industries with production without any delivery, but there is no road vehicle for it. So CluelessPlus sort away those two cargoes. Metal on the other hand is the cargo id STEL, which is in the default game content so it has a vehicle type available. However, there is no industry producing this cargo without any input. So transporting any goal cargo will fail and after two attempts to do so, it will get to desperate level 2, and then consider any cargo types regardless of goals.

Didn't state it explicitly above, but CluelessPlus doesn't draw an industry hierarchy graph in order to figure out how to produce a goal cargo without supplies. So it will focus first on those who are available easily and then randomly build until it has a supply and then connect that up.

I did also a test without any NewGRF and in that case it does focus on the goal cargoes. But the first 1-2 connections will not because those are constructed before it has read the response from the Game Script. But I don't think it is a bad thing that it will make one or two connections in the beginning that are more likely to make money by ignoring goal cargo restrictions.
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: Google Adsense [Bot] and 4 guests