Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 23, 2011, 9:57:54 PM (13 years ago)
Author:
dafrick
Message:

Merging changes from tetris branch into trunk, since they are also useful, there.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pong/PongAI.h

    r5929 r8108  
    2727 */
    2828
     29/**
     30    @file PongAI.h
     31    @brief Declaration of the PongAI class.
     32    @ingroup Pong
     33*/
     34
    2935#ifndef _PongAI_H__
    3036#define _PongAI_H__
     
    3339
    3440#include <list>
     41
    3542#include "util/Math.h"
    3643#include "tools/interfaces/Tickable.h"
     44
    3745#include "controllers/Controller.h"
    3846
    3947namespace orxonox
    4048{
     49
     50    /**
     51    @brief
     52        The PongAI is an artificial intelligence for the @ref orxonox::Pong "Pong" gametype.
     53
     54    @author
     55        Fabian 'x3n' Landau
     56
     57    @ingroup Pong
     58    */
    4159    class _PongExport PongAI : public Controller, public Tickable
    4260    {
    4361        public:
    44             PongAI(BaseObject* creator);
     62            PongAI(BaseObject* creator); //!< Constructor. Registers and initializes the object.
    4563            virtual ~PongAI();
    4664
    4765            void setConfigValues();
    4866
    49             virtual void tick(float dt);
     67            virtual void tick(float dt); //!< Implements the behavior of the PongAI (i.e. its intelligence).
    5068
     69            /**
     70            @brief Set the ball for the AI.
     71            @param ball A pointer to the ball.
     72            */
    5173            void setPongBall(PongBall* ball)
    5274                { this->ball_ = ball; }
    5375
    5476        protected:
    55             void calculateRandomOffset();
    56             void calculateBallEndPosition();
    57             void move(char direction, bool bUseDelay);
    58             void delayedMove();
     77            void calculateRandomOffset(); //!< Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
     78            void calculateBallEndPosition(); //!< Calculate the end position the ball will be in.
     79            void move(char direction, bool bUseDelay); //!< Determine the movement the AI will undertake.
     80            void delayedMove(); //!< Is called, when a delayed move takes effect.
    5981
    60             PongBall* ball_;
    61             Vector2 ballDirection_;
    62             float ballEndPosition_;
    63             float randomOffset_;
    64             bool bChangedRandomOffset_;
    65             float relHysteresisOffset_;
    66             float strength_;
     82            PongBall* ball_; //!< A pointer to the ball.
     83            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
     84            float ballEndPosition_; //!< The calculated end position of the ball.
     85            float randomOffset_; //!< A random offset to introduce random errors (weighted by the strength of the AI) into the AI's behavior.
     86            bool bChangedRandomOffset_; //!< Helper boolean, to change the random offset more often.
     87            float relHysteresisOffset_; //!< A hysteresis offset.
     88            float strength_; //!< The strength of the AI. Ranging from 0 to 1.
    6789
    68             std::list<std::pair<Timer*, char> > reactionTimers_;
    69             char movement_;
    70             char oldMove_;
    71             bool bOscillationAvoidanceActive_;
     90            std::list<std::pair<Timer*, char> > reactionTimers_; //!< A list of reaction timers and the directions that take effect when their timer expires.
     91            char movement_; //!< The planned movement.
     92            char oldMove_; //!< The previous movement.
     93            bool bOscillationAvoidanceActive_; //!< Boolean, to avoid oscillations.
    7294    };
    7395}
Note: See TracChangeset for help on using the changeset viewer.