BasicCoach Class Reference

#include <BasicCoach.h>


Public Member Functions

 BasicCoach (ActHandler *a, WorldModel *wm, ServerSettings *ss, char *strTeamName, double dVersion, bool isTrainer)
virtual ~BasicCoach ()
virtual void mainLoopNormal ()
void substitutePlayer (int iPlayer, int iPlayerType)
void handleStdin ()
void showStringCommands (ostream &out)
bool executeStringCommand (char *str)

Protected Attributes

ActHandlerACT
WorldModelWM
ServerSettingsSS
HeteroPlayerSettings m_player_types [MAX_HETERO_PLAYERS]
bool bContLoop


Detailed Description

This class starts a simple coach, which actions are defined in the method mainLoop. It uses an ActHandler to send actions to the server and can receive information from the WorldModel. The declaration of the different methods are defined in BasicCoachTest.C and BasicCoach.C.

Definition at line 63 of file BasicCoach.h.


Constructor & Destructor Documentation

BasicCoach::BasicCoach ( ActHandler act,
WorldModel wm,
ServerSettings ss,
char *  strTeamName,
double  dVersion,
bool  isTrainer 
)

This is the constructor for the BasicCoach class and contains the arguments that are used to initialize a coach.

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
strTeamName team name of this player
dVersion version this basiccoach corresponds to
isTrainer indicates whether the coach is a trainer (offline coach) or an online coach (used during the match).

Definition at line 67 of file BasicCoach.cpp.

References ACT, bContLoop, MAX_MSG, ActHandler::sendMessage(), WorldModel::setTeamName(), SS, and WM.

BasicCoach::~BasicCoach (  )  [virtual]

Definition at line 87 of file BasicCoach.cpp.


Member Function Documentation

void BasicCoach::mainLoopNormal (  )  [virtual]

This method is the main loop of the coach. All sequence of actions are located in this method.

Definition at line 93 of file BasicCoach.cpp.

References ACT, bContLoop, WorldModel::getInfoHeteroPlayer(), WorldModel::getPlayMode(), ServerSettings::getSynchMode(), Time::getTime(), WorldModel::getTimeLastSeeGlobalMessage(), WorldModel::isConfidenceGood(), Logger::isInLogLevel(), Logger::log(), Log, WorldModel::logObjectInformation(), m_player_types, MAX_HETERO_PLAYERS, OBJECT_ILLEGAL, OBJECT_TEAMMATE_11, PM_TIME_OVER, ActHandler::sendMessageDirect(), SS, substitutePlayer(), WorldModel::waitForNewInformation(), and WM.

Referenced by main().

void BasicCoach::substitutePlayer ( int  iPlayer,
int  iPlayerType 
)

This method substitutes one player to the given player type and sends this command (using the ActHandler) to the soccer server.

Definition at line 160 of file BasicCoach.cpp.

References ACT, CMD_CHANGEPLAYER, SoccerCommand::makeCommand(), and ActHandler::sendCommandDirect().

Referenced by mainLoopNormal().

void BasicCoach::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 193 of file BasicCoach.cpp.

References bContLoop, executeStringCommand(), and MAX_MSG.

Referenced by stdin_callback().

void BasicCoach::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 214 of file BasicCoach.cpp.

bool BasicCoach::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 225 of file BasicCoach.cpp.

References ACT, bContLoop, Parse::parseFirstDouble(), Parse::parseFirstInt(), and ActHandler::sendMessage().

Referenced by handleStdin().


Field Documentation

ActHandler* BasicCoach::ACT [protected]

ActHandler to which commands can be sent

Definition at line 66 of file BasicCoach.h.

Referenced by BasicCoach(), executeStringCommand(), mainLoopNormal(), and substitutePlayer().

WorldModel* BasicCoach::WM [protected]

WorldModel that contains information of world

Definition at line 67 of file BasicCoach.h.

Referenced by BasicCoach(), and mainLoopNormal().

ServerSettings* BasicCoach::SS [protected]

All parameters used by the server

Definition at line 68 of file BasicCoach.h.

Referenced by BasicCoach(), and mainLoopNormal().

HeteroPlayerSettings BasicCoach::m_player_types[MAX_HETERO_PLAYERS] [protected]

Definition at line 70 of file BasicCoach.h.

Referenced by mainLoopNormal().

bool BasicCoach::bContLoop [protected]

bool to indicate whether to stop or continue

Definition at line 71 of file BasicCoach.h.

Referenced by BasicCoach(), executeStringCommand(), handleStdin(), and mainLoopNormal().


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