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

Formations Class Reference

#include <Formations.h>

Collaboration diagram for Formations:

Collaboration graph
[legend]
List of all members.

Public Methods

 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

Private Attributes

FormationTypeInfo formations [MAX_FORMATION_TYPES]
FormationT curFormation
int iPlayerInFormation

Detailed Description

This class is a container for all different Formation Types: it contains the information of all the formation types. Furthermore it contains two other values: the current formation type that is used by the agent and the role of the agent in the current formation. These two values fully specify the position of this player in the formation.

Definition at line 173 of file Formations.h.


Constructor & Destructor Documentation

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

Parameters:
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, FormationT, readFormations(), and setPlayerInFormation().


Member Function Documentation

FormationT Formations::getFormation   const
 

This method returns the current formation.

Returns:
current formation

Definition at line 652 of file Formations.cpp.

References curFormation, and FormationT.

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

int Formations::getPlayerInFormation ObjectT    obj = OBJECT_ILLEGAL const
 

This method returns the role number of the agent in the current formation

Returns:
player number for this agent in the current formation

Definition at line 669 of file Formations.cpp.

References SoccerTypes::getIndex(), iPlayerInFormation, OBJECT_ILLEGAL, and ObjectT.

Referenced by WorldModel::getStrategicPosition(), 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

Returns:
player type for the agent in the current formation

Definition at line 692 of file Formations.cpp.

References curFormation, formations, FormationT, FT_ILLEGAL, FormationTypeInfo::getPlayerType(), iPlayerInFormation, and PlayerT.

PlayerT Formations::getPlayerType ObjectT    obj,
FormationT    ft = FT_ILLEGAL
const
 

This method returns the player type for the specified object

Returns:
player type for the agent in the current formation

Definition at line 682 of file Formations.cpp.

References curFormation, formations, FormationT, FT_ILLEGAL, SoccerTypes::getIndex(), FormationTypeInfo::getPlayerType(), ObjectT, and PlayerT.

Referenced by WorldModel::getClosestPlayerInFormationTo(), WorldModel::getPlayerType(), Player::mainLoop(), Player::performPenalty(), and Player::Player().

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.

Parameters:
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, FormationT, FT_ILLEGAL, PlayerTypeInfo::getAttrX(), PlayerTypeInfo::getAttrY(), PlayerTypeInfo::getBehindBall(), PlayerTypeInfo::getMaxX(), PlayerTypeInfo::getMinX(), 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:

  • x coordinate of the home position for all the roles
  • y coordinate of the home position for all the roles
  • the player types for all the roles
  • the x attraction for all the player types
  • the y attraction for all the player types
  • indication whether to stay behind the ball for all the player types
  • minimal x coordinate for all the player types
  • maximal x coordinate for all the player types
  • extra y distance added to strat. pos. when in ball possession
Parameters:
strFile  string representation of the file.
Returns:
bool when file was read in succesfully.

Definition at line 543 of file Formations.cpp.

References formations, FormationTypeInfo::getPlayerTypeInfo(), Parse::gotoFirstNonSpace(), MAX_PLAYER_TYPES, MAX_TEAMMATES, Parse::parseFirstDouble(), Parse::parseFirstInt(), PlayerT, PlayerTypeInfo::setAttrX(), PlayerTypeInfo::setAttrY(), PlayerTypeInfo::setBehindBall(), PlayerTypeInfo::setMaxX(), PlayerTypeInfo::setMinX(), FormationTypeInfo::setPlayerType(), FormationTypeInfo::setXPosHome(), and FormationTypeInfo::setYPosHome().

Referenced by Formations().

bool Formations::setFormation FormationT    formation
 

This method sets the current formation.

Parameters:
formation  new current formation
Returns:
bool indicating whether the update was successful

Definition at line 644 of file Formations.cpp.

References curFormation, and FormationT.

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'.

Parameters:
iNumber  new player number for this agent
Returns:
bool indicating whether the update was succesfull

Definition at line 661 of file Formations.cpp.

References iPlayerInFormation.

Referenced by Formations().

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.

Parameters:
os  output stream to which output is written.

Definition at line 466 of file Formations.cpp.

References curFormation, formations, iPlayerInFormation, MAX_FORMATION_TYPES, and FormationTypeInfo::show().


Member Data Documentation

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

FormationTypeInfo Formations::formations[ MAX_FORMATION_TYPES ] [private]
 

stored formations

Definition at line 175 of file Formations.h.

Referenced by getPlayerType(), getStrategicPosition(), readFormations(), 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().


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