SuperTuxKart
ai_properties.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2012-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_AI_PROPERTIES_HPP
20 #define HEADER_AI_PROPERTIES_HPP
21 
22 #include "race/race_manager.hpp"
23 #include "utils/interpolation_array.hpp"
24 
25 #include <string>
26 #include <vector>
27 
28 class XMLNode;
29 
30 
40 {
41 public:
42  //LEAK_CHECK();
43 protected:
44  // Give them access to the members
45  friend class AIBaseController;
46  friend class AIBaseLapController;
47  friend class SkiddingAI;
48  friend class ArenaAI;
49  friend class TestAI;
50 
52  static float UNDEFINED;
53 
57 
62 
69 
73 
76 
79 
82  InterpolationArray m_last_speed_cap;
83 
86 
89 
93 
96 
99 
102 
108 
111 
114 
119 
124 
131 
133  std::string m_ident;
134 
135 public:
136 
138  void load(const XMLNode *skid_node);
139  void checkAllSet(const std::string &filename) const;
140  // ------------------------------------------------------------------------
143  float getSkiddingProbability(float distance) const
144  {
145  return m_skid_probability.get(distance);
146  } // getSkiddingProbability
147  // ------------------------------------------------------------------------
150  float getSpeedCap(float distance, int ai_position, int num_ai) const;
151 
152  // ------------------------------------------------------------------------
155  float getItemCollectProbability(float distance) const
156  {
157  return m_collect_item_probability.get(distance);
158  } // getItemcollectProbability
159  // ------------------------------------------------------------------------
162 }; // AIProperties
163 
164 
165 #endif
166 
167 /* EOF */
168 
void checkAllSet(const std::string &filename) const
Check if all AI properties are defined, and aborts if some are missing.
Definition: ai_properties.cpp:89
A base class for all AI karts.
Definition: ai_base_controller.hpp:33
Difficulty
Game difficulty.
Definition: race_manager.hpp:229
InterpolationArray m_collect_item_probability
To determine the probability of selecting an item.
Definition: ai_properties.hpp:85
int m_nitro_usage
How the AI uses nitro.
Definition: ai_properties.hpp:123
void load(const XMLNode *skid_node)
Loads the AI properties from an XML file.
Definition: ai_properties.cpp:56
float getItemCollectProbability(float distance) const
Returns the probability to collect an item depending on the distance to the first player kart...
Definition: ai_properties.hpp:155
float m_max_item_angle
Maximum direction change when trying to collect an item.
Definition: ai_properties.hpp:56
bool m_make_use_of_slipstream
True if the AI should avtively try to make use of slipstream.
Definition: ai_properties.hpp:101
static float UNDEFINED
Used to check that all values are defined in the xml file.
Definition: ai_properties.hpp:52
float m_max_item_angle_high_speed
Maximum direction change when trying to collect an item while being on high-speed (i...
Definition: ai_properties.hpp:61
A simple class that stores all AI related properties.
Definition: ai_properties.hpp:39
float m_false_start_probability
Probability of a false start.
Definition: ai_properties.hpp:92
int m_item_usage_skill
Determines the strategies used by the AI for items.
Definition: ai_properties.hpp:118
bool m_collect_avoid_items
Actively collect and avoid items.
Definition: ai_properties.hpp:110
This is a test version of the AI, which can be used to create new AIs, and compare them with the curr...
Definition: test_ai.hpp:74
bool disableSlipstreamUsage() const
Returns true if this kart should not even get a slipstream bonus.
Definition: ai_properties.hpp:161
bool m_disable_slipstream_usage
Used for low level AI to not give them a slipstream bonus.
Definition: ai_properties.hpp:107
float m_shield_incoming_radius
Distance at which a detected projectile triggers a shield.
Definition: ai_properties.hpp:88
float m_min_start_delay
Minimum start delay.
Definition: ai_properties.hpp:95
float m_max_start_delay
Maximum start delay.
Definition: ai_properties.hpp:98
InterpolationArray m_skid_probability
The array of (distance, skid_probability) points.
Definition: ai_properties.hpp:78
float m_time_full_steer
Time for AI karts to reach full steer angle (used to reduce shaking of karts).
Definition: ai_properties.hpp:72
This class manages a set of (x_i,y_i) points, x_i must be sorted.
Definition: interpolation_array.hpp:31
std::string m_ident
An identifier like &#39;easy&#39;, &#39;medium&#39; or &#39;hard&#39; for this data set.
Definition: ai_properties.hpp:133
float m_skidding_threshold
TODO: ONLY USE FOR OLD SKIDDING! CAN BE REMOVED once the new skidding works as expected.
Definition: ai_properties.hpp:130
utility class used to parse XML files
Definition: xml_node.hpp:47
A base class for all AI karts.
Definition: ai_base_lap_controller.hpp:32
float getSkiddingProbability(float distance) const
Returns the skidding probability dependent on the specified distance to the first player kart...
Definition: ai_properties.hpp:143
float getSpeedCap(float distance, int ai_position, int num_ai) const
Returns the fraction of maximum speed the AI should drive at, depending on the distance from the play...
Definition: ai_properties.cpp:128
float get(float x) const
Returns the interpolated Y value for a given x.
Definition: interpolation_array.hpp:101
float m_straight_length_for_zipper
Minimum length of a straight in order to activate a zipper.
Definition: ai_properties.hpp:75
bool m_handle_bomb
If the AI should actively try to pass on a bomb.
Definition: ai_properties.hpp:113
float m_bad_item_closeness_2
If a good item and a bad item are closer than this distance, a good item will be avoided (in order to...
Definition: ai_properties.hpp:68
InterpolationArray m_first_speed_cap
To cap maximum speed if the kart is ahead of the player.
Definition: ai_properties.hpp:81
A base class for AI that use navmesh to work.
Definition: arena_ai.hpp:41
This is the actual racing AI.
Definition: skidding_ai.hpp:116
AIProperties(RaceManager::Difficulty difficulty)
Constructor.
Definition: ai_properties.cpp:29