22#ifndef HEADER_SKIDDING_AI_HPP
23#define HEADER_SKIDDING_AI_HPP
36# undef AI_DEBUG_NEW_FIND_NON_CRASHING
38# undef AI_DEBUG_CIRCLES
40# undef AI_DEBUG_KART_HEADING
42# undef AI_DEBUG_KART_AIM
46#include "karts/controller/ai_base_lap_controller.hpp"
47#include "race/race_manager.hpp"
48#include "tracks/drive_node.hpp"
49#include "utils/random_generator.hpp"
127 void clear() {m_road =
false; m_kart = -1;}
160 float m_time_since_stuck;
208 enum {SKID_PROBAB_NOT_YET, SKID_PROBAB_NO_SKID, SKID_PROBAB_SKID}
235 enum {PSA_DEFAULT, PSA_NEW}
245 irr::scene::ISceneNode *m_debug_sphere[4];
249 irr::scene::ISceneNode *m_item_sphere;
258 void handleRaceStart();
263 int last_node,
int item_skill);
265 const std::vector<const ItemState *> &items_to_collect,
266 const std::vector<const ItemState *> &items_to_avoid);
271 const std::vector<const ItemState *> &items_to_collect,
272 const std::vector<const ItemState *> &items_to_avoid);
273 void handleRescue(
const float dt);
280 bool steerToAvoid(
const std::vector<const ItemState *> &items_to_avoid,
281 const core::line3df &line_to_target,
284 const std::vector<const ItemState *> &items_to_avoid);
286 std::vector<const ItemState *> *items_to_avoid,
287 std::vector<const ItemState *> *items_to_collect);
289 void checkCrashes(
const Vec3& pos);
294 virtual bool canSkid(
float steer_fraction);
304 virtual void update (
int ticks);
305 virtual void reset ();
A base class for all AI karts.
Definition: ai_base_lap_controller.hpp:33
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
DirectionType
To indiciate in which direction the track is going: straight, left, right.
Definition: drive_node.hpp:37
Definition: item_manager.hpp:47
Contains the state information of an item, i.e.
Definition: item.hpp:53
Definition: linear_world.hpp:36
AISuperPower
True if the AI should have additional abbilities, e.g.
Definition: race_manager.hpp:134
A random number generator.
Definition: random_generator.hpp:34
This class is used for debugging.
Definition: show_curve.hpp:46
Definition: skidding_ai.hpp:121
This is the actual racing AI.
Definition: skidding_ai.hpp:117
RandomGenerator m_random_collect_item
A random number generator for collecting items.
Definition: skidding_ai.hpp:222
const ItemState * m_item_to_collect
If set an item that the AI should aim for.
Definition: skidding_ai.hpp:182
void determineTrackDirection()
Determines the direction of the track ahead of the kart: 0 indicates straight, +1 right turn,...
Definition: skidding_ai.cpp:2780
void handleSteering(float dt)
Decides in which direction to steer.
Definition: skidding_ai.cpp:370
void handleAccelerationAndBraking(int ticks)
Determines if the AI should accelerate or not, and if not if it should brake.
Definition: skidding_ai.cpp:1989
void evaluateItems(const ItemState *item, Vec3 kart_aim_direction, std::vector< const ItemState * > *items_to_avoid, std::vector< const ItemState * > *items_to_collect)
This subroutine decides if the specified item should be collected, avoided, or ignored.
Definition: skidding_ai.cpp:974
bool handleSelectedItem(Vec3 kart_aim_direction, Vec3 *aim_point)
This function is called when the AI is trying to hit an item that is pre-selected to be collected.
Definition: skidding_ai.cpp:786
bool m_really_collect_item
True if m_last_item_random was randomly selected to be collected.
Definition: skidding_ai.hpp:219
virtual bool canSkid(float steer_fraction)
Determines if the kart should skid.
Definition: skidding_ai.cpp:2899
unsigned int m_last_direction_node
The index of the last node with the same direction as the current node the kart is on.
Definition: skidding_ai.hpp:179
DriveNode::DirectionType m_current_track_direction
The direction of the track where the kart is on atm.
Definition: skidding_ai.hpp:166
float m_distance_leader
Distance to the leader kart (used only in FTL) If this kart is leader, contains a high value to avoid...
Definition: skidding_ai.hpp:151
virtual void setSteering(float angle, float dt)
Converts the steering angle to a lr steering in the range of -1 to 1.
Definition: skidding_ai.cpp:3029
void handleBraking(float max_turn_speed, float min_speed)
This function decides if the AI should brake.
Definition: skidding_ai.cpp:2069
void handleCurve()
If the kart is at/in a curve, determine the turn radius.
Definition: skidding_ai.cpp:2837
AbstractKart * m_kart_ahead
Pointer to the closest kart ahead of this kart.
Definition: skidding_ai.hpp:136
virtual void reset()
Resets the AI when a race is restarted.
Definition: skidding_ai.cpp:162
void findNonCrashingPointNew(Vec3 *result, int *last_node)
This is a new version of findNonCrashingPoint, which at this stage is slightly inferior (though faste...
Definition: skidding_ai.cpp:2584
void findNonCrashingPoint(Vec3 *result, int *last_node)
This is basically the original AI algorithm.
Definition: skidding_ai.cpp:2695
void handleSwatter(int item_skill)
Handle the swatter depending on the chosen strategy Level 2 : Use the swatter immediately after a wai...
Definition: skidding_ai.cpp:1681
void handleSwitch(int item_skill, const std::vector< const ItemState * > &items_to_collect, const std::vector< const ItemState * > &items_to_avoid)
Handle switch depending on the chosen strategy Level 2 : Use the switch after a wait time Level 3 : S...
Definition: skidding_ai.cpp:1742
void handleBubblegum(int item_skill, const std::vector< const ItemState * > &items_to_collect, const std::vector< const ItemState * > &items_to_avoid)
Handle bubblegum depending on the chosen strategy Level 2 : Use the shield immediately after a wait t...
Definition: skidding_ai.cpp:1299
enum SkiddingAI::@8 m_skid_probability_state
This implements a simple finite state machine: it starts in NOT_YET.
int computeSkill(SkillType type)
Returns the AI skill value used by the kart.
Definition: skidding_ai.cpp:2394
AbstractKart * m_kart_behind
Pointer to the closest kart behind this kart.
Definition: skidding_ai.hpp:143
Vec3 m_curve_center
Stores the center of the curve (if the kart is in a curve, otherwise undefined).
Definition: skidding_ai.hpp:174
float m_time_since_last_shot
Time an item has been collected and not used.
Definition: skidding_ai.hpp:158
float m_distance_to_player
Distance to the player, used for rubber-banding.
Definition: skidding_ai.hpp:189
bool steerToAvoid(const std::vector< const ItemState * > &items_to_avoid, const core::line3df &line_to_target, Vec3 *aim_point)
Decides if steering is necessary to avoid bad items.
Definition: skidding_ai.cpp:821
void handleNitroAndZipper(float max_safe_speed)
Decides wether to use nitro and zipper or not.
Definition: skidding_ai.cpp:2193
bool m_avoid_item_close
True if items to avoid are close by.
Definition: skidding_ai.hpp:186
void computeNearestKarts()
Determines the closest karts just behind and in front of this kart.
Definition: skidding_ai.cpp:1869
void handleItemCollectionAndAvoidance(Vec3 *aim_point, int last_node)
Decides if the currently selected aim at point (as determined by handleSteering) should be changed in...
Definition: skidding_ai.cpp:554
void handleBowling(int item_skill)
Handle the bowling ball depending on the chosen strategy Level 2 : Use the bowling ball against enemi...
Definition: skidding_ai.cpp:1600
int m_start_kart_crash_direction
Direction of crash: -1 = left, 1 = right, 0 = no crash.
Definition: skidding_ai.hpp:163
float m_current_curve_radius
The radius of the curve the kart is currently driving.
Definition: skidding_ai.hpp:170
virtual void update(int ticks)
This is the main entry point for the AI.
Definition: skidding_ai.cpp:225
int m_start_delay
The actual start delay used in ticks.
Definition: skidding_ai.hpp:155
int m_num_players_ahead
Number of players ahead, used for rubber-banding.
Definition: skidding_ai.hpp:192
enum SkiddingAI::@9 m_point_selection_algorithm
Determines the algorithm to use to select the point-to-aim-for There are two different Point Selectio...
RandomGenerator m_random_skid
A random number generator to decide if the AI should skid or not.
Definition: skidding_ai.hpp:198
float m_distance_behind
Distance to the kard behind.
Definition: skidding_ai.hpp:146
virtual unsigned int getNextSector(unsigned int index)
Returns the pre-computed successor of a graph node.
Definition: skidding_ai.cpp:215
void handleItems(const float dt, const Vec3 *aim_point, int last_node, int item_skill)
Handle all items depending on the chosen strategy.
Definition: skidding_ai.cpp:1081
const ItemState * m_last_item_random
The last item selected for collection, for which a probability was determined.
Definition: skidding_ai.hpp:216
void handleCake(int item_skill)
Handle cake depending on the chosen strategy Level 2 : Use the cake against any close vulnerable enem...
Definition: skidding_ai.cpp:1462
bool m_burster
This bool allows to make the AI use nitro by series of two bursts.
Definition: skidding_ai.hpp:195
float m_distance_ahead
Distance to the kart ahead.
Definition: skidding_ai.hpp:139
virtual const irr::core::stringw & getNamePostfix() const
Returns a name for the AI.
Definition: skidding_ai.cpp:203
SkillType
This is used by computeSkill to know what skill is used.
Definition: skidding_ai.hpp:212
bool hitBadItemWhenAimAt(const ItemState *item, const std::vector< const ItemState * > &items_to_avoid)
Returns true if the AI would hit any of the listed bad items when trying to drive towards the specifi...
Definition: skidding_ai.cpp:761
Definition: track.hpp:114
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35