Class Actor

java.lang.Object
  |
  +--Actor
All Implemented Interfaces:
DebugInterface, PlayModeInterface

public class Actor
extends java.lang.Object
implements DebugInterface, PlayModeInterface

The Actor class is used to get an abstraction of the plain text commands so that the can be used via methods. The methods compose the commands and send them via the communicationChannel link.

Version:
1.00
Author:
Daniel Förderer and Moritz Steiner

Field Summary
 CommunicationChannel communicationChannel
          reference to the communicationChannel
private  Player player
          reference to the Player
 
Fields inherited from interface DebugInterface
DEBUG_SWITCH_STRATEGY_IS_SET, DEBUG_SWITCH_VISUALISATION_IS_SET, DEBUG_SWITCH_WORLDMODEL_AUDIOEVENT_IS_SET, DEBUG_SWITCH_WORLDMODEL_BODYEVENT_IS_SET, DEBUG_SWITCH_WORLDMODEL_VISUALEVENT_IS_SET
 
Fields inherited from interface PlayModeInterface
PLAYMODE_BEFORE_KICK_OFF, PLAYMODE_EXTEND, PLAYMODE_HALF_TIME, PLAYMODE_OPPONENTS_CORNER_KICK, PLAYMODE_OPPONENTS_FOUL, PLAYMODE_OPPONENTS_FREE_KICK, PLAYMODE_OPPONENTS_GOAL, PLAYMODE_OPPONENTS_GOAL_KICK, PLAYMODE_OPPONENTS_GOALIE_CATCH, PLAYMODE_OPPONENTS_KICK_IN, PLAYMODE_OPPONENTS_KICK_OFF, PLAYMODE_OPPONENTS_OFFSIDE, PLAYMODE_OUR_CORNER_KICK, PLAYMODE_OUR_FOUL, PLAYMODE_OUR_FREE_KICK, PLAYMODE_OUR_GOAL, PLAYMODE_OUR_GOAL_KICK, PLAYMODE_OUR_GOALIE_CATCH, PLAYMODE_OUR_KICK_IN, PLAYMODE_OUR_KICK_OFF, PLAYMODE_OUR_OFFSIDE, PLAYMODE_PLAY_ON, PLAYMODE_TIME_UP, PLAYMODES
 
Constructor Summary
Actor(CommunicationChannel communicationChannel, Player player)
          Creates a new Actor instance.
 
Method Summary
 void bye()
          removes the player from the field
 void catchBall(double direction)
          catches the ball in the specified direction
 void changeView(double width, double quality)
          Method changeView. changes view Quality width: 2 = narrow 1 = normal 0.5 = wide quality: 1 = high 0.5 = low
 void dash(double power)
          Gives a running impulse
 Event event(AgentInfo agentInfo)
          Receives incoming messages from the server.
 void init(java.lang.String teamName, AgentInfo agentInfo, boolean isGoalie)
          Registers itself to to the server specifying protocol version 7.0.
NOTE: If you don't use version 7.0, it may occur that you will not receive a sense_body event and that the names of the objects will be written in a different way like "flag" instead of "f".
 void kick(double power, double direction)
          Kicks into a given direction with given power
 void move(double x, double y)
          Places the player to a given position on the field.
 void say(java.lang.String message)
          Says the overgiven message
 void turn(double moment)
          Turns the body of the client on the field.
 void turnNeck(double moment)
          Turns the head of the client on the field.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

communicationChannel

public CommunicationChannel communicationChannel
reference to the communicationChannel

player

private Player player
reference to the Player
Constructor Detail

Actor

public Actor(CommunicationChannel communicationChannel,
             Player player)
Creates a new Actor instance.
Parameters:
communicationChannel - a CommunicationChannel value defining the communicationChannel link to the server via which the commands can be sent
See Also:
CommunicationChannel
Method Detail

init

public void init(java.lang.String teamName,
                 AgentInfo agentInfo,
                 boolean isGoalie)
Registers itself to to the server specifying protocol version 7.0.
NOTE: If you don't use version 7.0, it may occur that you will not receive a sense_body event and that the names of the objects will be written in a different way like "flag" instead of "f". This may cause problems if you assume a special format for parsing. Saves the register confirmation from the server in agentInfo.own.side and agentInfo.own.number
Parameters:
teamName - The name of the team the player should join or create if it does not already exist and there less than two teams already present on the field

event

public Event event(AgentInfo agentInfo)
Receives incoming messages from the server. They are automatically classified and passed on to the correct parsing/representation classes.
NOTE: The receive() method is blocking because is uses the blocking receive() method of the CommunicationChannel class. Therefor the thread will be interrupted until a new message arrives.
Returns:
an Event object containing the parsed information of the read message
See Also:
CommunicationChannel

dash

public void dash(double power)
Gives a running impulse
Parameters:
power - a double value containing the power of the impulse 21.06. added recovery decreasing, sb

changeView

public void changeView(double width,
                       double quality)
Method changeView. changes view Quality width: 2 = narrow 1 = normal 0.5 = wide quality: 1 = high 0.5 = low
Parameters:
width -  
quality -  

kick

public void kick(double power,
                 double direction)
Kicks into a given direction with given power
Parameters:
power - a double value specifying the power of the kick
direction - a double value giving the direction of the kick

move

public void move(double x,
                 double y)
Places the player to a given position on the field. Only possible:
Parameters:
x - gives the position in x direction. The position can vary from -52.5 to 52.5. The unit is meter. Negative values stand for the own half of the field, positive values stand for the opponent's half. The value itself gives the distance from the mid-line.
y - gives the position in y direction. The position can vary from -34.0 to 34.0. The unit is meter. Negative values stand for the left side of the field when looked in direction of the opponent's goal.Positive value stand for the right side. The value itself gives the distance from the line going through the center of both goal and the middle point of the field.

turn

public void turn(double moment)
Turns the body of the client on the field.
Parameters:
moment - is the angle in degree you want to turn. The orientation is clockwise so that positive angles mean right turns. The absolute value of the angle must be smaller than 180 degrees. Otherwise the the server will take the turn as a 180 degree turn. So it should be assured that the angle are normalized before usage

turnNeck

public void turnNeck(double moment)
Turns the head of the client on the field.
Parameters:
moment - is the angle in degree you want to turn. The orientation is clockwise so that positive angles mean right turns. The absolute value of the angle must be smaller than 180 degrees. Otherwise the the server will take the turn as a 180 degree turn. So it should be assured that the angle are normalized before usage

say

public void say(java.lang.String message)
Says the overgiven message

bye

public void bye()
removes the player from the field

catchBall

public void catchBall(double direction)
catches the ball in the specified direction