Orxonox  0.0.5 Codename: Arcturus
PongAI.h
Go to the documentation of this file.
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 
35 #ifndef _PongAI_H__
36 #define _PongAI_H__
37 
38 #include "pong/PongPrereqs.h"
39 
40 #include <list>
41 
42 #include "util/Math.h"
44 
45 #include "controllers/Controller.h"
46 #include "PongBall.h"
47 
48 namespace orxonox
49 {
50 
60  class _PongExport PongAI : public Controller, public Tickable
61  {
62  public:
63  PongAI(Context* context);
64  virtual ~PongAI();
65 
66  void setConfigValues();
67 
68  virtual void tick(float dt) override;
69 
74  void setPongBall(PongBall* ball)
75  { this->ball_ = ball; }
76 
77  protected:
78  void calculateRandomOffset();
79  void calculateBallEndPosition();
80  void move(char direction, bool bUseDelay);
81  void delayedMove();
82 
84  Vector2 ballDirection_;
86  float randomOffset_;
89  float strength_;
90 
91  std::list<std::pair<Timer*, char>> reactionTimers_;
92  char movement_;
93  char oldMove_;
95  };
96 }
97 
98 #endif /* _PongAI_H__ */
The PongAI is an artificial intelligence for the Pong gametype.
Definition: PongAI.h:60
bool bChangedRandomOffset_
Helper boolean, to change the random offset more often.
Definition: PongAI.h:87
Declaration of the Tickable interface.
Vector2 ballDirection_
Vector to store the (x,z) direction in which the ball is flying.
Definition: PongAI.h:84
float ballEndPosition_
The calculated end position of the ball.
Definition: PongAI.h:85
char oldMove_
The previous movement.
Definition: PongAI.h:93
float randomOffset_
A random offset to introduce random errors (weighted by the strength of the AI) into the AI&#39;s behavio...
Definition: PongAI.h:86
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
Definition: CorePrereqs.h:236
char movement_
The planned movement.
Definition: PongAI.h:92
Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the ...
void setPongBall(PongBall *ball)
Set the ball for the AI.
Definition: PongAI.h:74
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
std::list< std::pair< Timer *, char > > reactionTimers_
A list of reaction timers and the directions that take effect when their timer expires.
Definition: PongAI.h:91
bool bOscillationAvoidanceActive_
Boolean, to avoid oscillations.
Definition: PongAI.h:94
float relHysteresisOffset_
A hysteresis offset.
Definition: PongAI.h:88
Definition: Context.h:45
This class manages the ball for Pong.
Definition: PongBall.h:59
Definition: Controller.h:38
float strength_
The strength of the AI. Ranging from 0 to 1.
Definition: PongAI.h:89
WeakPtr< PongBall > ball_
A weak pointer to the ball.
Definition: PongAI.h:83
#define _PongExport
Definition: PongPrereqs.h:60
Shared library macros, enums, constants and forward declarations for the pong module ...
The Tickable interface provides a tick(dt) function, that gets called every frame.
Definition: Tickable.h:52
Declaration of the PongBall class.