|
SuperTuxKart
|
A base class for all AI karts. More...
#include <ai_base_controller.hpp>

Public Member Functions | |
| AIBaseController (AbstractKart *kart) | |
| virtual void | reset () OVERRIDE |
| virtual bool | disableSlipstreamBonus () const OVERRIDE |
| Certain AI levels will not receive a slipstream bonus in order to be not as hard. | |
| virtual void | crashed (const Material *m) OVERRIDE |
| This is called when the kart crashed with the terrain. More... | |
| virtual void | crashed (const AbstractKart *k) OVERRIDE |
| virtual void | handleZipper (bool play_sound) OVERRIDE |
| virtual void | finishedRace (float time) OVERRIDE |
| Called whan this controller's kart finishes the last lap. | |
| virtual void | collectedItem (const ItemState &item, float previous_energy=0) OVERRIDE |
| virtual void | setPosition (int p) OVERRIDE |
| virtual bool | isPlayerController () const OVERRIDE |
| This function checks if this player is not an AI, i.e. More... | |
| virtual bool | isLocalPlayerController () const OVERRIDE |
| This function checks if this is a local player. More... | |
| virtual bool | action (PlayerAction action, int value, bool dry_run=false) OVERRIDE |
| Default: ignore actions. More... | |
| virtual void | skidBonusTriggered () OVERRIDE |
| virtual bool | saveState (BareNetworkString *buffer) const OVERRIDE |
| virtual void | rewindTo (BareNetworkString *buffer) OVERRIDE |
| void | setNetworkAI (bool val) |
| virtual void | update (int ticks) OVERRIDE |
Public Member Functions inherited from Controller | |
| Controller (AbstractKart *kart) | |
| Constructor, saves the kart pointer and a pointer to the KartControl of the kart. | |
| virtual void | rumble (float strength_low, float strength_high, uint16_t duration) |
| const std::string & | getControllerName () const |
| Returns the name of this controller. | |
| virtual void | newLap (int lap)=0 |
| Callback whenever a new lap is triggered. More... | |
| virtual KartControl * | getControls () |
| Get a pointer on the kart controls. | |
| void | setControls (KartControl *kc) |
| virtual bool | canGetAchievements () const |
| Only local players can get achievements. | |
| virtual core::stringw | getName (bool include_handicap_string=true) const |
| Display name of the controller. More... | |
| AbstractKart * | getKart () const |
| Returns the kart controlled by this controller. | |
Static Public Member Functions | |
| static void | enableDebug () |
| static void | setTestAI (int n) |
| static int | getTestAI () |
Protected Member Functions | |
| void | setControllerName (const std::string &name) OVERRIDE |
| In debug mode when the user specified –ai-debug on the command line set the name of the controller as on-screen text, so that the different AI controllers can be distinguished. More... | |
| float | steerToPoint (const Vec3 &point) |
| Computes the steering angle to reach a certain point. More... | |
| float | normalizeAngle (float angle) |
| Normalises an angle to be between -pi and _ pi. More... | |
| bool | isStuck () const |
| This can be called to detect if the kart is stuck (i.e. More... | |
| void | determineTurnRadius (const Vec3 &end, Vec3 *center, float *radius) const |
| Determine the center point and radius of a circle given two points on the circle and the tangent at the first point. More... | |
| virtual void | setSteering (float angle, float dt) |
| Converts the steering angle to a lr steering in the range of -1 to 1. More... | |
| virtual bool | canSkid (float steer_fraction)=0 |
| Return true if AI can skid now. | |
Protected Attributes | |
| bool | m_enabled_network_ai |
| float | m_kart_length |
| Length of the kart, storing it here saves many function calls. | |
| float | m_kart_width |
| Cache width of kart. | |
| Track * | m_track |
| Keep a pointer to the track to reduce calls. | |
| const AIProperties * | m_ai_properties |
| A pointer to the AI properties for this kart. | |
Protected Attributes inherited from Controller | |
| AbstractKart * | m_kart |
| Pointer to the kart that is controlled by this controller. | |
| KartControl * | m_controls |
| A pointer to the main controller, from which the kart takes it commands. | |
| std::string | m_controller_name |
| The name of the controller, mainly used for debugging purposes. | |
Static Protected Attributes | |
| static bool | m_ai_debug = false |
| static int | m_test_ai = 0 |
| Stores the '–test-ai=n' command line parameter: It indicates which fraction of the AIs are going to be the test AI: 1 means only to use the TestAI, 2 means every second AI will be test etc. More... | |
Private Attributes | |
| std::vector< int > | m_collision_ticks |
| Stores the last N times when a collision happened. More... | |
| bool | m_stuck |
| A flag that is set during the physics processing to indicate that this kart is stuck and needs to be rescued. | |
A base class for all AI karts.
This class basically provides some common low level functions.
|
inlinevirtual |
Default: ignore actions.
Only PlayerController get them.
Implements Controller.
Reimplemented in EndController.
|
virtual |
This is called when the kart crashed with the terrain.
This subroutine tries to detect if the AI is stuck by determining if a certain number of collisions happened in a certain amount of time, and if so rescues the kart. \paran m Pointer to the material that was hit (NULL if no specific material was used for the part of the track that was hit).
Implements Controller.
|
protected |
Determine the center point and radius of a circle given two points on the circle and the tangent at the first point.
This is done as follows:
| [in] | end | Second point on circle. |
| [out] | center | Center point of the circle (local coordinate). |
| [out] | radius | Radius of the circle. |
|
inlinevirtual |
This function checks if this is a local player.
A local player will get special graphical effects enabled, has a camera, and sound effects will be played with normal volume.
Implements Controller.
Reimplemented in EndController.
|
inlinevirtual |
This function checks if this player is not an AI, i.e.
it is either a a local or a remote/networked player. This is tested e.g. by the AI for rubber-banding.
Implements Controller.
Reimplemented in EndController.
|
inlineprotected |
This can be called to detect if the kart is stuck (i.e.
repeatedly hitting part of the track).
|
protected |
Normalises an angle to be between -pi and _ pi.
| angle | Angle to normalise. |
|
protectedvirtual |
In debug mode when the user specified –ai-debug on the command line set the name of the controller as on-screen text, so that the different AI controllers can be distinguished.
| name | Name of the controller. |
Reimplemented from Controller.
|
protectedvirtual |
Converts the steering angle to a lr steering in the range of -1 to 1.
If the steering angle is too great, it will also trigger skidding. This function uses a 'time till full steer' value specifying the time it takes for the wheel to reach full left/right steering similar to player karts when using a digital input device. The parameter is defined in the kart properties and helps somewhat to make AI karts more 'pushable' (since otherwise the karts counter-steer to fast). It also takes the effect of a plunger into account by restricting the actual steer angle to 50% of the maximum.
| angle | Steering angle. |
| dt | Time step. |
Reimplemented in TestAI, and SkiddingAI.
|
protected |
Computes the steering angle to reach a certain point.
The function will request steering by setting the steering angle to maximum steer angle times skidding factor.
| point | Point to steer towards. |
| skidding_factor | Increase factor for steering when skidding. |
|
private |
Stores the last N times when a collision happened.
This is used to detect when the AI is stuck, i.e. N collisions happened in a certain period of time.
|
staticprotected |
Stores the '–test-ai=n' command line parameter: It indicates which fraction of the AIs are going to be the test AI: 1 means only to use the TestAI, 2 means every second AI will be test etc.
Used for AI testing only.