[Java] How to know player id

[Java] How to know player id

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
bioinfornatics
Posts: 13
Joined: 11 Oct 2014, 13:13

[Java] How to know player id

Post by bioinfornatics » 23 Oct 2014, 00:23

Hi stupid question,

How to know player id ?

My AI inherit from OOAI so I have his skirmishAIId.
I can to get is allyteam with Game object callback.getGame().getMyTeam()

But I do not see how to get the playerId!

thanks
0 x

playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: [Java] How to know player id

Post by playerO1 » 24 Oct 2014, 13:54

For check all team I using:

Code: Select all

for(int teamI clb.getTeams().getSize();teamI++) {
  //some work here
  if (game.getTeamColor(teamI).equals(msgColor))...
}
See also: clb.getGame().getPlayerTeam(player); clb.getGame().getTeamAllyTeam(owner.clb.getGame().getPlayerTeam(player));
Java AI documentation link: http://spring.abma.de/doc-Interface-JavaOO/
0 x

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: [Java] How to know player id

Post by jK » 24 Oct 2014, 18:31

AI is no player, it's a design flaw.
0 x

User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Re: [Java] How to know player id

Post by PauloMorfeo » 24 Oct 2014, 22:15

Is your class declaration like this?:
https://github.com/spring/spring/blob/d ... I.java#L38

Code: Select all

public class NullOOJavaAI extends OOAI
That is, do you inherit ("extend") from OOAI?

Are you trying to find the ID of *your* AI? If so, that is sent in the init():
https://github.com/spring/spring/blob/d ... .java#L105

Code: Select all

	@Override
	public int init(int skirmishAIId, OOAICallback callback)
I'm not in my "development" computer right now to confirm but from memory you should also have:

Code: Select all

callback.getTeamId();
0 x

bioinfornatics
Posts: 13
Joined: 11 Oct 2014, 13:13

Re: [Java] How to know player id

Post by bioinfornatics » 26 Oct 2014, 22:41

ok thanks,
I will use callback.getTeamId(); as a player ID
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: [Java] How to know player id

Post by hoijui » 28 Oct 2014, 09:44

player ID and team ID are not the same. only humans have player IDs. AIs are not players (that is totally wrong, but it is how it works in spring at the moment). each AI is "owned" or "controlled" by a player, so that players ID is closest to its player ID. though, if i remember right, you need just the team ID in most places.
0 x

Post Reply

Return to “AI”

cron