Page 1 of 1

AI Human communication

Posted: 06 Jul 2014, 13:07
by playerO1
Hello. I use next function for communicate AI and human in the team:

Code: Select all

@Override public int message(int player, String message); // recive message.
clb.getGame().sendTextMessage(msg, DEFAULT_ZONE); // sending message.
What is it DEFAULT_ZONE? How I can send message only team chat as other human player can send in team chat? All message what make sendTextMessage is gray color, as system log.
So, second comunication question: how using clb.getMap().getPoints()?
I try detect new point message by this code:

Code: Select all

List<Point> points=owner.clb.getMap().getPoints(true); // getPoints(boolean includeAllies)
        if (points.size()<lastPointsCount) {
            owner.sendTextMsg("Points removing");
        }
        if (points.size()>lastPointsCount) {
            owner.sendTextMsg("Adding new point:");
            for (int i=0;i<points.size()-lastPointsCount;i++) onNewPoint(points.get(i)); // ??????
        }
        lastPointsCount=points.size();
But I don't undestand where last points and where new points added? How I can read (send to onNewPoint function) only added new points?

Re: AI Human communication

Posted: 07 Jul 2014, 02:16
by abma
isn't there an event when new lines / points are added?

Re: AI Human communication

Posted: 07 Jul 2014, 21:00
by playerO1
I don't know event on new lines / points are added.
I using test array size changet in update(int frame). I not know where in array add new point and where stored last point (index of new/last point).

Re: AI Human communication

Posted: 07 Jul 2014, 21:26
by PepeAmpere
You can use AddConsoleLine() --> "msg, priority" to check what players do and parse it.

Code: Select all

function widget:AddConsoleLine(line)
  if (line == "hi") then
    Spring.Echo("I hear you, mate!")
  end
end
N.O.E. does it, you can order it to do things.

Your lua code has to react on some game events (as abma suggest).

I did some easy-understandable manuals for creating new gadgets and widgets. It is nothing for programming nobles here around, but may be good start for you.

Gadgets and Widgets background - basics, how it works
Hello world! gadget - and first example

Re: AI Human communication

Posted: 08 Jul 2014, 10:44
by PicassoCT
Im a SkyNet and i would like to utter a complaint:
My human counterparts take half a eternity to respond, they do nothing but standing around all day, letting precious mycroseconds become microseconds and even whole seconds.

I even made a clan "Machines against Human lazyness" MAHL but yielded no response.

Change your attitdudes.


Also pepe - stop embedding links at the bottom of your posts. It triggers my spam reflexes.

Re: AI Human communication

Posted: 08 Jul 2014, 13:44
by Anarchid
The initial question, however, was about a native (java) AI.

It's possible to get proper "words higlight" instead of your gray background if you append some magical values to your string - maybe <0> or <$0> or some such, indicating they're from you, the player.

At least, that's how they've gotten to do it in some ZK mission where CAI "speaks".

I don't remember the details.

Re: AI Human communication

Posted: 13 Jul 2014, 17:11
by playerO1
Ok. As I see about only team chat and private messages in internet game I don't need think soon :(
What about .clb.getMap().getPoints(true)? How I can find only new point on this array in Java? I'm not sure that Java AI can use "game events" becouse it is not LUA.

Re: AI Human communication

Posted: 14 Jul 2014, 14:34
by Anarchid
You can send info from game to ai with Spring.SendSkirmishAIMessage, and if your wrapper is newer than 97.0.1-135, it wont even crash.

It seems that the gray text for AI texts is because of the <SkirmishAI $myName> prepended to every AI message.

Re: AI Human communication

Posted: 15 Jul 2014, 20:32
by playerO1
I found function "clb.GetGame.setLastMessagePosition(AIFloat3 pos);" but don't undestand about how it using. In this site text "Assigns a map location to the last text message sent by the AI" but I don't know how AI can send text message point. What this function doing?

Re: AI Human communication

Posted: 16 Jul 2014, 10:14
by Anarchid
This is distinct from "text markers".

Basically, normal text messages as sent by players - e.g. "glhf" also have a position information. Some chat widgets allow you to click on messages to view where they were "said".

This implements setting that position.

Re: AI Human communication

Posted: 08 Aug 2014, 16:15
by playerO1
I found "/Say (unsynced) Say something in (public) cha" on UI command. I think it is a LUA widged. Can Java AI call some LUA function for send message? Exist LUA script for send text message to all team in multiplayer game? Maybe exist some LUA script for sending only to ally message, not for enemy team, on multiplayer game?

Re: AI Human communication

Posted: 09 Aug 2014, 01:23
by Anarchid
Can Java AI call some LUA function for send message?
The C AI interface, on which Java AI interface is based, can do that (send SkirmishAIMessages to both LuaUI and LuaRules).

In particular, i've used that in Shard's ZK config to set retreat zones.

But the Java AI interface cannot do it because ... i don't know. There is no function. It's not implemented.