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

Formations.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000-2003, Jelle Kok, University of Amsterdam
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 1. Redistributions of source code must retain the above copyright notice, this
00009 list of conditions and the following disclaimer.
00010 
00011 2. Redistributions in binary form must reproduce the above copyright notice,
00012 this list of conditions and the following disclaimer in the documentation
00013 and/or other materials provided with the distribution.
00014 
00015 3. Neither the name of the University of Amsterdam nor the names of its
00016 contributors may be used to endorse or promote products derived from this
00017 software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00023 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00024 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00025 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00027 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 */
00030 
00068 #ifndef _FORMATIONS_
00069 #define _FORMATIONS_
00070 
00071 #include "SoccerTypes.h"  // PlayerT
00072 
00073 /*****************************************************************************/
00074 /********************** CLASS PLAYERTYPEINFO *********************************/
00075 /*****************************************************************************/
00076 
00094 class PlayerTypeInfo
00095 {
00096   PlayerT playerType; 
00097   double  dAttrX;     
00098   double  dAttrY;     
00099   double  dMinX;      
00100   double  dMaxX;      
00101   bool    bBehindBall;
00103 public:
00104   PlayerTypeInfo( );
00105   PlayerTypeInfo( PlayerT, double, double, double, double, bool );
00106 
00107   // method to set all the values at once and displaying them all
00108   bool    setValues( PlayerT, double, double, double, double, bool  );
00109   void    show     ( ostream &os = cout                            );
00110 
00111   // standard get and set methods to individually set all the values
00112   bool    setPlayerType    ( PlayerT type  );
00113   PlayerT getPlayerType    (               ) const;
00114   bool    setAttrX         ( double  attrX );
00115   double  getAttrX         (               ) const;
00116   bool    setAttrY         ( double  attrY );
00117   double  getAttrY         (               ) const;
00118   bool    setMinX          ( double  minX  );
00119   double  getMinX          (               ) const;
00120   bool    setMaxX          ( double  maxX  );
00121   double  getMaxX          (               ) const;
00122   bool    setBehindBall    ( bool    b     );
00123   bool    getBehindBall    (               ) const;
00124 
00125 };
00126 
00127 
00128 /*****************************************************************************/
00129 /********************** CLASS FORMATIONTYPEINFO ******************************/
00130 /*****************************************************************************/
00131 
00138 class FormationTypeInfo
00139 {
00140   FormationT      formationType;               
00141   VecPosition     posHome[ MAX_TEAMMATES ];    
00142   PlayerT         playerType[ MAX_TEAMMATES ]; 
00143   PlayerTypeInfo  playerTypeInfo[ MAX_PLAYER_TYPES ]; 
00145 public:
00146   FormationTypeInfo(                    );
00147   void show(         ostream &os = cout );
00148 
00149   // get and set methods to get information for a player in this formation
00150   bool            setFormationType         ( FormationT  type                );
00151   FormationT      getFormationType         (                            ) const;
00152   bool            setPosHome               ( VecPosition pos,     int atIndex);
00153   bool            setXPosHome              ( double      x,       int atIndex);
00154   bool            setYPosHome              ( double      y,       int atIndex);
00155   VecPosition     getPosHome               ( int         atIndex       ) const;
00156   bool            setPlayerType            ( PlayerT     type,    int atIndex);
00157   PlayerT         getPlayerType            ( int         atIndex       ) const;
00158   bool            setPlayerTypeInfo        ( PlayerTypeInfo info, int atIndex);
00159   PlayerTypeInfo* getPlayerTypeInfo        ( int         atIndex             );
00160   PlayerTypeInfo* getPlayerTypeInfoOfPlayer( int         iPlayerInFormation  );
00161 };
00162 
00163 /*****************************************************************************/
00164 /********************** CLASS FORMATIONS *************************************/
00165 /*****************************************************************************/
00166 
00173 class Formations
00174 {
00175   FormationTypeInfo formations[ MAX_FORMATION_TYPES ]; 
00176   FormationT        curFormation;       
00177   int               iPlayerInFormation; 
00178 public:
00179   Formations( const char *strFile = NULL, FormationT ft=FT_ILLEGAL, int iNr=1);
00180   void show ( ostream &os = cout );
00181 
00182   // method to get the strategic position depending on different factors
00183   VecPosition getStrategicPosition( int         iPlayer,
00184                                     VecPosition posBall,
00185                                     double      dMaxXInPlayMode,
00186                                     bool        bInBallPossession = false,
00187                                     double      dMaxYPercentage = 0.75,
00188             FormationT  ft = FT_ILLEGAL );
00189 
00190   // method to read the formations from a formation configuration file.
00191   bool        readFormations      ( const char *strFile         );
00192 
00193   // standard get and set methods for the different member variables
00194   bool        setFormation        ( FormationT formation            );
00195   FormationT  getFormation        (                                 ) const;
00196   bool        setPlayerInFormation( int number                      );
00197   int         getPlayerInFormation( ObjectT    obj = OBJECT_ILLEGAL ) const;   
00198   PlayerT     getPlayerType       ( ObjectT    obj,
00199             FormationT ft = FT_ILLEGAL      ) const;
00200   PlayerT     getPlayerType       ( int        iIndex = -1,
00201             FormationT ft = FT_ILLEGAL      ) const;
00202 };
00203 
00204 #endif

Generated on Fri Nov 7 11:45:39 2003 for UvA Trilearn 2003 Base Code by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001