Main Page   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 readFormations (const char *strFile)
bool setFormation (FormationT formation)
FormationT getFormation () const
bool setPlayerInFormation (int number)
int getPlayerInFormation () const
PlayerT getPlayerType () 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 164 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 443 of file Formations.C.

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 643 of file Formations.C.

References curFormation, and FormationT.

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

int Formations::getPlayerInFormation   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 660 of file Formations.C.

References iPlayerInFormation.

Referenced by Player::getStrategicPosition(), and Player::Player().

PlayerT Formations::getPlayerType   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 667 of file Formations.C.

References curFormation, formations, iPlayerInFormation, and PlayerT.

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

VecPosition Formations::getStrategicPosition int    iPlayer,
VecPosition    posBall,
double    dMaxXInPlayMode
 

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 488 of file Formations.C.

References curFormation, formations, PlayerTypeInfo::getAttrX(), PlayerTypeInfo::getAttrY(), PlayerTypeInfo::getBehindBall(), PlayerTypeInfo::getMaxX(), PlayerTypeInfo::getMinX(), VecPosition::getX(), VecPosition::getY(), and PITCH_WIDTH.

Referenced by Player::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
Parameters:
strFile  string representation of the file.
Returns:
bool when file was read in succesfully.

Definition at line 534 of file Formations.C.

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 635 of file Formations.C.

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 652 of file Formations.C.

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 461 of file Formations.C.

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 167 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 166 of file Formations.h.

Referenced by getPlayerType(), getStrategicPosition(), readFormations(), and show().

int Formations::iPlayerInFormation [private]
 

role agent in current formation

Definition at line 168 of file Formations.h.

Referenced by getPlayerInFormation(), getPlayerType(), setPlayerInFormation(), and show().


The documentation for this class was generated from the following files:
Generated on Thu Mar 7 00:37:54 2002 for UvA Trilearn 2001 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001