#include <Formations.h>
Public Member Functions | |
Formations (const char *strFile=NULL, FormationT ft=FT_ILLEGAL, int iNr=1) | |
void | show (ostream &os=cout) |
VecPosition | getStrategicPosition (int iPlayer, VecPosition posBall, double dMaxXInPlayMode, bool bInBallPossession=false, double dMaxYPercentage=0.75, FormationT ft=FT_ILLEGAL) |
bool | readFormations (const char *strFile) |
bool | setFormation (FormationT formation) |
FormationT | getFormation () const |
bool | setPlayerInFormation (int number) |
int | getPlayerInFormation (ObjectT obj=OBJECT_ILLEGAL) const |
PlayerT | getPlayerType (ObjectT obj, FormationT ft=FT_ILLEGAL) const |
PlayerT | getPlayerType (int iIndex=-1, FormationT ft=FT_ILLEGAL) const |
int | getPlayerInFormation () |
Private Attributes | |
FormationTypeInfo | formations [MAX_FORMATION_TYPES] |
FormationT | curFormation |
int | iPlayerInFormation |
Definition at line 173 of file Formations.h.
Formations::Formations | ( | const char * | strFile = NULL , |
|
FormationT | curFt = FT_ILLEGAL , |
|||
int | iNr = 1 | |||
) |
This is the constructor for the Formations class and needs as arguments a formation configuration file, the current formation and the number of the agent in this formation (normally at start-up this equals the player number).
strFile | string representation of the formation configuration file | |
curFt | current formation type (default FT_ILLEGAL) | |
iNr | number of the agent in this formation (default 1) |
Definition at line 448 of file Formations.cpp.
References curFormation, readFormations(), and setPlayerInFormation().
void Formations::show | ( | ostream & | os = cout |
) |
This methods prints all the information of the different formation types to the output stream os and furthermore prints the current formation and the role number of the agent in this formation.
os | output stream to which output is written. |
Definition at line 466 of file Formations.cpp.
References curFormation, formations, iPlayerInFormation, and MAX_FORMATION_TYPES.
VecPosition Formations::getStrategicPosition | ( | int | iPlayer, | |
VecPosition | posBall, | |||
double | dMaxXInPlayMode, | |||
bool | bInBallPossession = false , |
|||
double | dMaxYPercentage = 0.75 , |
|||
FormationT | ft = FT_ILLEGAL | |||
) |
This method returns the strategic position for a player. It calculates this information by taking the home position of the current role in the current formation and combines this with the position of the ball using the attraction values for the current player type. The attraction values defines the percentage of the ball coordinate that is added to the home position of the current player type. So when the x coordindate of the home position is 10.0, x coordinate ball is 20.0 and x attraction is 0.25. The x coordinate of the strategic position will become 10.0 + 0.25*20.0 = 15.0. When this value is smaller than the minimal x coordinate or larger than the maximal x coordinate, the coordinate is changed to this minimal or maximal coordinate respectively. Also when the behind ball value is set, the x coordinate of the strategic position is set to this ball coordinate. Furthermore when the strategic position is in front of the supplied argument dMaxXInPlayMode, the x coordinate is adjusted to this value. During normal play mode the supplied value is often the offside line.
iPlayer | player number in formation of which strategic position should be determined. | |
posBall | position of the ball | |
dMaxXInPlayMode,max | x coordinate allowed in current play mode. |
Definition at line 493 of file Formations.cpp.
References curFormation, formations, FT_ILLEGAL, PlayerTypeInfo::getAttrX(), PlayerTypeInfo::getAttrY(), PlayerTypeInfo::getBehindBall(), PlayerTypeInfo::getMaxX(), PlayerTypeInfo::getMinX(), FormationTypeInfo::getPosHome(), VecPosition::getX(), VecPosition::getY(), PITCH_WIDTH, and sign().
Referenced by WorldModel::getStrategicPosition().
bool Formations::readFormations | ( | const char * | strFile | ) |
This method reads the formations from the file 'strFile' and has the following format:
strFile | string representation of the file. |
Definition at line 543 of file Formations.cpp.
References formations, Parse::gotoFirstNonSpace(), MAX_PLAYER_TYPES, MAX_TEAMMATES, Parse::parseFirstDouble(), Parse::parseFirstInt(), PlayerTypeInfo::setAttrX(), PlayerTypeInfo::setAttrY(), PlayerTypeInfo::setBehindBall(), PlayerTypeInfo::setMaxX(), and PlayerTypeInfo::setMinX().
Referenced by Formations().
bool Formations::setFormation | ( | FormationT | formation | ) |
This method sets the current formation.
formation | new current formation |
Definition at line 644 of file Formations.cpp.
References curFormation.
Referenced by Player::deMeer5(), and Player::deMeer5_goalie().
FormationT Formations::getFormation | ( | ) | const |
This method returns the current formation.
Definition at line 652 of file Formations.cpp.
References curFormation.
Referenced by Player::deMeer5(), and Player::deMeer5_goalie().
bool Formations::setPlayerInFormation | ( | int | iNumber | ) |
This method sets the player number of the agent in the current formation to 'iNumber'.
iNumber | new player number for this agent |
Definition at line 661 of file Formations.cpp.
References iPlayerInFormation.
Referenced by Formations().
int Formations::getPlayerInFormation | ( | ObjectT | obj = OBJECT_ILLEGAL |
) | const |
This method returns the role number of the agent in the current formation
Definition at line 669 of file Formations.cpp.
References SoccerTypes::getIndex(), iPlayerInFormation, and OBJECT_ILLEGAL.
Referenced by WorldModel::getStrategicPosition(), and Player::Player().
PlayerT Formations::getPlayerType | ( | ObjectT | obj, | |
FormationT | ft = FT_ILLEGAL | |||
) | const |
This method returns the player type for the specified object
Definition at line 682 of file Formations.cpp.
References curFormation, formations, FT_ILLEGAL, SoccerTypes::getIndex(), and FormationTypeInfo::getPlayerType().
Referenced by WorldModel::getClosestPlayerInFormationTo(), WorldModel::getPlayerType(), Player::mainLoop(), Player::performPenalty(), and Player::Player().
PlayerT Formations::getPlayerType | ( | int | iIndex = -1 , |
|
FormationT | ft = FT_ILLEGAL | |||
) | const |
This method returns the player type for the agent in the current formation
Definition at line 692 of file Formations.cpp.
References curFormation, formations, FT_ILLEGAL, FormationTypeInfo::getPlayerType(), and iPlayerInFormation.
int Formations::getPlayerInFormation | ( | ) |
FormationTypeInfo Formations::formations[MAX_FORMATION_TYPES] [private] |
stored formations
Definition at line 175 of file Formations.h.
Referenced by getPlayerType(), getStrategicPosition(), readFormations(), and show().
FormationT Formations::curFormation [private] |
type of the current formation
Definition at line 176 of file Formations.h.
Referenced by Formations(), getFormation(), getPlayerType(), getStrategicPosition(), setFormation(), and show().
int Formations::iPlayerInFormation [private] |
role agent in current formation
Definition at line 177 of file Formations.h.
Referenced by getPlayerInFormation(), getPlayerType(), setPlayerInFormation(), and show().