formation_uva.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
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           \brief get role name
00106           \return role name string
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       \brief get all positions for the current focus point
00289       \param focus_point current focus point, usually ball position
00290       \param positions contaner to store the result
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

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0