#include <Player.h>
Inheritance diagram for Player:
Public Methods | |
Player (ActHandler *a, WorldModel *wm, ServerSettings *ss, PlayerSettings *cs, Formations *fs, char *strTeamName, double dVersion, int iReconnect=-1) | |
VecPosition | getStrategicPosition (int iPlayer=-1) |
void | mainLoop () |
void | deMeer5 () |
void | deMeer5_goalie () |
void | handleStdin () |
void | showStringCommands (ostream &out) |
bool | executeStringCommand (char *str) |
void | test_only_update () |
bool | shallISaySomething () |
bool | amIAgentToSaySomething () |
SoccerCommand | sayWorldStatus () |
Private Methods | |
void | goalieMainLoop () |
void | defenderMainLoop () |
void | midfielderMainLoop () |
void | attackerMainLoop () |
Private Attributes | |
Formations * | formations |
bool | bContLoop |
int | m_lastSay |
Definition at line 54 of file Player.h.
|
This is the constructor the Player class and calls the constructor of the superclass BasicPlayer.
Definition at line 58 of file Player.C. References BasicPlayer::ACT, bContLoop, formations, Formations::getPlayerInFormation(), Formations::getPlayerType(), m_lastSay, MAX_MSG, BasicPlayer::PS, PT_GOALKEEPER, ActHandler::sendMessage(), WorldModel::setTeamName(), BasicPlayer::SS, and BasicPlayer::WM. |
|
This method returns a boolean indicating whether I should communicate my world model to the other agents. This depends on the last sent message and a simple utility function that determines whether I am best positioned on the field.
Definition at line 665 of file Player.C. References WorldModel::getBallPos(), WorldModel::getPlayerNumber(), VecPosition::getX(), VecPosition::getY(), PITCH_LENGTH, and BasicPlayer::WM. Referenced by shallISaySomething(). |
|
This is the main decision loop for an agent. Definition at line 167 of file Player.C. References deMeer5(). Referenced by mainLoop(). |
|
This is the main decision loop for a defender. Definition at line 155 of file Player.C. References deMeer5(). Referenced by mainLoop(). |
|
|
|
|
This method determine the strategic position for the specified player. This is done using the Formations class. In this class all information about the current formation, player number in formation and other specific values are stored. The strategic position is based on the position of the ball. If the confidence in the position of the ball is lower than the threshold defined in PlayerSettings, it is assumed that the ball is at position (0,0).
Definition at line 434 of file Player.C. References formations, PlayerSettings::getBallConfThr(), WorldModel::getBallPos(), WorldModel::getConfidence(), WorldModel::getOffsideX(), Formations::getPlayerInFormation(), Formations::getStrategicPosition(), VecPosition::getX(), WorldModel::isGoalKickThem(), WorldModel::isOffsideUs(), min(), OBJECT_BALL, PENALTY_X, BasicPlayer::PS, and BasicPlayer::WM. Referenced by deMeer5(), and deMeer5_goalie(). |
|
This is the main decision loop for the goalkeeper. Definition at line 149 of file Player.C. References deMeer5_goalie(). Referenced by mainLoop(). |
|
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 468 of file Player.C. References executeStringCommand(), and MAX_MSG. Referenced by stdin_callback(). |
|
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 92 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_lastSay, midfielderMainLoop(), PT_ATTACKER, PT_ATTACKER_WING, PT_DEFENDER_SWEEPER, PT_DEFENDER_WING, PT_GOALKEEPER, PT_ILLEGAL, PT_MIDFIELDER_CENTER, PT_MIDFIELDER_WING, sayWorldStatus(), ActHandler::sendCommandDirect(), ActHandler::sendCommands(), shallISaySomething(), WorldModel::updateAll(), WorldModel::waitForNewInformation(), and BasicPlayer::WM. Referenced by main(). |
|
This is the main decision loop for a midfielder. Definition at line 161 of file Player.C. References deMeer5(). Referenced by mainLoop(). |
|
This method says the world status. This message is encoded to make sure the other teammates know which is the cycle of the message, the author of the message and that the message is originated from a teammate and not from an opponent. The world status is the abs pos and velocity of the author of the message and the ball and the global positions of all the known teammates and the opponents. The format is as follows (*=encoding): (say ***** my_x my_y my_vel_x my_vel_y (ball_x ball_y ball_vel_x ball_vel_y ball_conf) (team_nr pos_x pos_y conf ...) (opp_nr pos_x pos_y conf ...)) Some players in the worldmodel are known by player number, some not. Players of which the player number is not sure are located at the end of the message and have the nr -1.
Definition at line 707 of file Player.C. References CMD_SAY, WorldModel::getAgentGlobalPosition(), WorldModel::getAgentGlobalVelocity(), PlayerSettings::getBallConfThr(), WorldModel::getBallPos(), WorldModel::getConfidence(), WorldModel::getCurrentCycle(), WorldModel::getGlobalPosition(), WorldModel::getGlobalVelocity(), WorldModel::getOppGoalieType(), WorldModel::getPlayerNumber(), WorldModel::getSide(), VecPosition::getX(), VecPosition::getY(), WorldModel::isConfidenceGood(), WorldModel::isKnownPlayer(), MAX_OPPONENTS, MAX_SAY_MSG, MAX_TEAMMATES, OBJECT_BALL, OBJECT_OPPONENT_1, OBJECT_TEAMMATE_1, ObjectT, BasicPlayer::PS, SIDE_LEFT, and BasicPlayer::WM. Referenced by mainLoop(). |
|
This method determines whether a player should say something. This is based on several factors: 1. The difference with the last say message should be equal or larger than the server paramater hear_decay 2. Always say something when time is stopped 3. The outside player in the opposite rectangle in which the ball is located equals this agent.
Definition at line 650 of file Player.C. References amIAgentToSaySomething(), WorldModel::getCurrentCycle(), ServerSettings::getHearDecay(), m_lastSay, BasicPlayer::SS, and BasicPlayer::WM. Referenced by mainLoop(). |
|
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.
Definition at line 484 of file Player.C. Referenced by executeStringCommand(). |
|
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 821 of file Player.C. References bContLoop, WorldModel::updateAll(), WorldModel::waitForNewInformation(), and BasicPlayer::WM. Referenced by main(). |
|
is server is alive Definition at line 57 of file Player.h. Referenced by executeStringCommand(), mainLoop(), Player(), and test_only_update(). |
|
all formation information Definition at line 56 of file Player.h. Referenced by deMeer5(), deMeer5_goalie(), getStrategicPosition(), mainLoop(), and Player(). |
|
last cycle communicated Definition at line 59 of file Player.h. Referenced by mainLoop(), Player(), and shallISaySomething(). |