Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Aug 20, 2018 12:45 pm

All times are UTC




Post new topic  Reply to topic  [ 20 posts ] 
Author Message
PostPosted: Thu May 17, 2012 2:06 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Zuu and I made the Script Communication Protocol (SCP), and before you asked what is SCP ?
SCP is 3 things:
  • a protocol to allow scripts to communicate with each other
  • an implementation library for Goal Script
  • an implementation library for AI script
So an AI, using the SCP library for AIs, can communicate with a GS that use the SCP library for GS. AI->AI communication is planed, but has not been finished and will be restricted by AI and GS settings.
With SCP, an AI can ask a GS for its settings, goals... anything the GS wish to provide to the AI, allowing the AI to really handle the GS in use.
What the AI or GS can ask/answer is all up to the AI/GS authors, we provide the interface to speak, but you must create your own API (through commands and command sets; see the wiki page) so others devs could use it.

You can grab :

Current (not yet finished) documentation can be found here : http://wiki.openttd.org/Script_communication_protocol

As these libs are used by devs and not by users, I'm sure even without doc, many would love to try it and start implementing it in their own scripts. Since this is work in progress, we don't yet publish the libs in bananas yet, but you can get them here. We still need to document the source code and build the API documentation and the implementation documentation.

The libraries are licensed under GNU/Affero, any AI/GS incompatible with it (non GNU/GPL), can still create their own implementation of the protocol, see the wiki for the link to the protocol.

And you can get here our test AI and GS using SCP as sample of how it works, except for the demonstration, they are of no use. Also the latest revision of the GS/AI Libs...

http://dev.openttdcoop.org/projects/scr ... ow/package
We're at a point where comments and feedback would help us, hence that post :)

Edit: i have remove the files attachments, as versions evolve fast, it's better to grab them from http://dev.openttdcoop.org/projects/scr ... ow/package


Last edited by krinn on Mon May 21, 2012 9:52 am, edited 1 time in total.

Top
   
PostPosted: Thu May 17, 2012 4:58 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4537
Location: /home/sweden
The documentation is getting better. I've completed the first version of an API documentation of the library. I plan to upload a demo of TransportGoals with NoGo support and I also got a CluelessPlus version that can talk with TransportGoals (but not yet react on the goal).

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Thu May 17, 2012 7:23 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13177
Location: The Netherlands
Krinn and Zuu, the two of you deserve a statue in a town of your choice :bow: .

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
PostPosted: Thu May 17, 2012 7:37 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9036
Location: Sol d
Hyronymus wrote:
Krinn and Zuu, the two of you deserve a statue in a town of your choice :bow: .

Unfortunately I fail to fit 'Krinn' onto the statue...


Attachments:
statue_zuu.png
statue_zuu.png [ 1.06 KiB | Viewed 6806 times ]

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Top
   
PostPosted: Thu May 17, 2012 8:03 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13177
Location: The Netherlands
planetmaker wrote:
Hyronymus wrote:
Krinn and Zuu, the two of you deserve a statue in a town of your choice :bow: .

Unfortunately I fail to fit 'Krinn' onto the statue...

Think outside the blue box :).

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
PostPosted: Thu May 17, 2012 8:41 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
thank you guys, if you know a place without birds :)


Top
   
PostPosted: Thu May 17, 2012 9:30 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9036
Location: Sol d
Here now the real thing [TM] with both names... take a close look at the statues ;-)

I wish to apologize for my quick and dirty graphics.


Attachments:
File comment: source bundle
statue.zip [19.3 KiB]
Downloaded 157 times
File comment: NewGRF
statue.tar [22.5 KiB]
Downloaded 116 times

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Top
   
PostPosted: Thu May 17, 2012 10:05 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4537
Location: /home/sweden
I found two issues with the current version. If you transmit a string with underscores, the underscore characters do not get transmitted correctly. The other issue is that if you try to transmit -1, the SCP library crash.

I've informed krinn about the issue, but though that anyone trying to use the library should be aware of the issue too to not waste your time on this bug.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sat Jun 09, 2012 7:26 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Mon May 31, 2004 9:21 am
Posts: 1303
1 word: wow.

_________________
The only thing necessary for the triumph of evil is for good men to do nothing.


Top
   
PostPosted: Wed Oct 17, 2012 11:42 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
I have upload the libraries for AI and GS on bananas what i think is a stable release. If you want a test AI and GS you can grab them from the url gave on first post as i won't upload them to bananas, because they are just tests and not real usable AI/GS.

Don't forget to add them as dependencies for your GS/AI if you use them.
Look out the wiki page for help or ask questions, and add your GS commands to the wiki so AI authors could implement them easy.


Top
   
PostPosted: Tue Oct 23, 2012 8:16 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4537
Location: /home/sweden
Unfortunately, there still seem to be some instability in this communication library.

Sometimes, but not always this happens:

On the GS side this was sent: (an array with the numbers presented in the red rectangle)
Attachment:
gs-sent.png
gs-sent.png [ 24 KiB | Viewed 6098 times ]


Code:
local result = [for_company, date,  0, 0, 0,  0, 0, 0,  0, 0, 0];
// code that adds goal data to result array. (each pair of three values is a goal)
SCPLib.Answer(message, result);



On the AI side this is received:
Attachment:
ai-received.png
ai-received.png [ 23.37 KiB | Viewed 6098 times ]


Edit: The code used to print that message looks like this: (yes quick and dirty)
Code:
      local s = "";
      if(message.Data != null)
      {
         for(local i = 0; i < message.Data.len(); i++)
         {
            if (i == 2) s+= " | ";
            else if (i == 2 + 3) s+= " | ";
            else if (i == 2 + 6) s+= " | ";
            else if (s != "") s+=", ";
            s += "" + message.GetData(i);
         }
      }
      AILog.Info("Server gave transport goal: " + s);
      AIController.Break("");



Also I get the "Hole in message" warning/error from time to time in a very non-predictable way. If I load a save game multiple times I get different results. My guess is that the amount of time that the game is paused (= GS runs but not AI) somehow have an impact on if this problem happen or not. But its no extreme differences. Its more about open in-game windows and then unpause game or unpause game first and then open some in-game windows. Or be quick or slow about hitting unpause etc. and I have not yet to see a pattern in when it happens and when not. (maybe the only pattern so far is that I have only seen it when loading a game, but most of my testing is based upon re-loading a save-game and make adjustments in my source code before reloading)

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Wed Oct 24, 2012 3:01 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4659
Location: home
In regular network programming, one of the pitfalls is the assumption that messages arrive in one piece.
I don't know how you communicate, but it may be useful to check what promises the used network calls give you.


Top
   
PostPosted: Tue Oct 30, 2012 6:54 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
That's what i've done Alberth, and funny, it was that : messages doesn't arrive in one piece :)

for the communcation: the basics are encode in a define charset (limited by openttd) a message, that is then cut into 31 chars pieces (sign length restriction) and build the signs for a given company. We have a protocol.txt that explain it, but honeslty outdate, something that should be update, but time...


Top
   
PostPosted: Tue Oct 30, 2012 7:33 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4659
Location: home
Not updating docs may seem to give you time, but that's not true. One day you'll have to return to some issue, and then you spend hours to retrieve the information you'd now write in a fraction of that time.

Another possibility is that someone else might want to know how it works, and then you have to spend time to explain it all, while otherwise you could just point at the doc.


Top
   
PostPosted: Tue Oct 30, 2012 8:54 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
The doc has been update (maybe because Zuu isn't as lazzy as me).
Only protocol isn't, something i will do, but as it change a lot while we met problems, it wasn't that stable to document it as it should.
But i will, as it seems stable now (version change a lot, but protocol seems fine)


Top
   
PostPosted: Mon Jul 22, 2013 8:28 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Kogut wrote:
Why AIAI is used as name for something? I hope that there is a possibility to use name that is not the same as my AI, this collision may end quite confusing.

Because it was made like that for a futher extension (that may never appears because of lack of interrest from anyone).
SCP is design to do AI<>GS, but also for AI<>AI.
So to identify an AI from another AI that would try speak with it, the shortname (that should be uniq) is the best name to use. And like that an AI with SCP not handling AI<>AI will still be able to "hear" another one handling it (but not speak with it).
That name is use internally by the SCP library.
So it was a need to avoid incompatibility later.


Top
   
PostPosted: Mon Jul 22, 2013 8:33 am 
Offline
Tycoon
Tycoon

Joined: Wed Aug 26, 2009 6:33 am
Posts: 2493
Location: Poland
Why aiai is used as name for something? I hope that there is a possibility to use name that is not the same as my AI, this collision may end quite confusing.

Why it is necessary to provide version number of AI? As GetVersion from info.nut refuses to work in other files it requires manual update after every version change of AI. And is it really necessary to provide this data? It seems to be unused anywhere, except in log statements.

minor problem in Script_Communication_for_AI-45\main.nut:

Code:
   SCPLog.Info("Script Communcation Protocol: version: "+_SCPLib_Share.LibVersion+" - API: "+_SCPLib_Share.LibAPIVersion+"

"Communcation" should be "Communication"

_________________
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD


Top
   
PostPosted: Mon Jul 22, 2013 8:35 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4537
Location: /home/sweden
I can now think that possible the company Id would be better if there are multiple AIs of the same ShortName in the game. However, care has to be taken if it changes the protocol so that old/new clients either work or fail hard with an error.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Mon Jul 22, 2013 8:38 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Kogut wrote:
"Communcation" should be "Communication"

Thanks. It will get fix if any version goes out, but i won't pubish one just for this ;)

Other questions are already answer on the other thread.


Top
   
PostPosted: Mon Jul 22, 2013 8:47 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4537
Location: /home/sweden
krinn wrote:
Other questions are already answer on the other thread.


For your information: those answers has now been moved here by a moderator.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 20 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.