22#ifndef HEADER_TEST_AI_HPP
23#define HEADER_TEST_AI_HPP
37# undef AI_DEBUG_NEW_FIND_NON_CRASHING
39# undef AI_DEBUG_CIRCLES
41# undef AI_DEBUG_KART_HEADING
43# undef AI_DEBUG_KART_AIM
47#include "karts/controller/ai_base_lap_controller.hpp"
48#include "race/race_manager.hpp"
49#include "tracks/drive_node.hpp"
50#include "utils/random_generator.hpp"
85 void clear() {m_road =
false; m_kart = -1;}
112 float m_time_since_stuck;
154 enum {SKID_PROBAB_NOT_YET, SKID_PROBAB_NO_SKID, SKID_PROBAB_SKID}
180 enum {PSA_DEFAULT, PSA_FIXED, PSA_NEW}
189 irr::scene::ISceneNode *m_debug_sphere[4];
193 irr::scene::ISceneNode *m_item_sphere;
202 void handleRaceStart();
203 void handleAcceleration(
int ticks);
204 void handleSteering(
float dt);
205 void handleItems(
const float dt);
206 void handleRescue(
const float dt);
207 void handleBraking();
208 void handleNitroAndZipper();
209 void computeNearestKarts();
210 void handleItemCollectionAndAvoidance(
Vec3 *aim_point,
212 bool handleSelectedItem(
Vec3 kart_aim_direction,
Vec3 *aim_point);
213 bool steerToAvoid(
const std::vector<const ItemState *> &items_to_avoid,
214 const core::line3df &line_to_target,
216 bool hitBadItemWhenAimAt(
const ItemState *item,
217 const std::vector<const ItemState *> &items_to_avoid);
218 void evaluateItems(
const ItemState *item,
Vec3 kart_aim_direction,
219 std::vector<const ItemState *> *items_to_avoid,
220 std::vector<const ItemState *> *items_to_collect);
222 void checkCrashes(
const Vec3& pos);
223 void findNonCrashingPointFixed(
Vec3 *result,
int *last_node);
224 void findNonCrashingPointNew(
Vec3 *result,
int *last_node);
225 void findNonCrashingPoint(
Vec3 *result,
int *last_node);
227 void determineTrackDirection();
239 virtual void reset ();
240 virtual const irr::core::stringw& getNamePostfix()
const;
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
Contains the state information of an item, i.e.
Definition: item.hpp:53
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: test_ai.hpp:79
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:75
RandomGenerator m_random_skid
A random number generator to decide if the AI should skid or not.
Definition: test_ai.hpp:144
int m_start_kart_crash_direction
Direction of crash: -1 = left, 1 = right, 0 = no crash.
Definition: test_ai.hpp:115
enum TestAI::@10 m_skid_probability_state
This implements a simple finite state machine: it starts in NOT_YET.
virtual void setSteering(float angle, float dt)
Converts the steering angle to a lr steering in the range of -1 to 1.
virtual void update(int ticks)
Updates the ai base controller each time step.
RandomGenerator m_random_collect_item
A random number generator for collecting items.
Definition: test_ai.hpp:165
float m_current_curve_radius
The radius of the curve the kart is currently driving.
Definition: test_ai.hpp:122
enum TestAI::@11 m_point_selection_algorithm
Determines the algorithm to use to select the point-to-aim-for There are three different Point Select...
AbstractKart * m_kart_ahead
Pointer to the closest kart ahead of this kart.
Definition: test_ai.hpp:94
const ItemState * m_last_item_random
The last item selected for collection, for which a probability was determined.
Definition: test_ai.hpp:159
float m_distance_ahead
Distance to the kart ahead.
Definition: test_ai.hpp:97
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: test_ai.hpp:131
float m_distance_behind
Distance to the kard behind.
Definition: test_ai.hpp:104
virtual bool canSkid(float steer_fraction)
Return true if AI can skid now.
int m_start_delay
The actual start delay used in ticks.
Definition: test_ai.hpp:107
Vec3 m_curve_center
Stores the center of the curve (if the kart is in a curve, otherwise undefined).
Definition: test_ai.hpp:126
AbstractKart * m_kart_behind
Pointer to the closest kart behind this kart.
Definition: test_ai.hpp:101
DriveNode::DirectionType m_current_track_direction
The direction of the track where the kart is on atm.
Definition: test_ai.hpp:118
const ItemState * m_item_to_collect
If set an item that the AI should aim for.
Definition: test_ai.hpp:134
float m_distance_to_player
Distance to the player, used for rubber-banding.
Definition: test_ai.hpp:141
bool m_avoid_item_close
True if items to avoid are close by.
Definition: test_ai.hpp:138
bool m_really_collect_item
True if m_last_item_random was randomly selected to be collected.
Definition: test_ai.hpp:162
virtual unsigned int getNextSector(unsigned int index)
Returns the next sector of the given sector index.
float m_time_since_last_shot
Time an item has been collected and not used.
Definition: test_ai.hpp:110
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35