Main Page   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 deMeer5 ()
void deMeer5_goalie ()
void handleStdin ()
void showStringCommands (ostream &out)
bool executeStringCommand (char *str)
void test_only_update ()

Private Methods

void goalieMainLoop ()
void defenderMainLoop ()
void midfielderMainLoop ()
void attackerMainLoop ()
bool shallISaySomething ()
bool amIAgentToSaySomething ()
SoccerCommand sayBallStatus ()

Private Attributes

Formationsformations
bool bContLoop
Time m_timeLastSay

Detailed Description

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

Definition at line 59 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 62 of file Player.C.

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


Member Function Documentation

bool Player::amIAgentToSaySomething   [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 445 of file Player.C.

References WorldModel::getCurrentTime(), WorldModel::getRelativeDistance(), WorldModel::getTimeChangeInformation(), ServerSettings::getVisibleDistance(), OBJECT_BALL, BasicPlayer::SS, and BasicPlayer::WM.

Referenced by shallISaySomething().

void Player::attackerMainLoop   [private]
 

This is the main decision loop for an agent.

Definition at line 169 of file Player.C.

References deMeer5().

Referenced by mainLoop().

void Player::defenderMainLoop   [private]
 

This is the main decision loop for a defender.

Definition at line 157 of file Player.C.

References deMeer5().

Referenced by mainLoop().

void 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 and no opponent can intercept ball intercept the ball
  • else move to strategic position based on your home position and pos ball

Definition at line 184 of file Player.C.

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(), 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::isKickOffThem(), BasicPlayer::kickTo(), BasicPlayer::moveToPos(), OBJECT_BALL, OBJECT_SET_TEAMMATES, PITCH_LENGTH, BasicPlayer::PS, ActHandler::putCommandInQueue(), BasicPlayer::searchBall(), Formations::setFormation(), VecPosition::setX(), BasicPlayer::SS, BasicPlayer::teleportToPos(), BasicPlayer::turnBodyToObject(), BasicPlayer::turnBodyToPoint(), BasicPlayer::turnNeckToObject(), and BasicPlayer::WM.

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

void 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 284 of file Player.C.

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 571 of file Player.C.

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(), PlayerSettings::getPlayerWhenToTurnAngle(), SoccerTypes::getViewAngleFromStr(), SoccerTypes::getViewQualityFromStr(), Parse::gotoFirstNonSpace(), Parse::gotoFirstOccurenceOf(), SoccerCommand::iTimes, BasicPlayer::kickTo(), SoccerCommand::makeCommand(), OBJECT_SET_OPPONENTS, Parse::parseFirstDouble(), Parse::parseFirstInt(), 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().

void Player::goalieMainLoop   [private]
 

This is the main decision loop for the goalkeeper.

Definition at line 151 of file Player.C.

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 525 of file Player.C.

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 96 of file Player.C.

References BasicPlayer::ACT, attackerMainLoop(), bContLoop, defenderMainLoop(), formations, WorldModel::getCurrentCycle(), WorldModel::getCurrentTime(), WorldModel::getPlayerNumber(), Formations::getPlayerType(), WorldModel::getTimeLastSeeMessage(), goalieMainLoop(), WorldModel::iNrHoles, WorldModel::iNrOpponentsSeen, WorldModel::iNrTeammatesSeen, m_timeLastSay, midfielderMainLoop(), PT_ATTACKER, PT_ATTACKER_WING, PT_DEFENDER_SWEEPER, PT_DEFENDER_WING, PT_GOALKEEPER, PT_ILLEGAL, PT_MIDFIELDER_CENTER, PT_MIDFIELDER_WING, sayBallStatus(), ActHandler::sendCommandDirect(), ActHandler::sendCommands(), shallISaySomething(), WorldModel::updateAll(), WorldModel::waitForNewInformation(), and BasicPlayer::WM.

Referenced by main().

void Player::midfielderMainLoop   [private]
 

This is the main decision loop for a midfielder.

Definition at line 163 of file Player.C.

References deMeer5().

Referenced by mainLoop().

SoccerCommand Player::sayBallStatus   [private]
 

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

Definition at line 457 of file Player.C.

References BasicPlayer::communicate(), WorldModel::getGlobalPosition(), WorldModel::getGlobalVelocity(), VecPosition::getX(), VecPosition::getY(), MAX_SAY_MSG, min(), OBJECT_BALL, and BasicPlayer::WM.

Referenced by mainLoop().

bool Player::shallISaySomething   [private]
 

This method determines whether a player should say something.

Returns:
bool indicating whether the agent should say a message

Definition at line 431 of file Player.C.

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 542 of file Player.C.

Referenced by executeStringCommand().

void Player::test_only_update  
 

This method does nothing except updating the worldmodel after each arrival of a see or sense_body message. Using this test program it is possible to control the commands of the agent using the standard input and see the resulting behavior of the agent.

Definition at line 484 of file Player.C.

References bContLoop, WorldModel::updateAll(), WorldModel::waitForNewInformation(), and BasicPlayer::WM.

Referenced by main().


Member Data Documentation

bool Player::bContLoop [private]
 

is server is alive

Definition at line 62 of file Player.h.

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

Formations* Player::formations [private]
 

all formation information

Definition at line 61 of file Player.h.

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

Time Player::m_timeLastSay [private]
 

last time communicated

Definition at line 64 of file Player.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jul 2 10:19:20 2002 for UvA Trilearn 2002 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001