[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 »

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
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: [Java] How to know player id

Post by playerO1 »

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/
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: [Java] How to know player id

Post by jK »

AI is no player, it's a design flaw.
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Re: [Java] How to know player id

Post by PauloMorfeo »

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();
bioinfornatics
Posts: 13
Joined: 11 Oct 2014, 13:13

Re: [Java] How to know player id

Post by bioinfornatics »

ok thanks,
I will use callback.getTeamId(); as a player ID
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: [Java] How to know player id

Post by hoijui »

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.
Post Reply

Return to “AI”