Page 1 of 1

AIChat: chat with your ai

Posted: 13 Jun 2008 12:50
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.

Re: AIChat: chat with your ai

Posted: 13 Jun 2008 13:25
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

Re: AIChat: chat with your ai

Posted: 13 Jun 2008 16:40
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 :)

Re: AIChat: chat with your ai

Posted: 13 Jun 2008 17:51
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

Re: AIChat: chat with your ai

Posted: 14 Jun 2008 19:29
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.

Re: AIChat: chat with your ai

Posted: 14 Jun 2008 20:35
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?

Re: AIChat: chat with your ai

Posted: 14 Jun 2008 20:43
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.

Re: AIChat: chat with your ai

Posted: 14 Jun 2008 22:52
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.

Re: AIChat: chat with your ai

Posted: 15 Jun 2008 00:04
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! :)

Re: AIChat: chat with your ai

Posted: 03 Aug 2010 16:05
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 ?

Re: AIChat: chat with your ai

Posted: 03 Aug 2010 16:10
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.

Re: AIChat: chat with your ai

Posted: 03 Aug 2010 17:00
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 :)