Player Class Reference

#include <Player.h>

Inheritance diagram for Player:

Inheritance graph
[legend]

Public Member Functions

 Player (ActHandler *a, WorldModel *wm, ServerSettings *ss, PlayerSettings *cs, Formations *fs, char *strTeamName, double dVersion, int iReconnect=-1)
 ~Player ()
void mainLoop ()
void handleStdin ()
void showStringCommands (ostream &out)
bool executeStringCommand (char *str)
SoccerCommand kickToPass (double *dFitness=NULL)
 GOS - Player passes ball to another player.
SoccerCommand kickToPlay ()
 GOS - method return a comand to kick the ball when OUT.
SoccerCommand kickToDrible ()
SoccerCommand kickToScore ()
SoccerCommand deMeer5 ()
SoccerCommand deMeer5_goalie ()
RoleCGgetPlayerRoles ()
 GOS - Function computes and returns an array of roles.
RoleCG getMyRole ()
 GOS - Function returns the role of the player.
int getPlayerIndexRole (ObjectT o)
 GOS - Gets the index of possition in RoleCG where agent's role is stored.
ObjectT getPlayerTypeRole (int index)
 GOS - Gets the index of possition in RoleCG where agent's role is stored.
double valueRuleInterc1 (PlayerActionCG agentAction)
 GOS - Value rule no.
double passTo (AngRad angle, ObjectT oPlayer, VecPosition *pos=NULL, double dConfThr=0.9)
 GOS - Determinse fitness for specific angle and determines the best position.
double valueRulePasser1 (RoleCG *playerRoles, int teammateIndex, PlayerActionCG agentAction, PlayerActionCG teammateAction, DirCG passDirection)
 GOS - Value rule no.
double valueRulePasser2 (PlayerActionCG agentAction, DirCG emptySpaceDirection)
 GOS - Value rule no.
double valueRulePasser3 (PlayerActionCG agentAction)
 GOS - Value rule no.
double valueRulePasser4 (PlayerActionCG agentAction)
 GOS - Value rule no.
double valueRuleReceiver1 (RoleCG *playerRoles, int teammateIndex, PlayerActionCG agentAction, PlayerActionCG teammateAction, DirCG passDirection)
 GOS - Value rule no.
double valueRuleReceiver2 (RoleCG *playerRoles, int teammateIndex1, int teammateIndex2, PlayerActionCG agentAction, PlayerActionCG teammateAction1, DirCG passDirection1, PlayerActionCG teammateAction2, DirCG passDirection2)
 GOS - Value rule no.
double valueRuleReceiver3 (PlayerActionCG agentAction)
 GOS - Value rule no.
double valueRulePassive1 (PlayerActionCG agentAction)
 GOS - Value rule no.
PlayerActionCGvariableEliminationAlgorithmCG ()
PlayerActionCGvariableEliminationAlgorithmCG (RoleCG *playerRoles)
 GOS - Functions returns an optimal common action computed by the variable elimination algorithm.
bool isPassBlockedCG (int playerIndex, int teammateIndex, DirCG passDirection)
 GOS - Not implemented yet!!!
bool isEmptySpace (int playerIndex, DirCG direction)
 GOS - Not implemented yet!!!
double uCG (int teammateIndex, DirCG passDirection)
 GOS - Not implemented yet!!!
double transformGlobalDirectionToAngleCG (DirCG globalDirection)
 GOS - Transforms an angle specified by DirCG to double value.
double getMax (double val1, double val2)
bool isInFrontOfGoalCG (VecPosition pos)
 GOS - Determines whether an object is in front of opponent's goal.
PlayerActionCGgetOptimalCommonAction ()
 GOS - Functions returns an optimal common action computed by the variable elimination algorithm.

Private Member Functions

SoccerCommand goalieMainLoop ()
SoccerCommand defenderMainLoop ()
SoccerCommand midfielderMainLoop ()
SoccerCommand attackerMainLoop ()
void performPenalty ()
VecPosition getDeadBallPosition ()
bool shallISaySomething (SoccerCommand soc)
bool amIAgentToSaySomething (SoccerCommand soc)
void sayOppAttackerStatus (char *str)
void sayBallStatus (char *str)
void makeBallInfo (VecPosition posBall, VecPosition velBall, int iDiff, char *str)
double passToFitness (double from1X, double from1Y, double to1X, double to1Y, double pX, double pY, double toX, double toY, double r)
 GOS - passTo fitness function.
double passToTeammateFitness (double from1X, double from1Y, double to1X, double to1Y, double pX, double pY, double toX, double toY, double r=-1)
 GOS - passTo fitness function for teammate.
double passToOpponentFitness (double from1X, double from1Y, double to1X, double to1Y, double pX, double pY, double toX, double toY, double r=-1)
 GOS - passTo fitness function for opponent.
bool isPassBlocked (ObjectT oPlayer, AngRad ang)
double leadingPass (ObjectT oPlayer, AngRad ang)
SoccerCommand circleKickToPass (double *dFitness=NULL)
 GOS - Kick to pass with circle algorithm.

Private Attributes

SituationsLoglog
Formationsformations
bool bContLoop
Time m_timeLastSay
ObjectT m_objMarkOpp
ObjectT m_objPassOption
int m_iPenaltyNr
ActionT m_actionPrev
VecPosition goalMiddle

Detailed Description

This class is a superclass from BasicPlayer and contains a more sophisticated decision procedure to determine the next action.

Definition at line 71 of file Player.h.


Constructor & Destructor Documentation

Player::Player ( ActHandler act,
WorldModel wm,
ServerSettings ss,
PlayerSettings ps,
Formations fs,
char *  strTeamName,
double  dVersion,
int  iReconnect = -1 
)

This is the constructor the Player class and calls the constructor of the superclass BasicPlayer.

Parameters:
act ActHandler to which the actions can be sent
wm WorldModel which information is used to determine action
ss ServerSettings that contain parameters used by the server
ps PlayerSettings that contain parameters important for the client
strTeamName team name of this player
dVersion version this basicplayer corresponds to
iReconnect integer that defines player number (-1 when new player)

Definition at line 70 of file Player.cpp.

References BasicPlayer::ACT, ACT_ILLEGAL, bContLoop, CARTESIAN, formations, Formations::getPlayerInFormation(), Formations::getPlayerType(), goalMiddle, log, m_actionPrev, m_iPenaltyNr, m_objMarkOpp, m_timeLastSay, MAX_MSG, OBJECT_ILLEGAL, PITCH_LENGTH, BasicPlayer::PS, PT_GOALKEEPER, ActHandler::sendMessage(), WorldModel::setTeamName(), VecPosition::setVecPosition(), BasicPlayer::SS, and BasicPlayer::WM.

Player::~Player (  ) 

Definition at line 112 of file Player.cpp.

References log.


Member Function Documentation

SoccerCommand Player::goalieMainLoop (  )  [private]

This is the main decision loop for the goalkeeper.

Definition at line 233 of file Player.cpp.

References deMeer5_goalie().

Referenced by mainLoop().

SoccerCommand Player::defenderMainLoop (  )  [private]

This is the main decision loop for a defender.

Definition at line 239 of file Player.cpp.

References deMeer5().

Referenced by mainLoop().

SoccerCommand Player::midfielderMainLoop (  )  [private]

This is the main decision loop for a midfielder.

Definition at line 245 of file Player.cpp.

References deMeer5().

Referenced by mainLoop().

SoccerCommand Player::attackerMainLoop (  )  [private]

This is the main decision loop for an agent.

Definition at line 251 of file Player.cpp.

References deMeer5().

Referenced by mainLoop().

void Player::performPenalty (  )  [private]

This method is called when a penalty kick has to be taken (for both the goalkeeper as the player who has to take the penalty.

Definition at line 683 of file Player.cpp.

References BasicPlayer::ACT, BasicPlayer::catchBall(), CMD_CHANGEVIEW, CMD_DASH, CMD_ILLEGAL, SoccerCommand::commandType, SoccerCommand::dPower, formations, WorldModel::getAgentGlobalBodyAngle(), WorldModel::getAgentGlobalPosition(), WorldModel::getAgentStamina(), WorldModel::getAgentViewAngle(), VecPosition::getDistanceTo(), ServerSettings::getPenAllowMultKicks(), ServerSettings::getPenDistX(), WorldModel::getPlayerNumber(), Formations::getPlayerType(), WorldModel::getPlayMode(), ServerSettings::getRecoverDecThr(), WorldModel::getSide(), WorldModel::getSidePenalty(), Stamina::getStamina(), ServerSettings::getStaminaMax(), VecPosition::getX(), BasicPlayer::intercept(), WorldModel::isBallCatchable(), WorldModel::isBallKickable(), SoccerCommand::isIllegal(), WorldModel::isPenaltyThem(), WorldModel::isPenaltyUs(), BasicPlayer::kickTo(), m_iPenaltyNr, BasicPlayer::moveToPos(), VecPosition::normalizeAngle(), OBJECT_BALL, PITCH_LENGTH, PM_ILLEGAL, PM_PENALTY_READY_LEFT, PM_PENALTY_READY_RIGHT, PM_PENALTY_SETUP_LEFT, PM_PENALTY_SETUP_RIGHT, PM_PENALTY_TAKEN_LEFT, PM_PENALTY_TAKEN_RIGHT, POLAR, PT_GOALKEEPER, ActHandler::putCommandInQueue(), VecPosition::setVecPosition(), SIDE_LEFT, SIDE_RIGHT, BasicPlayer::SS, BasicPlayer::turnBodyToPoint(), BasicPlayer::turnNeckToObject(), VA_NARROW, VQ_HIGH, and BasicPlayer::WM.

Referenced by mainLoop().

VecPosition Player::getDeadBallPosition (  )  [private]

This method returns the position to move in case of a dead ball situation. A dead ball situation occurs when the team can have a free kick, kick in, etc. The agent will move to the position behind the ball and when he is there will move to the ball again.

Definition at line 260 of file Player.cpp.

References WorldModel::getAgentGlobalPosition(), WorldModel::getAgentObjectType(), WorldModel::getBallPos(), WorldModel::getClosestInSetTo(), WorldModel::getGlobalPosition(), VecPosition::getY(), WorldModel::isBackPassThem(), WorldModel::isCornerKickUs(), WorldModel::isFreeKickFaultThem(), WorldModel::isFreeKickUs(), WorldModel::isGoalKickUs(), WorldModel::isKickInUs(), WorldModel::isOffsideThem(), VecPosition::normalizeAngle(), OBJECT_SET_PLAYERS, POLAR, sign(), UnknownDoubleValue, and BasicPlayer::WM.

bool Player::shallISaySomething ( SoccerCommand  socPri  )  [private]

This method determines whether a player should say something.

Returns:
bool indicating whether the agent should say a message

Definition at line 492 of file Player.cpp.

References amIAgentToSaySomething(), WorldModel::getCurrentCycle(), WorldModel::getCurrentTime(), ServerSettings::getHearDecay(), m_timeLastSay, BasicPlayer::SS, and BasicPlayer::WM.

Referenced by mainLoop().

bool Player::amIAgentToSaySomething ( SoccerCommand  socPri  )  [private]

This method returns a boolean indicating whether I should communicate my world model to the other agents.

Returns:
boolean indicating whether I should communicate my world model.

Definition at line 506 of file Player.cpp.

References WorldModel::getAgentObjectType(), WorldModel::getBallPos(), WorldModel::getClosestInSetTo(), WorldModel::getConfidence(), WorldModel::getCurrentCycle(), WorldModel::getCurrentTime(), VecPosition::getDistanceTo(), ServerSettings::getMaximalKickDist(), WorldModel::getPlayerNumber(), WorldModel::getRelativeDistance(), WorldModel::getTimeChangeInformation(), WorldModel::getTimeLastSeen(), ServerSettings::getVisibleDistance(), VecPosition::getX(), Logger::log(), Log, OBJECT_BALL, OBJECT_SET_TEAMMATES, PENALTY_X, WorldModel::predictAgentPosAfterCommand(), WorldModel::predictBallInfoAfterCommand(), BasicPlayer::SS, and BasicPlayer::WM.

Referenced by shallISaySomething().

void Player::sayOppAttackerStatus ( char *  strMsg  )  [private]

This method encodes the opponent attacker status in a visual message.

Returns:
string in which the opponent attacker position is encoded.

Definition at line 553 of file Player.cpp.

References WorldModel::getClosestInSetTo(), WorldModel::getCurrentCycle(), WorldModel::getGlobalPosition(), SoccerTypes::getIndex(), WorldModel::getOffsideX(), VecPosition::getX(), VecPosition::getY(), max(), MAX_SAY_MSG, OBJECT_ILLEGAL, OBJECT_SET_OPPONENTS, PITCH_LENGTH, and BasicPlayer::WM.

Referenced by mainLoop().

void Player::sayBallStatus ( char *  strMsg  )  [private]

This method creates a string to communicate the ball status. When the player just kicks the ball, it is the new velocity of the ball, otherwise it is the current velocity.

Parameters:
strMsg will be filled

Definition at line 607 of file Player.cpp.

References BasicPlayer::ACT, CMD_KICK, SoccerCommand::commandType, VecPosition::getDistanceTo(), WorldModel::getGlobalPosition(), WorldModel::getGlobalVelocity(), ServerSettings::getMaximalKickDist(), ActHandler::getPrimaryCommand(), WorldModel::getRelativeDistance(), VecPosition::getX(), VecPosition::getY(), Logger::log(), Log, makeBallInfo(), OBJECT_BALL, WorldModel::predictAgentPos(), WorldModel::predictBallInfoAfterCommand(), VecPosition::setVecPosition(), BasicPlayer::SS, and BasicPlayer::WM.

Referenced by mainLoop().

void Player::makeBallInfo ( VecPosition  posBall,
VecPosition  velBall,
int  iDiff,
char *  strMsg 
) [private]

This method is used to create the communicate message for the status of the ball, that is its position and velocity is encoded.

Parameters:
VecPosition posBall ball position
VecPosition velBall ball velocity
iDiff time difference corresponding to given ball information string message in which the ball information is encoded.

Definition at line 643 of file Player.cpp.

References WorldModel::getCurrentCycle(), WorldModel::getOffsideX(), WorldModel::getPlayerNumber(), VecPosition::getX(), VecPosition::getY(), Logger::log(), Log, max(), MAX_SAY_MSG, min(), and BasicPlayer::WM.

Referenced by sayBallStatus().

void Player::mainLoop (  ) 

This is the main loop of the agent. This method calls the update methods of the world model after it is indicated that new information has arrived. After this, the correct main loop of the player type is called, which puts the best soccer command in the queue of the ActHandler.

Definition at line 120 of file Player.cpp.

References BasicPlayer::ACT, attackerMainLoop(), bContLoop, defenderMainLoop(), formations, WorldModel::getBallPos(), WorldModel::getCurrentCycle(), WorldModel::getCurrentTime(), Timing::getElapsedTime(), ServerSettings::getHalfTime(), WorldModel::getPlayerNumber(), Formations::getPlayerType(), WorldModel::getPlayMode(), WorldModel::getRecvThink(), ServerSettings::getSimulatorStep(), ServerSettings::getSynchMode(), WorldModel::getTimeLastSeeMessage(), VecPosition::getX(), goalieMainLoop(), WorldModel::iNrHoles, WorldModel::iNrOpponentsSeen, WorldModel::iNrTeammatesSeen, Logger::isInLogLevel(), WorldModel::isPenaltyThem(), WorldModel::isPenaltyUs(), Logger::log(), Log, WorldModel::logCoordInfo(), LogDraw, WorldModel::logDrawBallInfo(), WorldModel::logDrawInfo(), Logger::logWithTime(), m_timeLastSay, MAX_MSG, MAX_SAY_MSG, midfielderMainLoop(), OBJECT_BALL, PENALTY_X, performPenalty(), PM_FROZEN, WorldModel::processRecvThink(), PT_ATTACKER, PT_ATTACKER_WING, PT_DEFENDER_CENTRAL, PT_DEFENDER_SWEEPER, PT_DEFENDER_WING, PT_GOALKEEPER, PT_ILLEGAL, PT_MIDFIELDER_CENTER, PT_MIDFIELDER_WING, ActHandler::putCommandInQueue(), Timing::restartTime(), sayBallStatus(), sayOppAttackerStatus(), ActHandler::sendCommands(), ActHandler::sendMessage(), ActHandler::sendMessageDirect(), WorldModel::setCommunicationString(), Logger::setHeader(), shallISaySomething(), BasicPlayer::SS, BasicPlayer::turnBodyToObject(), WorldModel::updateAll(), WorldModel::waitForNewInformation(), and BasicPlayer::WM.

Referenced by main().

void Player::handleStdin (  ) 

This method listens for input from the keyboard and when it receives this input it converts this input to the associated action. See showStringCommands for the possible options. This method is used together with the SenseHandler class that sends an alarm to indicate that a new command can be sent. This conflicts with the method in this method that listens for the user input (fgets) on Linux systems (on Solaris this isn't a problem). The only known method is to use the flag SA_RESTART with this alarm function, but that does not seem to work under Linux. If each time the alarm is sent, this gets function unblocks, it will cause major performance problems. This function should not be called when a whole match is played!

Definition at line 305 of file Player.cpp.

References bContLoop, executeStringCommand(), and MAX_MSG.

Referenced by stdin_callback().

void Player::showStringCommands ( ostream &  out  ) 

This method prints the possible commands that can be entered by the user. The whole name can be entered to perform the corresponding command, but normally only the first character is sufficient. This is indicated by putting brackets around the part of the command that is not needed.

Parameters:
out output stream to which the possible commands are printed

Definition at line 326 of file Player.cpp.

Referenced by executeStringCommand().

bool Player::executeStringCommand ( char *  str  ) 

This method executes the command that is entered by the user. For the possible command look at the method showStringCommands.

Parameters:
str string that is entered by the user
Returns:
true when command could be executed, false otherwise

Definition at line 355 of file Player.cpp.

References BasicPlayer::ACT, bContLoop, CMD_CATCH, CMD_CHANGEVIEW, CMD_DASH, CMD_ILLEGAL, CMD_KICK, CMD_MOVE, CMD_SAY, CMD_TURN, CMD_TURNNECK, SoccerCommand::commandType, SoccerCommand::dAngle, SoccerCommand::dPower, SoccerCommand::dX, SoccerCommand::dY, WorldModel::getAgentGlobalNeckAngle(), WorldModel::getAgentGlobalPosition(), WorldModel::getAgentObjectType(), WorldModel::getNrInSetInCone(), SoccerTypes::getViewAngleFromStr(), SoccerTypes::getViewQualityFromStr(), Parse::gotoFirstNonSpace(), Parse::gotoFirstOccurenceOf(), SoccerCommand::iTimes, BasicPlayer::kickTo(), SoccerCommand::makeCommand(), OBJECT_SET_OPPONENTS, Parse::parseFirstDouble(), Parse::parseFirstInt(), POLAR, WorldModel::predictNrCyclesToPoint(), BasicPlayer::PS, ActHandler::putCommandInQueue(), ActHandler::sendMessage(), WorldModel::show(), GenericValues::show(), WorldModel::showQueuedCommands(), showStringCommands(), BasicPlayer::SS, SoccerCommand::str, SoccerCommand::va, SoccerCommand::vq, and BasicPlayer::WM.

Referenced by handleStdin().

SoccerCommand Player::kickToPass ( double *  dFitness = NULL  ) 

GOS - Player passes ball to another player.

Position to kick to is determined with prediction

Parameters:
dFitness output fitness of the command

Definition at line 495 of file PlayerTeams.cpp.

References circleKickToPass(), CMD_ILLEGAL, WorldModel::getCurrentCycle(), log, SituationsLog::situationBegin(), SituationsLog::situationEnd(), and BasicPlayer::WM.

Referenced by deMeer5(), and deMeer5_goalie().

SoccerCommand Player::kickToPlay (  ) 

GOS - method return a comand to kick the ball when OUT.

Definition at line 512 of file PlayerTeams.cpp.

References BasicPlayer::ACT, CMD_ILLEGAL, ServerSettings::getBallSpeedMax(), WorldModel::getClosestRelativeInSet(), WorldModel::getGlobalPosition(), BasicPlayer::kickTo(), kickToScore(), OBJECT_BALL, OBJECT_ILLEGAL, OBJECT_SET_TEAMMATES_NO_GOALIE, ActHandler::putCommandInQueue(), BasicPlayer::SS, BasicPlayer::turnNeckToObject(), and BasicPlayer::WM.

Referenced by deMeer5().

SoccerCommand Player::kickToDrible (  ) 

Definition at line 165 of file PlayerTeams.cpp.

References BasicPlayer::ACT, CMD_ILLEGAL, ServerSettings::getBallSpeedMax(), WorldModel::getCurrentCycle(), ServerSettings::getGoalWidth(), BasicPlayer::kickTo(), Logger::log(), Log, OBJECT_BALL, PITCH_LENGTH, ActHandler::putCommandInQueue(), BasicPlayer::SS, BasicPlayer::turnNeckToObject(), and BasicPlayer::WM.

SoccerCommand Player::kickToScore (  ) 

Definition at line 58 of file PlayerTeams.cpp.

References BasicPlayer::ACT, cFuzzyObj::AddInput(), cFuzzyObj::AddInputMF(), cFuzzyObj::AddOutput(), cFuzzyObj::AddOutputMF(), cFuzzyObj::AddRule(), CMD_ILLEGAL, cFuzzyObj::CountResult(), DFZ_CENTROID, FZ_LEFT, FZ_RIGHT, FZ_TRAPEZOID, FZ_TRIANGLE, WorldModel::getAgentGlobalPosition(), ServerSettings::getBallSpeedMax(), WorldModel::getGlobalPosition(), ServerSettings::getGoalWidth(), VecPosition::getY(), BasicPlayer::kickTo(), Logger::log(), Log, OBJECT_BALL, OBJECT_OPPONENT_GOALIE, OPS_ZADEH, PITCH_LENGTH, ActHandler::putCommandInQueue(), cFuzzyObj::SetSamples(), BasicPlayer::SS, BasicPlayer::turnNeckToObject(), and BasicPlayer::WM.

Referenced by deMeer5(), and kickToPlay().

SoccerCommand Player::deMeer5 (  ) 

This method is the first complete simple team and defines the actions taken by all the players on the field (excluding the goalie). It is based on the high-level actions taken by the simple team FC Portugal that it released in 2000. The players do the following:

Definition at line 543 of file PlayerTeams.cpp.

References BasicPlayer::ACT, BasicPlayer::adjustView(), BasicPlayer::alignNeckWithBody(), BasicPlayer::canDribbleWithBall(), CMD_DASH, CMD_ILLEGAL, CMD_TURNNECK, SoccerCommand::commandType, SoccerCommand::dPower, formations, FT_433_OFFENSIVE, FT_INITIAL, WorldModel::getAgentGlobalPosition(), WorldModel::getAgentObjectType(), WorldModel::getAgentStamina(), PlayerSettings::getBallConfThr(), WorldModel::getBallPos(), WorldModel::getConfidence(), WorldModel::getCurrentCycle(), VecPosition::getDistanceTo(), WorldModel::getFastestInSetTo(), Formations::getFormation(), ServerSettings::getGoalWidth(), WorldModel::getPlayerNumber(), PlayerSettings::getPlayerWhenToTurnAngle(), ServerSettings::getRecoverDecThr(), Stamina::getRecovery(), WorldModel::getRelativeAngle(), Stamina::getStamina(), ServerSettings::getStaminaMax(), WorldModel::getStrategicPosition(), VecPosition::getX(), goalMiddle, BasicPlayer::handleWithBall(), BasicPlayer::intercept(), WorldModel::isBallKickable(), WorldModel::isBeforeKickOff(), WorldModel::isDeadBallThem(), WorldModel::isDeadBallUs(), WorldModel::isGoalKickUs(), WorldModel::isKickOffUs(), kickToPass(), kickToPlay(), kickToScore(), Logger::log(), Log, BasicPlayer::moveToPos(), OBJECT_BALL, OBJECT_SET_TEAMMATES, BasicPlayer::oscillateView(), PITCH_LENGTH, BasicPlayer::PS, ActHandler::putCommandInQueue(), BasicPlayer::searchBall(), Formations::setFormation(), BasicPlayer::SS, BasicPlayer::teleportToPos(), BasicPlayer::turnAround(), BasicPlayer::turnBodyToObject(), BasicPlayer::turnBodyToPoint(), BasicPlayer::turnNeckToObject(), and BasicPlayer::WM.

Referenced by attackerMainLoop(), defenderMainLoop(), and midfielderMainLoop().

SoccerCommand Player::deMeer5_goalie (  ) 

This method is a simple goalie based on the goalie of the simple Team of FC Portugal. It defines a rectangle in its penalty area and moves to the position on this rectangle where the ball intersects if you make a line between the ball position and the center of the goal. If the ball can be intercepted in the own penalty area the ball is intercepted and catched.

Definition at line 743 of file PlayerTeams.cpp.

References BasicPlayer::ACT, BasicPlayer::adjustView(), BasicPlayer::alignNeckWithBody(), BasicPlayer::catchBall(), CMD_ILLEGAL, CMD_MOVE, SoccerCommand::commandType, BasicPlayer::dashToPoint(), formations, FT_INITIAL, WorldModel::getAgentGlobalBodyAngle(), WorldModel::getAgentGlobalPosition(), WorldModel::getAgentObjectType(), PlayerSettings::getBallConfThr(), WorldModel::getBallPos(), WorldModel::getConfidence(), VecPosition::getDistanceTo(), WorldModel::getFastestInSetTo(), Formations::getFormation(), WorldModel::getGlobalPosition(), SoccerTypes::getGlobalPositionFlag(), BasicPlayer::getInterceptionPointBall(), Line::getIntersection(), WorldModel::getNrInSetInCircle(), PlayerSettings::getPlayerWhenToTurnAngle(), WorldModel::getPlayMode(), WorldModel::getSide(), WorldModel::getStrategicPosition(), WorldModel::getTimeSinceLastCatch(), VecPosition::getX(), VecPosition::getY(), BasicPlayer::intercept(), WorldModel::isBallCatchable(), WorldModel::isBallKickable(), WorldModel::isBeforeKickOff(), WorldModel::isCornerKickThem(), WorldModel::isFreeKickThem(), WorldModel::isFreeKickUs(), WorldModel::isGoalKickUs(), WorldModel::isInOwnPenaltyArea(), kickToPass(), SoccerCommand::makeCommand(), Line::makeLineFromTwoPoints(), BasicPlayer::moveToPos(), OBJECT_BALL, OBJECT_GOAL_L, OBJECT_GOAL_R, OBJECT_ILLEGAL, OBJECT_SET_OPPONENTS, OBJECT_SET_PLAYERS, PENALTY_AREA_LENGTH, PENALTY_AREA_WIDTH, PITCH_LENGTH, PM_PLAY_ON, BasicPlayer::PS, ActHandler::putCommandInQueue(), BasicPlayer::searchBall(), Formations::setFormation(), VecPosition::setX(), SIDE_LEFT, SIDE_RIGHT, BasicPlayer::teleportToPos(), BasicPlayer::turnBodyToObject(), BasicPlayer::turnBodyToPoint(), BasicPlayer::turnNeckToObject(), and BasicPlayer::WM.

Referenced by goalieMainLoop().

RoleCG * Player::getPlayerRoles (  ) 

GOS - Function computes and returns an array of roles.

Returns:
roles for each agent in the array.

Definition at line 900 of file Player.cpp.

References ACTIVE_INTERCEPTOR, ACTIVE_PASSER, ArsToolbox::computeLeastInterceptTime(), WorldModel::getAgentGlobalPosition(), WorldModel::getBallPos(), WorldModel::getGlobalPosition(), WorldModel::getGlobalVelocity(), getMax(), getPlayerIndexRole(), ServerSettings::getPlayerSpeedMax(), GOALIE, WorldModel::iterateObjectDone(), WorldModel::iterateObjectNext(), WorldModel::iterateObjectStart(), NO_ROLE, OBJECT_BALL, OBJECT_GOAL_R, OBJECT_ILLEGAL, OBJECT_SET_TEAMMATES_NO_GOALIE, PASSIVE, RECEIVER, BasicPlayer::SS, and BasicPlayer::WM.

Referenced by getMyRole(), and getOptimalCommonAction().

RoleCG Player::getMyRole (  ) 

GOS - Function returns the role of the player.

Returns:
the role of mine in the current formation on the field

Definition at line 1120 of file Player.cpp.

References WorldModel::getAgentObjectType(), getPlayerIndexRole(), getPlayerRoles(), and BasicPlayer::WM.

int Player::getPlayerIndexRole ( ObjectT  o  ) 

GOS - Gets the index of possition in RoleCG where agent's role is stored.

Parameters:
Player whose index will be returned
Returns:
index to RoleCG.
-1 is returned if o is not a teamate.

Definition at line 851 of file Player.cpp.

References OBJECT_TEAMMATE_1, OBJECT_TEAMMATE_10, OBJECT_TEAMMATE_11, OBJECT_TEAMMATE_2, OBJECT_TEAMMATE_3, OBJECT_TEAMMATE_4, OBJECT_TEAMMATE_5, OBJECT_TEAMMATE_6, OBJECT_TEAMMATE_7, OBJECT_TEAMMATE_8, and OBJECT_TEAMMATE_9.

Referenced by getMyRole(), getPlayerRoles(), valueRulePasser1(), valueRulePasser2(), valueRuleReceiver1(), and valueRuleReceiver2().

ObjectT Player::getPlayerTypeRole ( int  index  ) 

GOS - Gets the index of possition in RoleCG where agent's role is stored.

Parameters:
index Player's index whose ObjectT will be returned
Returns:
Object type fo the player.

Definition at line 800 of file Player.cpp.

References OBJECT_TEAMMATE_1, OBJECT_TEAMMATE_10, OBJECT_TEAMMATE_11, OBJECT_TEAMMATE_2, OBJECT_TEAMMATE_3, OBJECT_TEAMMATE_4, OBJECT_TEAMMATE_5, OBJECT_TEAMMATE_6, OBJECT_TEAMMATE_7, OBJECT_TEAMMATE_8, and OBJECT_TEAMMATE_9.

double Player::valueRuleInterc1 ( PlayerActionCG  agentAction  ) 

GOS - Value rule no.

1 of an interceptor player.

Parameters:
agentAction Chosen agent action
Returns:
value

Definition at line 1181 of file Player.cpp.

References PlayerActionCG::getActionType(), and INTERCEPT.

double Player::passTo ( AngRad  angle,
ObjectT  oPlayer,
VecPosition pos = NULL,
double  dConfThr = 0.9 
)

GOS - Determinse fitness for specific angle and determines the best position.

Using circle algorithm this function finds the best position on line specified by angle Here is made the decision if a player (teammate or oponent) will be considered.

See also:
passToFitness
Parameters:
angle line angle from player
oPlayer player to kick to, if function should find the best then use OBJECT_SELECT_PLAYER
pos the best position where to kick ball to
dConfThr confidence treshold for players
Returns:
fitness for this angle

Definition at line 308 of file PlayerTeams.cpp.

References SituationsLog::addObject(), ArsToolbox::circleLineIntersection(), ArsToolbox::createLineTo(), WorldModel::getAgentGlobalPosition(), VecPosition::getDistanceTo(), WorldModel::getGlobalPosition(), BasicPlayer::getInterestRadius(), VecPosition::getX(), VecPosition::getY(), WorldModel::iterateObjectDone(), WorldModel::iterateObjectNext(), WorldModel::iterateObjectStart(), log, LOG_CIRCLE, LOG_LINE, LOG_PLAYER_OTHER, LOG_PLAYER_TEAM, OBJECT_ILLEGAL, OBJECT_SET_OPPONENTS, OBJECT_SET_TEAMMATES_NO_GOALIE, passToOpponentFitness(), passToTeammateFitness(), RAY_LENGTH, VecPosition::setX(), VecPosition::setY(), ArsToolbox::trim(), and BasicPlayer::WM.

Referenced by circleKickToPass().

double Player::valueRulePasser1 ( RoleCG playerRoles,
int  teammateIndex,
PlayerActionCG  agentAction,
PlayerActionCG  teammateAction,
DirCG  passDirection 
)

GOS - Value rule no.

1 of a passer player.

Parameters:
playerRoles array of roles for every player on the field
teammateIndex index of a teammate of mine
agentAction chosen action of the current player
teammateAction chosen action of a teammate of mine
passDirection direction of a leading pass to a teammate of mine
Returns:
value

Definition at line 1196 of file Player.cpp.

References PlayerActionCG::getActionType(), WorldModel::getAgentObjectType(), PlayerActionCG::getDirection(), getPlayerIndexRole(), PlayerActionCG::getTeammateIndex(), isPassBlockedCG(), LEADING_PASS_TO, MOVE_TO, RECEIVER, uCG(), and BasicPlayer::WM.

double Player::valueRulePasser2 ( PlayerActionCG  agentAction,
DirCG  emptySpaceDirection 
)

GOS - Value rule no.

2 of a passer player.

Parameters:
agentAction chosen action of the current player
emptySpaceDirection possible direction to an empty area (30m triangle)
Returns:
value

Definition at line 1231 of file Player.cpp.

References DRIBBLE, PlayerActionCG::getActionType(), WorldModel::getAgentObjectType(), PlayerActionCG::getDirection(), getPlayerIndexRole(), isEmptySpace(), and BasicPlayer::WM.

double Player::valueRulePasser3 ( PlayerActionCG  agentAction  ) 

GOS - Value rule no.

3 of a passer player.

Parameters:
agentAction chosen action of the current player
Returns:
value

Definition at line 1247 of file Player.cpp.

References DRIBBLE, and PlayerActionCG::getActionType().

double Player::valueRulePasser4 ( PlayerActionCG  agentAction  ) 

GOS - Value rule no.

4 of a passer player.

Parameters:
agentAction chosen action of the current player
Returns:
value

Definition at line 1281 of file Player.cpp.

References PlayerActionCG::getActionType(), WorldModel::getAgentGlobalPosition(), WorldModel::isBallKickable(), isInFrontOfGoalCG(), SCORE, and BasicPlayer::WM.

double Player::valueRuleReceiver1 ( RoleCG playerRoles,
int  teammateIndex,
PlayerActionCG  agentAction,
PlayerActionCG  teammateAction,
DirCG  passDirection 
)

GOS - Value rule no.

1 of a receiver player.

Parameters:
playerRoles array of roles for every player on the field
teammateIndex index of a teammate of mine
agentAction chosen action of the current player
teammateAction chosen action of a teammate of mine
passDirection direction of a leading pass to a teammate of mine
Returns:
value

Definition at line 1302 of file Player.cpp.

References ACTIVE_INTERCEPTOR, PlayerActionCG::getActionType(), WorldModel::getAgentObjectType(), PlayerActionCG::getDirection(), getPlayerIndexRole(), INTERCEPT, MOVE_TO, uCG(), and BasicPlayer::WM.

double Player::valueRuleReceiver2 ( RoleCG playerRoles,
int  teammateIndex1,
int  teammateIndex2,
PlayerActionCG  agentAction,
PlayerActionCG  teammateAction1,
DirCG  passDirection1,
PlayerActionCG  teammateAction2,
DirCG  passDirection2 
)

GOS - Value rule no.

2 of a receiver player.

Parameters:
playerRoles array of roles for every player on the field
teammateIndex1 index of a teammate1 of mine
teammateIndex2 index of a teammate2 of mine
agentAction chosen action of the current player
teammateAction1 chosen action of a teammate1 of mine
passDirection1 pass direction from the current player to teammate1
teammateAction2 chosen action of a teammate2 of mine
passDirection2 pass direction from teammate1 to teammate2
Returns:
value

Definition at line 1332 of file Player.cpp.

References PlayerActionCG::getActionType(), WorldModel::getAgentObjectType(), PlayerActionCG::getDirection(), getPlayerIndexRole(), PlayerActionCG::getTeammateIndex(), LEADING_PASS_TO, MOVE_TO, RECEIVER, uCG(), and BasicPlayer::WM.

double Player::valueRuleReceiver3 ( PlayerActionCG  agentAction  ) 

GOS - Value rule no.

3 of a receiver player.

Parameters:
agentAction chosen action of the current player
Returns:
value

Definition at line 1363 of file Player.cpp.

References PlayerActionCG::getActionType(), and MOVE_TO_STRAT_POS.

double Player::valueRulePassive1 ( PlayerActionCG  agentAction  ) 

GOS - Value rule no.

1 of a passive player.

Parameters:
agentAction chosen action of the current player
Returns:
value

Definition at line 1376 of file Player.cpp.

References PlayerActionCG::getActionType(), and MOVE_TO_STRAT_POS.

PlayerActionCG* Player::variableEliminationAlgorithmCG (  ) 

Referenced by getOptimalCommonAction().

PlayerActionCG * Player::variableEliminationAlgorithmCG ( RoleCG playerRoles  ) 

GOS - Functions returns an optimal common action computed by the variable elimination algorithm.

Returns:
optimal joint actions of all agents excluding the goalie.

Definition at line 1406 of file Player.cpp.

bool Player::isPassBlockedCG ( int  playerIndex,
int  teammateIndex,
DirCG  passDirection 
)

GOS - Not implemented yet!!!

Parameters:
playerIndex index of the player in role array
teammateIndex index of teammate in role array
passDirection direction of the leading pass to the teammate specified by teammateIndex
return true / false

Definition at line 1585 of file Player.cpp.

Referenced by valueRulePasser1().

bool Player::isEmptySpace ( int  playerIndex,
DirCG  direction 
)

GOS - Not implemented yet!!!

Parameters:
playerIndex index of teammate in role array
direction of the possible player movement
return true / false

Definition at line 1597 of file Player.cpp.

Referenced by valueRulePasser2().

double Player::uCG ( int  teammateIndex,
DirCG  passDirection 
)

GOS - Not implemented yet!!!

Parameters:
teammateIndex index of teammate in role array
passDirection direction of the pass
return A number from interval <5,7>. Now it returns a fake value 6.0.

Definition at line 1609 of file Player.cpp.

Referenced by valueRulePasser1(), valueRuleReceiver1(), and valueRuleReceiver2().

double Player::transformGlobalDirectionToAngleCG ( DirCG  globalDirection  ) 

GOS - Transforms an angle specified by DirCG to double value.

Parameters:
globalDirection Global direction angle
Returns:
global Direction in radians

Definition at line 1141 of file Player.cpp.

References E, WorldModel::getGlobalAngle(), N, NE, NW, OBJECT_FLAG_C_B, OBJECT_FLAG_C_T, OBJECT_FLAG_L_B, OBJECT_FLAG_L_T, OBJECT_FLAG_R_B, OBJECT_FLAG_R_T, OBJECT_GOAL_L, OBJECT_GOAL_R, S, SE, SW, W, and BasicPlayer::WM.

double Player::getMax ( double  val1,
double  val2 
)

Definition at line 1128 of file Player.cpp.

Referenced by getPlayerRoles().

bool Player::isInFrontOfGoalCG ( VecPosition  pos  ) 

GOS - Determines whether an object is in front of opponent's goal.

Parameters:
pos global position of an object on the field
Returns:
value

Definition at line 1261 of file Player.cpp.

References SoccerTypes::getGlobalPositionFlag(), WorldModel::getSide(), VecPosition::getX(), VecPosition::getY(), OBJECT_FLAG_P_L_C, OBJECT_FLAG_P_R_C, PENALTY_AREA_WIDTH, SIDE_LEFT, and BasicPlayer::WM.

Referenced by valueRulePasser4().

PlayerActionCG * Player::getOptimalCommonAction (  ) 

GOS - Functions returns an optimal common action computed by the variable elimination algorithm.

Returns:
optimal joint actions of all agents excluding the goalie.

Definition at line 1388 of file Player.cpp.

References getPlayerRoles(), and variableEliminationAlgorithmCG().

double Player::passToFitness ( double  from1X,
double  from1Y,
double  to1X,
double  to1Y,
double  pX,
double  pY,
double  toX,
double  toY,
double  r 
) [private]

GOS - passTo fitness function.

Determines fitness function for passing ball from one position to another.

Parameters:
from1X line start X
from1Y line start Y
to1X line end X
to1Y line end Y
pX player X
pY player Y
toX pass ball to X
toY pass ball to Y

Definition at line 192 of file PlayerTeams.cpp.

References ArsToolbox::linePointDistance(), VecPosition::pointsDistance(), RAY_LENGTH, and ArsToolbox::trim().

Referenced by passToOpponentFitness(), and passToTeammateFitness().

double Player::passToTeammateFitness ( double  from1X,
double  from1Y,
double  to1X,
double  to1Y,
double  pX,
double  pY,
double  toX,
double  toY,
double  r = -1 
) [private]

GOS - passTo fitness function for teammate.

Determines fitness function for passing ball from one position to anothers. anothers.

Parameters:
from1X line start X
from1Y line start Y
to1X line end X
to1Y line end Y
pX player X
pY player Y
toX pass ball to X
toY pass ball to Y

Definition at line 226 of file PlayerTeams.cpp.

References VecPosition::getDistanceTo(), goalMiddle, passToFitness(), PITCH_LENGTH, and ArsToolbox::trim().

Referenced by passTo().

double Player::passToOpponentFitness ( double  from1X,
double  from1Y,
double  to1X,
double  to1Y,
double  pX,
double  pY,
double  toX,
double  toY,
double  r = -1 
) [private]

GOS - passTo fitness function for opponent.

Determines fitness function for passing ball from one position to anothers.

Parameters:
from1X line start X
from1Y line start Y
to1X line end X
to1Y line end Y
pX player X
pY player Y
toX pass ball to X
toY pass ball to Y

Definition at line 271 of file PlayerTeams.cpp.

References passToFitness().

Referenced by passTo().

bool Player::isPassBlocked ( ObjectT  oPlayer,
AngRad  ang 
) [private]

Definition at line 285 of file PlayerTeams.cpp.

double Player::leadingPass ( ObjectT  oPlayer,
AngRad  ang 
) [private]

Definition at line 288 of file PlayerTeams.cpp.

SoccerCommand Player::circleKickToPass ( double *  dFitness = NULL  )  [private]

GOS - Kick to pass with circle algorithm.

Finds the best ray to kick ball to using ray fitness function Algorithm scans every N degree, where N = 2PI / KICK_RAYS_NR

Parameters:
dFitness output fitness of the command
See also:
passTo
Returns:
Used and sent SoccerCommand

Definition at line 451 of file PlayerTeams.cpp.

References SituationsLog::addObject(), CMD_ILLEGAL, WorldModel::getAgentGlobalPosition(), ServerSettings::getBallSpeedMax(), VecPosition::getX(), VecPosition::getY(), KICK_RAYS_NR, BasicPlayer::kickTo(), log, LOG_LINE, LOG_PLAYER_ACTIVE, OBJECT_SELECT_PLAYER, passTo(), BasicPlayer::SS, ArsToolbox::trim(), and BasicPlayer::WM.

Referenced by kickToPass().


Field Documentation

SituationsLog* Player::log [private]

situations logging

Definition at line 73 of file Player.h.

Referenced by circleKickToPass(), kickToPass(), passTo(), Player(), and ~Player().

Formations* Player::formations [private]

all formation information

Definition at line 74 of file Player.h.

Referenced by deMeer5(), deMeer5_goalie(), mainLoop(), performPenalty(), and Player().

bool Player::bContLoop [private]

is server is alive

Definition at line 75 of file Player.h.

Referenced by executeStringCommand(), handleStdin(), mainLoop(), and Player().

Time Player::m_timeLastSay [private]

last time communicated

Definition at line 78 of file Player.h.

Referenced by mainLoop(), Player(), and shallISaySomething().

ObjectT Player::m_objMarkOpp [private]

last marked opponent

Definition at line 79 of file Player.h.

Referenced by Player().

ObjectT Player::m_objPassOption [private]

passing option in kick

Definition at line 80 of file Player.h.

int Player::m_iPenaltyNr [private]

number of current penalty

Definition at line 82 of file Player.h.

Referenced by performPenalty(), and Player().

ActionT Player::m_actionPrev [private]

previous action of this agent

Definition at line 84 of file Player.h.

Referenced by Player().

VecPosition Player::goalMiddle [private]

Definition at line 95 of file Player.h.

Referenced by deMeer5(), passToTeammateFitness(), and Player().


The documentation for this class was generated from the following files:
Generated on Thu Apr 26 22:45:31 2007 for GangOfSix(GOS)-RoboCupTeamProject by  doxygen 1.5.1-p1