Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pong/PongAI.h @ 12129

Last change on this file since 12129 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.4 KB
RevLine 
[2839]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[8108]29/**
30    @file PongAI.h
31    @brief Declaration of the PongAI class.
32    @ingroup Pong
33*/
34
[2839]35#ifndef _PongAI_H__
36#define _PongAI_H__
37
[5725]38#include "pong/PongPrereqs.h"
[2839]39
[2860]40#include <list>
[8108]41
[3196]42#include "util/Math.h"
[5693]43#include "tools/interfaces/Tickable.h"
[8108]44
[5735]45#include "controllers/Controller.h"
[9667]46#include "PongBall.h"
[2839]47
48namespace orxonox
49{
[8108]50
51    /**
52    @brief
53        The PongAI is an artificial intelligence for the @ref orxonox::Pong "Pong" gametype.
54
55    @author
56        Fabian 'x3n' Landau
57
58    @ingroup Pong
59    */
[5725]60    class _PongExport PongAI : public Controller, public Tickable
[2839]61    {
62        public:
[9667]63            PongAI(Context* context); //!< Constructor. Registers and initializes the object.
[2860]64            virtual ~PongAI();
[2839]65
[2857]66            void setConfigValues();
67
[11071]68            virtual void tick(float dt) override; //!< Implements the behavior of the PongAI (i.e. its intelligence).
[2839]69
[8108]70            /**
71            @brief Set the ball for the AI.
72            @param ball A pointer to the ball.
73            */
[2839]74            void setPongBall(PongBall* ball)
75                { this->ball_ = ball; }
76
77        protected:
[8108]78            void calculateRandomOffset(); //!< Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
79            void calculateBallEndPosition(); //!< Calculate the end position the ball will be in.
80            void move(char direction, bool bUseDelay); //!< Determine the movement the AI will undertake.
81            void delayedMove(); //!< Is called, when a delayed move takes effect.
[2839]82
[9016]83            WeakPtr<PongBall> ball_; //!< A weak pointer to the ball.
[8108]84            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
85            float ballEndPosition_; //!< The calculated end position of the ball.
86            float randomOffset_; //!< A random offset to introduce random errors (weighted by the strength of the AI) into the AI's behavior.
87            bool bChangedRandomOffset_; //!< Helper boolean, to change the random offset more often.
88            float relHysteresisOffset_; //!< A hysteresis offset.
89            float strength_; //!< The strength of the AI. Ranging from 0 to 1.
[2860]90
[11071]91            std::list<std::pair<Timer*, char>> reactionTimers_; //!< A list of reaction timers and the directions that take effect when their timer expires.
[8108]92            char movement_; //!< The planned movement.
93            char oldMove_; //!< The previous movement.
94            bool bOscillationAvoidanceActive_; //!< Boolean, to avoid oscillations.
[2839]95    };
96}
97
98#endif /* _PongAI_H__ */
Note: See TracBrowser for help on using the repository browser.