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

Protected Attributes

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

Static Protected Attributes

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

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.

◆ 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_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_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_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_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_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.


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