SuperTuxKart
Public Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
AIProperties Class Reference

A simple class that stores all AI related properties. More...

#include <ai_properties.hpp>

Public Member Functions

 AIProperties (RaceManager::Difficulty difficulty)
 Constructor. More...
 
void load (const XMLNode *skid_node)
 Loads the AI properties from an XML file. More...
 
void checkAllSet (const std::string &filename) const
 Check if all AI properties are defined, and aborts if some are missing. More...
 
float getSkiddingProbability (float distance) const
 Returns the skidding probability dependent on the specified distance to the first player kart. More...
 
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 player. More...
 
float getItemCollectProbability (float distance) const
 Returns the probability to collect an item depending on the distance to the first player kart. More...
 
bool disableSlipstreamUsage () const
 Returns true if this kart should not even get a slipstream bonus. More...
 

Protected Attributes

float m_max_item_angle
 Maximum direction change when trying to collect an item. More...
 
float m_max_item_angle_high_speed
 Maximum direction change when trying to collect an item while being on high-speed (i.e. More...
 
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 avoid the bad item). More...
 
float m_time_full_steer
 Time for AI karts to reach full steer angle (used to reduce shaking of karts). More...
 
float m_straight_length_for_zipper
 Minimum length of a straight in order to activate a zipper. More...
 
InterpolationArray m_skid_probability
 The array of (distance, skid_probability) points. More...
 
InterpolationArray m_first_speed_cap
 To cap maximum speed if the kart is ahead of the player. More...
 
InterpolationArray m_last_speed_cap
 
InterpolationArray m_collect_item_probability
 To determine the probability of selecting an item. More...
 
float m_shield_incoming_radius
 Distance at which a detected projectile triggers a shield. More...
 
float m_false_start_probability
 Probability of a false start. More...
 
float m_min_start_delay
 Minimum start delay. More...
 
float m_max_start_delay
 Maximum start delay. More...
 
bool m_make_use_of_slipstream
 True if the AI should avtively try to make use of slipstream. More...
 
bool m_disable_slipstream_usage
 Used for low level AI to not give them a slipstream bonus. More...
 
bool m_collect_avoid_items
 Actively collect and avoid items. More...
 
bool m_handle_bomb
 If the AI should actively try to pass on a bomb. More...
 
int m_item_usage_skill
 Determines the strategies used by the AI for items. More...
 
int m_nitro_usage
 How the AI uses nitro. More...
 
float m_skidding_threshold
 TODO: ONLY USE FOR OLD SKIDDING! CAN BE REMOVED once the new skidding works as expected. More...
 
std::string m_ident
 An identifier like 'easy', 'medium' or 'hard' for this data set. More...
 

Static Protected Attributes

static float UNDEFINED = -99.9f
 Used to check that all values are defined in the xml file. More...
 

Friends

class AIBaseController
 
class AIBaseLapController
 
class SkiddingAI
 
class ArenaAI
 
class TestAI
 

Detailed Description

A simple class that stores all AI related properties.

It acts as interface between kart_properties and AI (to avoid either passing very many individual variables, or making KartProperties a dependency of the AI). The AIs are friends of this class and so have access to its protected members.

Constructor & Destructor Documentation

◆ AIProperties()

AIProperties::AIProperties ( RaceManager::Difficulty  difficulty)

Constructor.

Sets all properties to the special UNDEFINED value.

Member Function Documentation

◆ checkAllSet()

void AIProperties::checkAllSet ( const std::string &  filename) const

Check if all AI properties are defined, and aborts if some are missing.

Parameters
filenameName of the file from which the properties are read. Only used for error messages.

◆ disableSlipstreamUsage()

bool AIProperties::disableSlipstreamUsage ( ) const
inline

Returns true if this kart should not even get a slipstream bonus.

◆ getItemCollectProbability()

float AIProperties::getItemCollectProbability ( float  distance) const
inline

Returns the probability to collect an item depending on the distance to the first player kart.

◆ getSkiddingProbability()

float AIProperties::getSkiddingProbability ( float  distance) const
inline

Returns the skidding probability dependent on the specified distance to the first player kart.

◆ getSpeedCap()

float AIProperties::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 player.

◆ load()

void AIProperties::load ( const XMLNode ai_node)

Loads the AI properties from an XML file.

Parameters
ai_nodeThe XML node containing all AI properties.

Member Data Documentation

◆ m_bad_item_closeness_2

float AIProperties::m_bad_item_closeness_2
protected

If a good item and a bad item are closer than this distance, a good item will be avoided (in order to avoid the bad item).

If the items are further apart, it is assumed that there is enough time to change steering direction.

◆ m_collect_avoid_items

bool AIProperties::m_collect_avoid_items
protected

Actively collect and avoid items.

◆ m_collect_item_probability

InterpolationArray AIProperties::m_collect_item_probability
protected

To determine the probability of selecting an item.

◆ m_disable_slipstream_usage

bool AIProperties::m_disable_slipstream_usage
protected

Used for low level AI to not give them a slipstream bonus.

Otherwise they tend to build 'trains' (AIs driving close behing each other and get slipstream bonus). Only for making the easy AI really easy.

◆ m_false_start_probability

float AIProperties::m_false_start_probability
protected

Probability of a false start.

Note that Nolok in boss battle will never have a false start.

◆ m_first_speed_cap

InterpolationArray AIProperties::m_first_speed_cap
protected

To cap maximum speed if the kart is ahead of the player.

◆ m_handle_bomb

bool AIProperties::m_handle_bomb
protected

If the AI should actively try to pass on a bomb.

◆ m_ident

std::string AIProperties::m_ident
protected

An identifier like 'easy', 'medium' or 'hard' for this data set.

◆ m_item_usage_skill

int AIProperties::m_item_usage_skill
protected

Determines the strategies used by the AI for items.

0 is no use, 1 is random use ; 2 to 5 use varying tactics, with 2 having the worst and 5 the best.

◆ m_make_use_of_slipstream

bool AIProperties::m_make_use_of_slipstream
protected

True if the AI should avtively try to make use of slipstream.

◆ m_max_item_angle

float AIProperties::m_max_item_angle
protected

Maximum direction change when trying to collect an item.

Items that are more than this away, will not even be considered.

◆ m_max_item_angle_high_speed

float AIProperties::m_max_item_angle_high_speed
protected

Maximum direction change when trying to collect an item while being on high-speed (i.e.

skidding bonus, nitro, ...). Items that are more than this away, will not even be considered.

◆ m_max_start_delay

float AIProperties::m_max_start_delay
protected

Maximum start delay.

◆ m_min_start_delay

float AIProperties::m_min_start_delay
protected

Minimum start delay.

◆ m_nitro_usage

int AIProperties::m_nitro_usage
protected

How the AI uses nitro.

0 correspond to no use ; 1 to immediate use 2 to 4 to various levels of mastery (the AI tries to accumulate a reserve and to use bursts whose size/spacing varies according to the level).

◆ m_shield_incoming_radius

float AIProperties::m_shield_incoming_radius
protected

Distance at which a detected projectile triggers a shield.

◆ m_skid_probability

InterpolationArray AIProperties::m_skid_probability
protected

The array of (distance, skid_probability) points.

◆ m_skidding_threshold

float AIProperties::m_skidding_threshold
protected

TODO: ONLY USE FOR OLD SKIDDING! CAN BE REMOVED once the new skidding works as expected.

The minimum steering angle at which the AI adds skidding. Lower values tend to improve the line the AI is driving. This is used to adjust for different AI levels.

◆ m_straight_length_for_zipper

float AIProperties::m_straight_length_for_zipper
protected

Minimum length of a straight in order to activate a zipper.

◆ m_time_full_steer

float AIProperties::m_time_full_steer
protected

Time for AI karts to reach full steer angle (used to reduce shaking of karts).

◆ UNDEFINED

float AIProperties::UNDEFINED = -99.9f
staticprotected

Used to check that all values are defined in the xml file.


The documentation for this class was generated from the following files: