SuperTuxKart
ai_base_lap_controller.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2010-2015 Joerg Henrichs
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 #ifndef HEADER_AI_BASE_LAP_CONTROLLER_HPP
19 #define HEADER_AI_BASE_LAP_CONTROLLER_HPP
20 
21 #include "karts/controller/ai_base_controller.hpp"
22 
23 class AIProperties;
24 class LinearWorld;
25 class Track;
26 class Vec3;
27 
33 {
34 protected:
40 
43 
45  std::vector<int> m_successor_index;
51  std::vector<int> m_next_node_index;
54  std::vector<std::vector<int> > m_all_look_aheads;
55 
56  virtual void update(int ticks);
57  virtual unsigned int getNextSector(unsigned int index);
58  virtual void newLap(int lap);
59  //virtual void setControllerName(const std::string &name);
60 
61  float steerToAngle (const unsigned int sector, const float angle);
62 
63  void computePath();
64  // ------------------------------------------------------------------------
66  virtual void raceFinished() {};
67 
68 public:
70  virtual ~AIBaseLapController() {};
71  virtual void reset();
72 }; // AIBaseLapController
73 
74 #endif
A base class for all AI karts.
Definition: ai_base_controller.hpp:33
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:34
virtual unsigned int getNextSector(unsigned int index)
Returns the next sector of the given sector index.
Definition: ai_base_lap_controller.cpp:234
LinearWorld * m_world
Keep a pointer to world.
Definition: ai_base_lap_controller.hpp:42
virtual void raceFinished()
Nothing special to do when the race is finished.
Definition: ai_base_lap_controller.hpp:66
virtual void update(int ticks)
Updates the ai base controller each time step.
Definition: ai_base_lap_controller.cpp:200
std::vector< int > m_successor_index
Which of the successors of a node was selected by the AI.
Definition: ai_base_lap_controller.hpp:45
A simple class that stores all AI related properties.
Definition: ai_properties.hpp:39
AIBaseLapController(AbstractKart *kart)
This is the base class for all AIs.
Definition: ai_base_lap_controller.cpp:86
int m_track_node
The current node the kart is on.
Definition: ai_base_lap_controller.hpp:39
float steerToAngle(const unsigned int sector, const float angle)
This function steers towards a given angle.
Definition: ai_base_lap_controller.cpp:246
std::vector< std::vector< int > > m_all_look_aheads
For each graph node this list contains a list of the next X graph nodes.
Definition: ai_base_lap_controller.hpp:54
std::vector< int > m_next_node_index
For each node in the graph this list contains the chosen next node.
Definition: ai_base_lap_controller.hpp:51
void computePath()
Computes a path for the AI to follow.
Definition: ai_base_lap_controller.cpp:141
A base class for all AI karts.
Definition: ai_base_lap_controller.hpp:32
Definition: linear_world.hpp:35
virtual void newLap(int lap)
Triggers a recomputation of the path to use, so that the AI does not always use the same way.
Definition: ai_base_lap_controller.cpp:124
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
Definition: track.hpp:96