formation_ngnet.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_NGNET_H
00033 #define RCSC_FORMATION_FORMATION_NGNET_H
00034 
00035 #include <rcsc/formation/formation.h>
00036 #include <rcsc/ann/ngnet.h>
00037 
00038 #include <boost/shared_ptr.hpp>
00039 
00040 #include <map>
00041 
00042 namespace rcsc {
00043 
00048 class FormationNGNet
00049     : public Formation {
00050 public:
00051 
00056     class Param {
00057     public:
00058         static const double PITCH_LENGTH;
00059         static const double PITCH_WIDTH;
00060 
00061     private:
00062 
00063         std::string M_role_name;
00064 
00065         NGNet M_net;
00066 
00067     public:
00068 
00072         Param();
00073 
00078         const
00079         std::string & roleName() const
00080           {
00081               return M_role_name;
00082           }
00083 
00088         NGNet & getNet()
00089           {
00090               return M_net;
00091           }
00092 
00097         const
00098         NGNet & net() const
00099           {
00100               return M_net;
00101           }
00102 
00109         Vector2D getPosition( const Vector2D & ball_pos,
00110                               const Formation::SideType type ) const;
00111 
00116         void setRoleName( const std::string & name )
00117           {
00118               M_role_name = name;
00119           }
00120 
00126         bool read( std::istream & is );
00127 
00133         std::ostream & print( std::ostream & os ) const;
00134 
00135     private:
00141         bool readRoleName( std::istream & is );
00142 
00148         bool readParam( std::istream & is );
00149 
00155         std::ostream & printRoleName( std::ostream & os ) const;
00156 
00162         std::ostream & printParam( std::ostream & os ) const;
00163 
00164     };
00165 
00166 
00167 private:
00168 
00170     std::map< int, boost::shared_ptr< Param > > M_param_map;
00171 
00172 public:
00173 
00177     FormationNGNet();
00178 
00179 
00184     static
00185     std::string name()
00186       {
00187           return std::string( "NGNet" );
00188       }
00189 
00194     static
00195     Formation * create()
00196       {
00197           return ( new FormationNGNet );
00198       }
00199 
00200     //--------------------------------------------------------------
00201 
00206     virtual
00207     std::string methodName() const
00208       {
00209           return FormationNGNet::name();
00210       }
00211 
00216     virtual
00217     Snapshot createDefaultParam();
00218 
00219 protected:
00220 
00227     virtual
00228     void createNewRole( const int unum,
00229                         const std::string & role_name,
00230                         const SideType type );
00231 
00237     virtual
00238     void setRoleName( const int unum,
00239                       const std::string & name );
00240 
00241 public:
00242 
00249     virtual
00250     std::string getRoleName( const int unum ) const;
00251 
00257     virtual
00258     Vector2D getPosition( const int unum,
00259                           const Vector2D & focus_point ) const;
00260 
00261     /*
00262       \brief get all positions for the current focus point
00263       \param focus_point current focus point, usually ball position
00264       \param positions contaner to store the result
00265      */
00266     virtual
00267     void getPositions( const Vector2D & focus_point,
00268                        std::vector< Vector2D > & positions ) const;
00269 
00274     virtual
00275     void train( const std::list< Snapshot > & train_data );
00276 
00282     bool read( std::istream & is );
00283 
00289     std::ostream & print( std::ostream & os ) const;
00290 
00291 
00292 private:
00293 
00299     bool readPlayers( std::istream & is );
00300 
00306     boost::shared_ptr< Param > getParam( const int unum );
00307 
00313     boost::shared_ptr< const Param > param( const int unum ) const;
00314 
00315 };
00316 
00317 }
00318 
00319 #endif

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