00001
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifndef RCSC_FORMATION_FORMATION_UVA_H
00033 #define RCSC_FORMATION_FORMATION_UVA_H
00034
00035 #include <iostream>
00036 #include <map>
00037
00038 #include <rcsc/geom/vector_2d.h>
00039 #include <rcsc/formation/formation.h>
00040
00041 namespace rcsc {
00042
00047 class FormationUvA
00048 : public Formation {
00049 public:
00050
00055 class RoleParam {
00056 std::string M_name;
00057 double M_attr_x;
00058 double M_attr_y;
00059 bool M_behind_ball;
00060 double M_min_x;
00061 double M_max_x;
00062
00063 public:
00064
00068 RoleParam();
00069
00079 RoleParam( const std::string & name,
00080 const double & attr_x,
00081 const double & atrr_y,
00082 const bool behind_ball,
00083 const double & min_x,
00084 const double & max_x );
00085
00096 const
00097 RoleParam & assign( const std::string & name,
00098 const double & attr_x,
00099 const double & attr_y,
00100 const bool behind_ball,
00101 const double & min_x,
00102 const double & max_y );
00103
00104
00105
00106
00107
00108 const
00109 std::string & name() const
00110 {
00111 return M_name;
00112 }
00113
00118 const
00119 double & attrX() const
00120 {
00121 return M_attr_x;
00122 }
00123
00128 const
00129 double & attrY() const
00130 {
00131 return M_attr_y;
00132 }
00133
00138 bool behindBall() const
00139 {
00140 return M_behind_ball;
00141 }
00142
00147 const
00148 double & minX() const
00149 {
00150 return M_min_x;
00151 }
00152
00157 const
00158 double & maxX() const
00159 {
00160 return M_max_x;
00161 }
00162
00168 std::ostream & print( std::ostream & os ) const;
00169 };
00170
00171
00172 private:
00173 std::string M_role_names[11];
00174 Vector2D M_home_pos[11];
00175
00176 std::map< std::string, RoleParam > M_role_params;
00177 double M_max_y_percentage;
00178 public:
00182 FormationUvA();
00183
00188 static
00189 std::string name()
00190 {
00191 return std::string( "UvA" );
00192 }
00193
00198 static
00199 Formation * create()
00200 {
00201 return ( new FormationUvA );
00202 }
00203
00204
00205
00210 virtual
00211 std::string methodName() const
00212 {
00213 return FormationUvA::name();
00214 }
00215
00220 virtual
00221 Snapshot createDefaultParam();
00222
00227 const
00228 double & maxYPercentage() const
00229 {
00230 return M_max_y_percentage;
00231 }
00232
00238 double setMaxYPercentage( const double & value )
00239 {
00240 double old_value = M_max_y_percentage;
00241 M_max_y_percentage = value;
00242 return old_value;
00243 }
00244
00245 protected:
00246
00253 virtual
00254 void createNewRole( const int unum,
00255 const std::string & role_name,
00256 const SideType type );
00257
00263 virtual
00264 void setRoleName( const int unum,
00265 const std::string & name );
00266
00267 public:
00268
00275 virtual
00276 std::string getRoleName( const int unum ) const;
00277
00283 virtual
00284 Vector2D getPosition( const int unum,
00285 const Vector2D & focus_point ) const;
00286
00287
00288
00289
00290
00291
00292 virtual
00293 void getPositions( const Vector2D & focus_point,
00294 std::vector< Vector2D > & positions ) const;
00295
00300 virtual
00301 void train( const std::list< Snapshot > & train_data );
00302
00308 virtual
00309 bool read( std::istream & is );
00310
00316 virtual
00317 std::ostream & print( std::ostream & os ) const;
00318
00319 private:
00320
00326 bool readPlayers( std::istream & is );
00327
00333 bool readRoles( std::istream & is );
00334
00335 };
00336
00337 }
00338
00339 #endif