Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Player Class Reference

#include <Player.h>

Inheritance diagram for Player:

Inheritance graph
[legend]
Collaboration diagram for Player:

Collaboration graph
[legend]
List of all members.

Public Methods

 Player (ActHandler *a, WorldModel *wm, ServerSettings *ss, PlayerSettings *cs, Formations *fs, char *strTeamName, double dVersion, int iReconnect=-1)
void mainLoop ()
void handleStdin ()
void showStringCommands (ostream &out)
bool executeStringCommand (char *str)
SoccerCommand deMeer5 ()
SoccerCommand deMeer5_goalie ()

Private Methods

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)

Private Attributes

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

Detailed Description

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

Definition at line 64 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 66 of file Player.cpp.

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


Member Function Documentation

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 494 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(), OBJECT_BALL, OBJECT_SET_TEAMMATES, ObjectT, PENALTY_X, WorldModel::predictAgentPosAfterCommand(), WorldModel::predictBallInfoAfterCommand(), BasicPlayer::SS, and BasicPlayer::WM.

Referenced by shallISaySomething().

SoccerCommand Player::attackerMainLoop   [private]
 

This is the main decision loop for an agent.

Definition at line 239 of file Player.cpp.

References deMeer5().

Referenced by mainLoop().

SoccerCommand Player::defenderMainLoop   [private]
 

This is the main decision loop for a defender.

Definition at line 227 of file Player.cpp.

References deMeer5().

Referenced by mainLoop().

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:

  • if ball is kickable kick ball to goal (random corner of goal)
  • else if i am fastest player to ball intercept the ball
  • else move to strategic position based on your home position and pos ball

Definition at line 60 of file PlayerTeams.cpp.

References BasicPlayer::ACT, BasicPlayer::alignNeckWithBody(), 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(), ServerSettings::getBallSpeedMax(), 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(), BasicPlayer::intercept(), WorldModel::isBallKickable(), WorldModel::isBeforeKickOff(), WorldModel::isDeadBallThem(), WorldModel::isKickOffUs(), BasicPlayer::kickTo(), BasicPlayer::moveToPos(), OBJECT_BALL, OBJECT_SET_TEAMMATES, PITCH_LENGTH, BasicPlayer::PS, ActHandler::putCommandInQueue(), BasicPlayer::searchBall(), Formations::setFormation(), BasicPlayer::SS, BasicPlayer::teleportToPos(), 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 176 of file PlayerTeams.cpp.

References BasicPlayer::ACT, BasicPlayer::alignNeckWithBody(), AngDeg, BasicPlayer::catchBall(), CMD_MOVE, formations, FT_INITIAL, WorldModel::getAgentGlobalBodyAngle(), WorldModel::getAgentGlobalPosition(), WorldModel::getAgentObjectType(), PlayerSettings::getBallConfThr(), WorldModel::getBallPos(), WorldModel::getConfidence(), VecPosition::getDistanceTo(), WorldModel::getFastestInSetTo(), Formations::getFormation(), 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(), VecPosition::isLeftOf(), VecPosition::isRightOf(), BasicPlayer::kickTo(), SoccerCommand::makeCommand(), Line::makeLineFromTwoPoints(), BasicPlayer::moveToPos(), OBJECT_BALL, OBJECT_GOAL_L, OBJECT_GOAL_R, 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().

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 343 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().

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 248 of file Player.cpp.

References AngDeg, 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, ObjectT, POLAR, sign(), UnknownDoubleValue, and BasicPlayer::WM.

SoccerCommand Player::goalieMainLoop   [private]
 

This is the main decision loop for the goalkeeper.

Definition at line 221 of file Player.cpp.

References deMeer5_goalie().

Referenced by mainLoop().

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 293 of file Player.cpp.

References executeStringCommand(), and MAX_MSG.

Referenced by stdin_callback().

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 108 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(), WorldModel::logCoordInfo(), WorldModel::logDrawBallInfo(), WorldModel::logDrawInfo(), 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::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 \strMsg string message in which the ball information is encoded.

Definition at line 631 of file Player.cpp.

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

Referenced by sayBallStatus().

SoccerCommand Player::midfielderMainLoop   [private]
 

This is the main decision loop for a midfielder.

Definition at line 233 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 671 of file Player.cpp.

References BasicPlayer::ACT, AngDeg, 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, PlayModeT, 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().

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 595 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(), makeBallInfo(), OBJECT_BALL, WorldModel::predictAgentPos(), WorldModel::predictBallInfoAfterCommand(), VecPosition::setVecPosition(), BasicPlayer::SS, and BasicPlayer::WM.

Referenced by mainLoop().

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 541 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, ObjectT, PITCH_LENGTH, and BasicPlayer::WM.

Referenced by mainLoop().

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 480 of file Player.cpp.

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

Referenced by mainLoop().

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 314 of file Player.cpp.

Referenced by executeStringCommand().


Member Data Documentation

bool Player::bContLoop [private]
 

is server is alive

Definition at line 67 of file Player.h.

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

Formations* Player::formations [private]
 

all formation information

Definition at line 66 of file Player.h.

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

ActionT Player::m_actionPrev [private]
 

previous action of this agent

Definition at line 75 of file Player.h.

Referenced by Player().

int Player::m_iPenaltyNr [private]
 

number of current penalty

Definition at line 73 of file Player.h.

Referenced by performPenalty(), and Player().

ObjectT Player::m_objMarkOpp [private]
 

last marked opponent

Definition at line 70 of file Player.h.

Referenced by Player().

ObjectT Player::m_objPassOption [private]
 

passing option in kick

Definition at line 71 of file Player.h.

Time Player::m_timeLastSay [private]
 

last time communicated

Definition at line 69 of file Player.h.

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


The documentation for this class was generated from the following files:
Generated on Fri Nov 7 11:46:05 2003 for UvA Trilearn 2003 Base Code by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001