AIChat: chat with your ai

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
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

AIChat: chat with your ai

Post by Yexo »

As promised yesterday night in another thread, here it is: AIChat. It adds one more event: AIEvent.AI_ET_RECEIVE_CHAT. Usage example:

Code: Select all

		while (AIEventController.IsEventWaiting()) {
			local e = AIEventController.GetNextEvent();
			switch (e.GetEventType()) {
				case AIEvent.AI_ET_RECEIVE_CHAT:
					local chat_event = AIEventReceiveChat.Convert(e);
					AILog.Info("Received chat message (from " + chat_event.GetSender() + "): " + chat_event.GetMessage());
					AIChat.SendIndividualMessage(chat_event.GetSender(),"Thanks for your message");
					break;
			}
		}
AIChat offers the following functions:
static bool SendBroadcastMessage(const char *message);
static bool SendTeamMessage(AICompany::CompanyID company_id, const char *message);
static bool SendIndividualMessage(uint32 to, const char *message);
Note that you shouldn't make up values for the parameter 'to' from SendInidividualMessage yourself. You should only call it with values you got from AIEventReceiveChat.GetSender(). If you need more documentation, read the patch.
Attachments
ai_chat.diff
(27.88 KiB) Downloaded 147 times
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: AIChat: chat with your ai

Post by Zutty »

AWESOME! The ability to communicate with an AI and vice-versa will open up many possibilities.

I'm not really able to build this myself (TBH I'd rather spend the time it would take me to setup MSVS doing something productive!), so if someone could post a binary for win32 it would be nice.

That or just stick it in the branch!!! :D
PathZilla - A networking AI - Now with tram support.
Finaldeath
Engineer
Engineer
Posts: 72
Joined: 09 Apr 2006 23:49
Location: UK
Contact:

Re: AIChat: chat with your ai

Post by Finaldeath »

Why is the individual one different from the team one? Isn't an individual a team member, or does this take into account multiplayer (you can have more then one person on one company right? - now there's a thought for AI builders, hehe). I guess with individual messages you can't send one yourself from an AI file according to your note there?

Looks cool, sending out taunts will be a neat addition, and inter-AI chat for cooperation maybe (hohoho!). Shame it won't work in singleplayer - maybe the trunk can be updated so it can be?

Also; is there a way to get what kind of chat message type it was? IE: If it was a team-chat, or to a specific company, then it obviously is more private then a global chat thing. No idea how the system works though.

It'd be nice if we could send custom newspaper outputs too, or have them generated automatically ("XXX Transport Doubles Turnover!", "XXX Transport Ranked Top Transport Company In World!", "XXX Transport Highest Rated By Local Authorities!" hehe).

Finally, the description for individual chat starts with "Send a chat message to all players / AIs." which I guess needs correcting.

Thanks for adding this :)
Finaldeath
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: AIChat: chat with your ai

Post by Zutty »

Finaldeath wrote:Why is the individual one different from the team one? Isn't an individual a team member, or does this take into account multiplayer (you can have more then one person on one company right? - now there's a thought for AI builders, hehe). I guess with individual messages you can't send one yourself from an AI file according to your note there?

Looks cool, sending out taunts will be a neat addition, and inter-AI chat for cooperation maybe (hohoho!). Shame it won't work in singleplayer - maybe the trunk can be updated so it can be?

Also; is there a way to get what kind of chat message type it was? IE: If it was a team-chat, or to a specific company, then it obviously is more private then a global chat thing. No idea how the system works though.

It'd be nice if we could send custom newspaper outputs too, or have them generated automatically ("XXX Transport Doubles Turnover!", "XXX Transport Ranked Top Transport Company In World!", "XXX Transport Highest Rated By Local Authorities!" hehe).

Finally, the description for individual chat starts with "Send a chat message to all players / AIs." which I guess needs correcting.

Thanks for adding this :)
Everything is this post is brilliant!! :D
PathZilla - A networking AI - Now with tram support.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AIChat: chat with your ai

Post by Yexo »

Finaldeath wrote:Why is the individual one different from the team one? Isn't an individual a team member, or does this take into account multiplayer (you can have more then one person on one company right? - now there's a thought for AI builders, hehe). I guess with individual messages you can't send one yourself from an AI file according to your note there?
You can't use the chat system in single player anyway, so only in multiplayer. The difference with team chat and individual chat:
team chat = company chat, send a messages to the ai (if controlled by ai) and all human players playing in that company.
Individual chat = send message to either one ai or to one human player.
Looks cool, sending out taunts will be a neat addition, and inter-AI chat for cooperation maybe (hohoho!). Shame it won't work in singleplayer - maybe the trunk can be updated so it can be?
You'll have to ask one of the trunk devs for that, I could do it, but imo it's not worth the effort.
Also; is there a way to get what kind of chat message type it was? IE: If it was a team-chat, or to a specific company, then it obviously is more private then a global chat thing. No idea how the system works though.
This is possible, but also too much work for now. It's a think I'll keep in mind when upgrading the patch.
It'd be nice if we could send custom newspaper outputs too, or have them generated automatically ("XXX Transport Doubles Turnover!", "XXX Transport Ranked Top Transport Company In World!", "XXX Transport Highest Rated By Local Authorities!" hehe).
This doesn't have anything to do with chatting. Furthermore, as human player you can't send out custom newspaper, so why should an ai be able to do so.
Finally, the description for individual chat starts with "Send a chat message to all players / AIs." which I guess needs correcting.
I've fixed this locally, but didn't upload a new diff, because it doesn't change any functionality.
Zutty wrote:
Finaldeath wrote:snip
Everything is this post is brilliant!! :D
Zutty, nofi, but if you reply next time, can you please add something usefull to the thread? If you could add least say why the post was brilliant, it'd have some use.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: AIChat: chat with your ai

Post by Zutty »

Yexo wrote:Zutty, nofi, but if you reply next time, can you please add something usefull to the thread? If you could add least say why the post was brilliant, it'd have some use.
I was just trying to express a bit of enthusiasm. :| Would "I agree on all points" have been more acceptable?
PathZilla - A networking AI - Now with tram support.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AIChat: chat with your ai

Post by Yexo »

Zutty wrote:
Yexo wrote:Zutty, nofi, but if you reply next time, can you please add something usefull to the thread? If you could add least say why the post was brilliant, it'd have some use.
I was just trying to express a bit of enthusiasm. :| Would "I agree on all points" have been more acceptable?
Sorry Zutty, it's just me tonight. I better get some more sleep tonight.
Finaldeath
Engineer
Engineer
Posts: 72
Joined: 09 Apr 2006 23:49
Location: UK
Contact:

Re: AIChat: chat with your ai

Post by Finaldeath »

While slightly not on topic, yeah, Newspapers - players can't do them because, what, is the AI going to react or something? (Adding in some kind of text interpretation is a bit much :) ).

More newspaper variety would be cool - ie; so if an AI could post up it's good and bad times, a player knows about them. Without the chat in singleplayer, it's an obvious other route since the player can turn them off if they are annoying. Personality is key, and the main thing you need to do, which the default AI fails at, is to give the player information.

There's simply no other easy way I can think of to facilitate it :) but that's just me - without chat, it's a shame there basically is no way to tell the player something that the AI wants them to know. Is a wish-list feature, along with chat in singleplayer (although decidedly more easy to implement).

Communication really helps facilitate an AI - and, for the most part, also allow the player to know how intelligent it is, and why it is doing something. To be honest, it'll look entirely random (like the default AI) and thus, they will assume it pretty much sucks no matter how complex you make it, hehehe ;) (we all know better, but they don't :D ).

Good work again, I'll try this out when I have a chance, and see how easy or hard Squirrels string parsing and stuff is.
Finaldeath
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: AIChat: chat with your ai

Post by Zutty »

Yexo wrote:
Zutty wrote:
Yexo wrote:Zutty, nofi, but if you reply next time, can you please add something usefull to the thread? If you could add least say why the post was brilliant, it'd have some use.
I was just trying to express a bit of enthusiasm. :| Would "I agree on all points" have been more acceptable?
Sorry Zutty, it's just me tonight. I better get some more sleep tonight.
No thats alright! :)
PathZilla - A networking AI - Now with tram support.
User avatar
Muxy
Engineer
Engineer
Posts: 80
Joined: 05 Oct 2008 17:06
Location: Goulp, FR
Contact:

Re: AIChat: chat with your ai

Post by Muxy »

This class will be very usefull when it will be integrated to the trunk.

It will open the goalserver system a bit.

This is the reply of all questions : how can i do this action by sending chat message, like !resetme

No need to use external bot.
No need to modify OpenTTD server source code.

Just write some AI Script and enjoy !

Also we can imagine some kind of ServerAI who will be able to perform some global action on the map.

Ok, Yexo, do you have some plan to integrate this into trunk ?
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: AIChat: chat with your ai

Post by Yexo »

No, I don't have any plans to integrate this in trunk. First of all it has nothing to do with a goalserver, an AI controls a single company on the server, not the server itself. I'm not against integrating squirrel scripting support for a lot of actions (which could include many parts of a goalserver), but this is not the answer.
User avatar
Muxy
Engineer
Engineer
Posts: 80
Joined: 05 Oct 2008 17:06
Location: Goulp, FR
Contact:

Re: AIChat: chat with your ai

Post by Muxy »

Yexo wrote:First of all it has nothing to do with a goalserver, an AI controls a single company on the server, not the server itself.
May be to control the AI...
Yexo wrote: I'm not against integrating squirrel scripting support for a lot of actions (which could include many parts of a goalserver), but this is not the answer.
Ok, then lets start with a ServerAI :)
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests