soccerclient.brain
Class Player

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--soccerclient.brain.Player
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FieldPlayer, Goalie

public class Player
extends java.lang.Thread

Player This class implements basic methods and attributes of a Player

Author:
Jan Kästle

Field Summary
(package private)  Action action
           
(package private)  Communication com
           
(package private)  Field field
           
(package private)  Log log
           
(package private)  Manager manager
           
(package private)  int nr
           
(package private)  java.io.PrintWriter out
           
(package private)  PlayerInfo pi
           
(package private)  PlayMode playmode
           
(package private)  java.lang.String serverName
           
(package private)  int serverPort
           
(package private)  Coordinate standardPos
           
(package private)  Coordinate startPos
           
(package private)  StateDef state
           
(package private)  java.lang.String teamName
           
(package private)  ViewMode viewmode
           
 
Fields inherited from class java.lang.Thread
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals
 
Constructor Summary
Player(java.lang.String serverName, int serverPort, java.lang.String teamName, boolean goalie)
          creates a new Player instance
 
Method Summary
(package private)  void checkIn()
          pseudo "constructor", executed after Communication has connected to server
(package private)  void directGoalKick()
          kicks the ball with an direct kick towards the goal coordinate.
(package private)  void directKick(Coordinate coor, double power)
          kicks the ball without regard of the ball´s position to the player in the given direction
(package private)  void exactGoalKick()
          kicks the ball with an exact kick towards the goal coordinate.
(package private)  void exactKick(Coordinate aPos, double power)
          kicks the ball to a Coordinate, after slightly kicking the ball to a suitable position
(package private)  Coordinate getBall()
           
(package private)  double getBallDir()
           
(package private)  double getBallDist()
          distance to the ball from PlayerInfo
(package private)  double getDirDist(Coordinate objCoordinate)
          difference of directions between an object and body direction
(package private)  double getDist(Coordinate c1, Coordinate c2)
          distance between two objects
(package private)  OtherPlayer getFarestFriend()
          selects the farest teammember from the list of near teammembers, whose uniform number is known
(package private)  Coordinate getFutureBall()
           
(package private)  OtherPlayer getNearestEnemy()
          selects the nearest enemy player from the list of near enemies, whose uniform number is known
(package private)  OtherPlayer getNearestFriend()
          selects the nearest friendly player from the list of near teammembers, whose uniform number is known
(package private)  double getNormedDirection(double direction)
          norm direction
(package private)  void goToBall(boolean stateCheck)
          lets the player run to the resting ball on the shortest way
(package private)  void goToFastBall(boolean stateCheck)
          lets the player run to the futur ball position on the shortest way during Play Mode play_on
(package private)  void goToFastBall(boolean stateCheck, double entfernung)
           
(package private)  void goToPosition(Coordinate aPos, double speed)
          player runs with given speed to given Coordinate
(package private)  void goToPosition(Coordinate aPos, double speed, double dist)
          player runs with given speed to given Coordinate
(package private)  void goToPosition(Coordinate aPos, double speed, double dist, boolean stateCheck)
          player runs with given speed to given Coordinate
(package private)  void initPos()
          moves the player to his initial Position by a move command
(package private)  boolean isBallTimeCurrent()
          checks if information about ball is too old (less than tooOld cycles)
(package private)  void log()
          lets the player say a stored log message
(package private)  void lookForBall()
          lets the player look for the ball
(package private)  void pass(OtherPlayer aOtherPlayer, int power)
          lets the player pass the ball to the specified player
(package private)  void resetPos(double speed)
          let the player return to his start position
(package private)  void resetPos(double speed, double dist)
           
(package private)  void resetPos(double speed, double dist, boolean stateCheck)
           
(package private)  void resetViewMode()
          reset view mode to width: normal and quality: high
(package private)  void stopBall()
          stops the ball, considering the ball's direction and the ball's speed
(package private)  void turnBodyToObject(Coordinate objCoordinate)
          lets the Player turn his body into the direction of the given Coordinate
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pi

PlayerInfo pi

com

Communication com

action

Action action

manager

Manager manager

playmode

PlayMode playmode

viewmode

ViewMode viewmode

state

StateDef state

field

Field field

serverName

java.lang.String serverName

serverPort

int serverPort

teamName

java.lang.String teamName

startPos

Coordinate startPos

standardPos

Coordinate standardPos

out

java.io.PrintWriter out

nr

int nr

log

Log log
Constructor Detail

Player

public Player(java.lang.String serverName,
              int serverPort,
              java.lang.String teamName,
              boolean goalie)
creates a new Player instance
Parameters:
serverName - a String object specifying the server name
serverPort - a int specifying the port of the server
teamName - a String object specifying the name of the team
goalie - a boolean specifiying if player is goalie
Method Detail

checkIn

void checkIn()
pseudo "constructor", executed after Communication has connected to server

lookForBall

void lookForBall()
lets the player look for the ball

goToPosition

void goToPosition(Coordinate aPos,
                  double speed,
                  double dist)
player runs with given speed to given Coordinate
Parameters:
aPos - a Coordinate specifying the destination
speed - a double specifying the speed of the player
dist - a double specifying how exactly the player should approach position

goToPosition

void goToPosition(Coordinate aPos,
                  double speed,
                  double dist,
                  boolean stateCheck)
            throws StateException
player runs with given speed to given Coordinate
Parameters:
aPos - a Coordinate specifying the destination
speed - a double specifying the speed of the player
dist - a double specifying how exactly the player should approach position
Throws:
StateException - if state changes
PlayModeException - if playmode changes

goToPosition

void goToPosition(Coordinate aPos,
                  double speed)
player runs with given speed to given Coordinate
Parameters:
aPos - a Coordinate specifying the destination
speed - a double specifying the speed of the player

resetPos

void resetPos(double speed)
let the player return to his start position
Parameters:
speed - a int specifying the speed of the player

resetPos

void resetPos(double speed,
              double dist)

resetPos

void resetPos(double speed,
              double dist,
              boolean stateCheck)
        throws StateException

initPos

void initPos()
moves the player to his initial Position by a move command

goToFastBall

void goToFastBall(boolean stateCheck)
            throws PlayModeException,
                   StateException
lets the player run to the futur ball position on the shortest way during Play Mode play_on
Throws:
StateException - if state changes
PlayModeException - if playmode changes

goToFastBall

void goToFastBall(boolean stateCheck,
                  double entfernung)
            throws PlayModeException,
                   StateException

goToBall

void goToBall(boolean stateCheck)
        throws PlayModeException,
               StateException
lets the player run to the resting ball on the shortest way
Throws:
StateException - if state changes
PlayModeException - if playmode changes

pass

void pass(OtherPlayer aOtherPlayer,
          int power)
lets the player pass the ball to the specified player
Parameters:
aOtherPlayer - a OtherPlayer object

log

void log()
lets the player say a stored log message

directKick

void directKick(Coordinate coor,
                double power)
kicks the ball without regard of the ball´s position to the player in the given direction
Parameters:
coor - a Coordiante specifying the destination
power - a double specifying the power to kick

exactKick

void exactKick(Coordinate aPos,
               double power)
kicks the ball to a Coordinate, after slightly kicking the ball to a suitable position
Parameters:
aPos - a Coordinate object specifying the destination
power - a double specifying the power to kick

directGoalKick

void directGoalKick()
kicks the ball with an direct kick towards the goal coordinate.

exactGoalKick

void exactGoalKick()
kicks the ball with an exact kick towards the goal coordinate.

stopBall

void stopBall()
stops the ball, considering the ball's direction and the ball's speed

getNearestEnemy

OtherPlayer getNearestEnemy()
selects the nearest enemy player from the list of near enemies, whose uniform number is known
Returns:
a OtherPlayer object

getNearestFriend

OtherPlayer getNearestFriend()
selects the nearest friendly player from the list of near teammembers, whose uniform number is known
Returns:
a OtherPlayer object

getFarestFriend

OtherPlayer getFarestFriend()
selects the farest teammember from the list of near teammembers, whose uniform number is known
Returns:
a OtherPlayer object

isBallTimeCurrent

boolean isBallTimeCurrent()
checks if information about ball is too old (less than tooOld cycles)
Returns:
a boolean specifying if information about the ball is up to date

turnBodyToObject

void turnBodyToObject(Coordinate objCoordinate)
lets the Player turn his body into the direction of the given Coordinate
Parameters:
objCoordinate - a Coordinate

getFutureBall

Coordinate getFutureBall()
Returns:
a Coordinate specifying the future ball position, where the player's way to the ball is the shortest

getBall

Coordinate getBall()
Returns:
a Coordinate specifying the ball's current position

getBallDir

double getBallDir()
Returns:
a double specifying the current relative direction of the ball

getBallDist

double getBallDist()
distance to the ball from PlayerInfo
Returns:
a double specifying the ball's current distance to the player

getDirDist

double getDirDist(Coordinate objCoordinate)
difference of directions between an object and body direction
Returns:
a double specifying the difference between the body direction of the player an the direction of a Coordinate

getDist

double getDist(Coordinate c1,
               Coordinate c2)
distance between two objects
Returns:
a double the distance between two Coordinate's

resetViewMode

void resetViewMode()
reset view mode to width: normal and quality: high

getNormedDirection

double getNormedDirection(double direction)
norm direction
Parameters:
direction - a double specifying the desired direction
Returns:
direction a double specifying the normed direction