Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 23, 2015, 7:44:20 AM (9 years ago)
Author:
gania
Message:

refactoring in process

Location:
code/branches/AI_HS15/src/orxonox/controllers
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h

    r10678 r10681  
    3838    {
    3939        public:
    40         DivisionController(Context* context);
    41         virtual ~DivisionController();
     40                DivisionController(Context* context);
     41                virtual ~DivisionController();
    4242
    43         //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     43                //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4444
     45                //Using british military aircraft formations
     46                enum FormationMode {VEE,FINGER4,DIAMOND, WALL};
     47                void setFormationMode(FormationMode val);
     48                inline FormationMode getFormationMode() const
     49                        { return this->formationMode_; }
     50                       
     51                        virtual void doFire();
    4552
     53                        //WAYPOINT FUNCTIONS`
     54            void addWaypoint(WorldEntity* waypoint);
     55            WorldEntity* getWaypoint(unsigned int index) const;
    4656
     57            inline void setAccuracy(float accuracy)
     58                { this->squaredaccuracy_ = accuracy*accuracy; }
     59            inline float getAccuracy() const
     60                { return sqrt(this->squaredaccuracy_); }
     61            void updatePointsOfInterest(std::string name, float distance);
     62            void manageWaypoints();
    4763
    4864        protected:
    4965
    50    
     66                //Target enemy, set by fleet controller.
     67                WeakPtr<Pawn> target_;
     68                bool bHasTargetPosition_;
     69                        Vector3 targetPosition_;
     70                        bool bHasTargetOrientation_;
     71                        Quaternion targetOrientation_;
     72                        void setTargetPosition(const Vector3& target);
     73                        void searchRandomTargetPosition();
     74
     75                        void setTargetOrientation(const Quaternion& orient);
     76                        void setTargetOrientation(Pawn* target);
     77
     78                        virtual void positionReached() {}
     79
     80                        static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack
     81
     82
     83                        void setTarget(Pawn* target);
     84
     85                        void searchNewTarget();
     86                    void forgetTarget();
     87
     88                        void targetDied();
     89                        bool bShooting_;
     90                        void aimAtTarget();
     91
     92            bool isCloseAtTarget(float distance) const;
     93            bool isLookingAtTarget(float angle) const;
     94
     95                //Has nothing to do with desiredRelativePosition_,
     96                //is set by fleet controller.
     97                Vector3* desiredAbsolutePosition_;
     98
     99                enum Maneuver {NONE, SPIN, TURN180};
     100                Maneuver maneuver_;
     101
     102                void moveToPosition(const Vector3& target);
     103                    void moveToTargetPosition();
     104                    void absoluteMoveToPosition(const Vector3& target);
     105                    void copyOrientation(const Quaternion& orient);
     106                    void copyTargetOrientation();
     107
     108                        void turn180Init();
     109                    void spinInit();
     110                    void spin();
     111                void turn180();
     112
     113                //WAYPOINT DATA
     114                std::vector<WeakPtr<WorldEntity> > waypoints_;
     115                size_t currentWaypoint_;
     116                float squaredaccuracy_;
     117                WorldEntity* defaultWaypoint_;
     118           
    51119        private:
    52120    };
  • code/branches/AI_HS15/src/orxonox/controllers/FleetController.h

    r10678 r10681  
    6767    {
    6868        public:
    69         FleetController(Context* context);
    70         virtual ~FleetController();
     69          FleetController(Context* context);
     70          virtual ~FleetController();
    7171
    7272
    73         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     73          virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    7474
    75         //gameGoal_ is to be set in XML
    76         //DOMINATE is default, makes AI want to be the only team alive
    77         //MOVE makes a fleet move to a set absolute position (set in variable goalPosition_)
    78         //DESTROY makes a fleet destroy a target (set in variable goalTarget_)
    79         //PROTECT makes a fleet protect a target (set in variable goalProtect_)
    80         enum GameGoal {DOMINATE, MOVE, DESTROY, PROTECT};
    81        
    82         /*void setGameGoal(GameGoal gameGoal)
    83            { this->gameGoal_ = gameGoal; }
    84         GameGoal getGameGoal() const
    85            { return this->gameGoal_; }
    86        
    87         void setGoalPosition(Vector3* goalPosition)
    88            { this->goalPosition_ = goalPosition; }
    89         Vector3* getGoalPosition() const
    90            { return this->goalPosition_; }
    91        
    92         void setGoalTarget(Pawn* goalTarget)
    93            { this->goalTarget_ = goalTarget; }
    94         Pawn* getGoalTarget() const
    95            { return this->goalTarget_; }
    96        
    97         void setGoalProtect(Pawn* goalProtect)
    98            { this->goalProtect_ = goalProtect; }
    99         Pawn* getGoalProtect() const
    100            { return this->goalProtect_; }*/
     75          //gameGoal_ is to be set in XML
     76          //DOMINATE is default, makes AI want to be the only team alive
     77          //MOVE makes a fleet move to a set absolute position (set in variable goalPosition_)
     78          //DESTROY makes a fleet destroy a target (set in variable goalTarget_)
     79          //PROTECT makes a fleet protect a target (set in variable goalProtect_)
     80          enum GameGoal {DOMINATE, MOVE, DESTROY, PROTECT};
     81         
     82          /*void setGameGoal(GameGoal gameGoal)
     83             { this->gameGoal_ = gameGoal; }
     84          GameGoal getGameGoal() const
     85             { return this->gameGoal_; }
     86         
     87          void setGoalPosition(Vector3* goalPosition)
     88             { this->goalPosition_ = goalPosition; }
     89          Vector3* getGoalPosition() const
     90             { return this->goalPosition_; }
     91         
     92          void setGoalTarget(Pawn* goalTarget)
     93             { this->goalTarget_ = goalTarget; }
     94          Pawn* getGoalTarget() const
     95             { return this->goalTarget_; }
     96         
     97          void setGoalProtect(Pawn* goalProtect)
     98             { this->goalProtect_ = goalProtect; }
     99          Pawn* getGoalProtect() const
     100             { return this->goalProtect_; }*/
    101101
    102102
  • code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc

    r10678 r10681  
    5959    }
    6060//**********************************************NEW
    61     void LeaderController::defaultBehaviour(float maxrand)
     61   /* void LeaderController::defaultBehaviour(float maxrand)
    6262    { 
    6363       
    64     }
     64    }*/
    6565
    6666}
  • code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h

    r10678 r10681  
    3838    {
    3939        public:
    40         LeaderController(Context* context);
    41         virtual ~LeaderController();
     40           
     41            LeaderController(Context* context);
     42            virtual ~LeaderController();
    4243
    43         virtual void tick(float dt); //<! Carrying out the targets set in action().
     44            virtual void tick(float dt); //<! Carrying out the targets set in action().
    4445
    4546        protected:
    46         virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
    47         void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
     47           
     48            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
     49            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
     50
     51
     52           
     53               
     54            enum Mode {KEEPFORMATION, ROCKET, KILLENEMY};
     55            Mode mode_;
     56
     57            //WEAPONSYSTEM DATA
     58            std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
     59            //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
     60            float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.)
     61            void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
     62            bool bSetupWorked; //<! If false, setupWeapons() is called.
     63            int getFiremode(std::string name);
     64
     65            void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost.
    4866
    4967        private:
    50         static const float ACTION_INTERVAL;
     68            static const float ACTION_INTERVAL;
    5169
    52         Timer actionTimer_; //<! Regularly calls action().
    53            
     70            Timer actionTimer_; //<! Regularly calls action().
     71              
    5472    };
    5573}
  • code/branches/AI_HS15/src/orxonox/controllers/SectionController.h

    r10678 r10681  
    3838    {
    3939        public:
    40         SectionController(Context* context);
    41         virtual ~SectionController();
     40            SectionController(Context* context);
     41            virtual ~SectionController();
    4242
    43         //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    44 
     43            //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4544
    4645
    4746
    4847        protected:
     48     
     49            //A division is the biggest block of spaceships.
     50            //In division one section is leading, the other one always stays on the same position
     51            //relative to the Leader of the leading section.
     52            //In section a Wingman always stays on same position relative to the Leader.
     53            //That position is desiredRelativePosition_
     54            Vector3* desiredRelativePosition_;
     55           
    4956
    50    
     57
     58            LeaderController* leader_;
     59            WingmanController* wingman_;
     60       
    5161        private:
    5262    };
  • code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc

    r10678 r10681  
    6565    }
    6666//**********************************************NEW
    67     void WingmanController::defaultBehaviour(float maxrand)
     67    /*void WingmanController::defaultBehaviour(float maxrand)
    6868    { 
    6969       
    70     }
     70    }*/
    7171
    7272}
  • code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h

    r10678 r10681  
    3131
    3232
    33 #include "SectionController.h"
     33#include "LeaderController.h"
    3434
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport WingmanController : public SectionController, public Tickable
     38    class _OrxonoxExport WingmanController : public LeaderController
    3939    {
    4040        public:
     
    4646        protected:
    4747            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
    48             void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
     48            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
    4949
    5050
     51                     
    5152        private:
    5253            static const float ACTION_INTERVAL;
Note: See TracChangeset for help on using the changeset viewer.