Added AI tweaks (adjusting curve speed and angle

depending on track). Details in wiki.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1513 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-02-18 04:16:57 +00:00
parent 720d31edc5
commit 930a1ef2b5
18 changed files with 81 additions and 44 deletions

View File

@ -1,11 +1,13 @@
;; -*- mode: lisp -*- ;; -*- mode: lisp -*-
(tuxkart-track (tuxkart-track
(name "On the Beach") (name "On the Beach")
(description "Created by Ingo Ruhnke") (description "Created by Ingo Ruhnke")
(music "oggs/CaribbeanMusic.ogg") (music "oggs/CaribbeanMusic.ogg")
(screenshot "sshot-beach.rgb") (screenshot "sshot-beach.rgb")
(topview "topview-beach.rgb") (topview "topview-beach.rgb")
(AI-curve-speed-adjust 2.0)
(AI-angle-adjust 2.7)
) )
;; EOF ;; ;; EOF ;;

View File

@ -6,6 +6,8 @@
(music "oggs/Lava_Lagoon_2.ogg") (music "oggs/Lava_Lagoon_2.ogg")
(screenshot "sshot-bsodcastle.rgb") (screenshot "sshot-bsodcastle.rgb")
(topview "topview-bsodcastle.rgb") (topview "topview-bsodcastle.rgb")
(AI-curve-speed-adjust 2.0)
(AI-angle-adjust 2.0)
) )
;; EOF ;; ;; EOF ;;

View File

@ -6,6 +6,8 @@
(music "oggs/tk2.ogg") (music "oggs/tk2.ogg")
(screenshot "sshot-geekopeak.rgb") (screenshot "sshot-geekopeak.rgb")
(topview "topview-geekopeak.rgb") (topview "topview-geekopeak.rgb")
(AI-curve-speed-adjust 2.0)
(AI-angle-adjust 4.0)
) )
;; EOF ;; ;; EOF ;;

View File

@ -7,6 +7,8 @@
(music "oggs/another_caribbean_beat.ogg") (music "oggs/another_caribbean_beat.ogg")
(screenshot "sshot-gownsbow.rgb") (screenshot "sshot-gownsbow.rgb")
(topview "topview-gownsbow.rgb") (topview "topview-gownsbow.rgb")
(AI-curve-speed-adjust 1.3)
(AI-angle-adjust 2.3)
) )
;; EOF ;; ;; EOF ;;

View File

@ -9,7 +9,8 @@
(start-heading 0.0 3.7 9.5 11.5 15.1 17.0 20.2 22.0 26.0 36.0 ) (start-heading 0.0 3.7 9.5 11.5 15.1 17.0 20.2 22.0 26.0 36.0 )
(start-x -1.2 1.6 -0.9 2.3 0.0 3.4 1.2 4.2 2.6 6.2 ) (start-x -1.2 1.6 -0.9 2.3 0.0 3.4 1.2 4.2 2.6 6.2 )
(start-y -0.5 -1.5 -3.8 -5.0 -7.0 -8.0 -10.4 -10.9 -13.4 -14.1 ) (start-y -0.5 -1.5 -3.8 -5.0 -7.0 -8.0 -10.4 -10.9 -13.4 -14.1 )
(AI-curve-speed-adjust 1.7)
(AI-angle-adjust 1.7)
) )
;; EOF ;; ;; EOF ;;

View File

@ -6,6 +6,8 @@
(music "oggs/tk2.ogg") (music "oggs/tk2.ogg")
(screenshot "sshot-lighthouse.rgb") (screenshot "sshot-lighthouse.rgb")
(topview "topview-lighthouse.rgb") (topview "topview-lighthouse.rgb")
(AI-curve-speed-adjust 1.7)
(AI-angle-adjust 1.7)
) )
;; EOF ;; ;; EOF ;;

View File

@ -18,6 +18,8 @@
(music "oggs/tk5a.ogg") (music "oggs/tk5a.ogg")
(screenshot "sshot-littlevolcano.rgb") (screenshot "sshot-littlevolcano.rgb")
(topview "topview-littlevolcano.rgb") (topview "topview-littlevolcano.rgb")
(AI-curve-speed-adjust 3.0)
(AI-angle-adjust 3.3)
) )
;; EOF ;; ;; EOF ;;

View File

@ -6,6 +6,8 @@
(music "oggs/Boom_boom_boom.ogg") (music "oggs/Boom_boom_boom.ogg")
(screenshot "sshot-olivermath.rgb") (screenshot "sshot-olivermath.rgb")
(topview "topview-olivermath.rgb") (topview "topview-olivermath.rgb")
(AI-curve-speed-adjust 1.3)
(AI-angle-adjust 1.7)
) )
;; EOF ;; ;; EOF ;;

View File

@ -6,6 +6,8 @@
(music "oggs/tk5a.ogg" "oggs/tk2.ogg") (music "oggs/tk5a.ogg" "oggs/tk2.ogg")
(screenshot "sshot-race.rgb") (screenshot "sshot-race.rgb")
(topview "topview-race.rgb") (topview "topview-race.rgb")
(AI-curve-speed-adjust 1.3)
(AI-angle-adjust 2.0)
) )
;; EOF ;; ;; EOF ;;

View File

@ -6,6 +6,8 @@
(music "oggs/desert_dunes.ogg" "oggs/tk7.ogg") (music "oggs/desert_dunes.ogg" "oggs/tk7.ogg")
(screenshot "sshot-sandtrack.rgb") (screenshot "sshot-sandtrack.rgb")
(topview "topview-sandtrack.rgb") (topview "topview-sandtrack.rgb")
(AI-curve-speed-adjust 1.0)
(AI-angle-adjust 3.0)
) )
;; EOF ;; ;; EOF ;;

View File

@ -7,6 +7,8 @@
(music "oggs/Ethereal_Spectrum_\(ver_loop\).ogg") (music "oggs/Ethereal_Spectrum_\(ver_loop\).ogg")
(screenshot "sshot-startrack.rgb") (screenshot "sshot-startrack.rgb")
(topview "topview-startrack.rgb") (topview "topview-startrack.rgb")
(AI-curve-speed-adjust 1.7)
(AI-angle-adjust 2.0)
) )
;; EOF ;; ;; EOF ;;

View File

@ -18,6 +18,8 @@
(music "oggs/tuxr.ogg") (music "oggs/tuxr.ogg")
(screenshot "sshot-subseatrack.rgb") (screenshot "sshot-subseatrack.rgb")
(topview "topview-subseatrack.rgb") (topview "topview-subseatrack.rgb")
(AI-curve-speed-adjust 2.3)
(AI-angle-adjust 4.0)
) )
;; EOF ;; ;; EOF ;;

View File

@ -9,6 +9,8 @@
(start-heading -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 ) (start-heading -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 )
(start-x 0.1 -3.3 -1.5 -4.8 -3.0 -6.3 -4.5 -7.8 -6.0 -9.3 ) (start-x 0.1 -3.3 -1.5 -4.8 -3.0 -6.3 -4.5 -7.8 -6.0 -9.3 )
(start-y -2.0 -1.8 -4.6 -4.4 -7.2 -7.0 -9.8 -9.6 -12.4 -12.2 ) (start-y -2.0 -1.8 -4.6 -4.4 -7.2 -7.0 -9.8 -9.6 -12.4 -12.2 )
(AI-curve-speed-adjust 1.7)
(AI-angle-adjust 2.3)
) )

View File

@ -6,6 +6,8 @@
(music "oggs/Boom_boom_boom.ogg") (music "oggs/Boom_boom_boom.ogg")
(screenshot "sshot-volcano.rgb") (screenshot "sshot-volcano.rgb")
(topview "topview-volcano.rgb") (topview "topview-volcano.rgb")
(AI-curve-speed-adjust 2.0)
(AI-angle-adjust 2.3)
) )
;; EOF ;; ;; EOF ;;

View File

@ -170,8 +170,10 @@ void DefaultRobot::handle_braking()
//Brake if the kart's speed is bigger than the speed we need //Brake if the kart's speed is bigger than the speed we need
//to go through the curve at the widest angle, or if the kart //to go through the curve at the widest angle, or if the kart
//is not going straight in relation to the road. //is not going straight in relation to the road.
if(getVelocityLC().getY() > m_curve_target_speed || float angle_adjust = world->m_track->getAIAngleAdjustment();
kart_ang_diff > MIN_TRACK_ANGLE ) float speed_adjust = world->m_track->getAICurveSpeedAdjustment();
if(getVelocityLC().getY() > speed_adjust*m_curve_target_speed ||
kart_ang_diff > angle_adjust*MIN_TRACK_ANGLE )
{ {
#ifdef AI_DEBUG #ifdef AI_DEBUG
std::cout << "BRAKING" << std::endl; std::cout << "BRAKING" << std::endl;

View File

@ -777,10 +777,12 @@ void Track::loadTrack(std::string filename_)
// Default values // Default values
m_use_fog = false; m_use_fog = false;
sgSetVec4 ( m_fog_color , 0.3f, 0.7f, 0.9f, 1.0f ) ; sgSetVec4 ( m_fog_color , 0.3f, 0.7f, 0.9f, 1.0f ) ;
m_fog_density = 1.0f/100.0f; m_fog_density = 1.0f/100.0f;
m_fog_start = 0.0f; m_fog_start = 0.0f;
m_fog_end = 1000.0f; m_fog_end = 1000.0f;
m_gravity = 9.80665f; m_gravity = 9.80665f;
m_AI_angle_adjustment = 1.0f;
m_AI_curve_speed_adjustment = 1.0f;
sgSetVec3 ( m_sun_position, 0.4f, 0.4f, 0.4f ); sgSetVec3 ( m_sun_position, 0.4f, 0.4f, 0.4f );
sgSetVec4 ( m_sky_color, 0.3f, 0.7f, 0.9f, 1.0f ); sgSetVec4 ( m_sky_color, 0.3f, 0.7f, 0.9f, 1.0f );
@ -803,29 +805,30 @@ void Track::loadTrack(std::string filename_)
throw std::runtime_error(msg); throw std::runtime_error(msg);
} }
LISP->get ("name", m_name); LISP->get ("name", m_name);
LISP->get ("description", m_description); LISP->get ("description", m_description);
LISP->getVector("music", m_music_filenames); LISP->getVector("music", m_music_filenames);
LISP->get ("herring", m_herring_style); LISP->get ("herring", m_herring_style);
LISP->get ("screenshot", m_screenshot); LISP->get ("screenshot", m_screenshot);
LISP->get ("topview", m_top_view); LISP->get ("topview", m_top_view);
LISP->get ("sky-color", m_sky_color); LISP->get ("sky-color", m_sky_color);
LISP->getVector("start-x", m_start_x); LISP->getVector("start-x", m_start_x);
LISP->getVector("start-y", m_start_y); LISP->getVector("start-y", m_start_y);
LISP->getVector("start-z", m_start_z); LISP->getVector("start-z", m_start_z);
LISP->getVector("start-heading", m_start_heading); LISP->getVector("start-heading", m_start_heading);
LISP->get ("use-fog", m_use_fog);
LISP->get ("fog-color", m_fog_color);
LISP->get ("fog-density", m_fog_density);
LISP->get ("fog-start", m_fog_start);
LISP->get ("fog-end", m_fog_end);
LISP->get ("sun-position", m_sun_position);
LISP->get ("sun-ambient", m_ambient_col);
LISP->get ("sun-specular", m_specular_col);
LISP->get ("sun-diffuse", m_diffuse_col);
LISP->get ("gravity", m_gravity);
LISP->get ("AI-angle-adjust", m_AI_angle_adjustment);
LISP->get ("AI-curve-speed-adjust", m_AI_curve_speed_adjustment);
LISP->get ("use-fog", m_use_fog);
LISP->get ("fog-color", m_fog_color);
LISP->get ("fog-density", m_fog_density);
LISP->get ("fog-start", m_fog_start);
LISP->get ("fog-end", m_fog_end);
LISP->get ("sun-position", m_sun_position);
LISP->get ("sun-ambient", m_ambient_col);
LISP->get ("sun-specular", m_specular_col);
LISP->get ("sun-diffuse", m_diffuse_col);
LISP->get ("gravity", m_gravity);
delete ROOT; delete ROOT;
} }

View File

@ -52,7 +52,11 @@ private:
ssgBranch* m_model; ssgBranch* m_model;
TriangleMesh* m_track_mesh; TriangleMesh* m_track_mesh;
TriangleMesh* m_non_collision_mesh; TriangleMesh* m_non_collision_mesh;
// The next two variables are for AI improvements: the AI sometimes does
// not estimate curve speed and/or angle correctly, resulting in too much
// braking. These factors are used to adjust this.
float m_AI_angle_adjustment;
float m_AI_curve_speed_adjustment;
public: public:
enum RoadSide{ RS_DONT_KNOW = -1, RS_LEFT = 0, RS_RIGHT = 1 }; enum RoadSide{ RS_DONT_KNOW = -1, RS_LEFT = 0, RS_RIGHT = 1 };
@ -175,6 +179,8 @@ public:
const float& getFogDensity () const {return m_fog_density; } const float& getFogDensity () const {return m_fog_density; }
const float& getFogStart () const {return m_fog_start; } const float& getFogStart () const {return m_fog_start; }
const float& getFogEnd () const {return m_fog_end; } const float& getFogEnd () const {return m_fog_end; }
const float& getAIAngleAdjustment () const {return m_AI_angle_adjustment;}
const float& getAICurveSpeedAdjustment() const {return m_AI_curve_speed_adjustment;}
const sgVec4& getSkyColor () const {return m_sky_color; } const sgVec4& getSkyColor () const {return m_sky_color; }
const std::string& getDescription () const {return m_description; } const std::string& getDescription () const {return m_description; }
const std::string& getTopviewFile () const {return m_top_view; } const std::string& getTopviewFile () const {return m_top_view; }
@ -183,7 +189,6 @@ public:
const std::vector<SGfloat>& getWidth() const {return m_path_width; } const std::vector<SGfloat>& getWidth() const {return m_path_width; }
const std::string& getHerringStyle () const {return m_herring_style; } const std::string& getHerringStyle () const {return m_herring_style; }
void getStartCoords (unsigned int pos, sgCoord* coords) const; void getStartCoords (unsigned int pos, sgCoord* coords) const;
// static const Material* getMaterial (unsigned int n) {return m_triangleIndex2Material[n];}
void getTerrainInfo(btVector3 &pos, float *hot, btVector3* normal, void getTerrainInfo(btVector3 &pos, float *hot, btVector3* normal,
const Material **material) const; const Material **material) const;
void createPhysicsModel (); void createPhysicsModel ();

View File

@ -494,23 +494,23 @@ void World::updateRaceStatus(float dt)
if(race_manager->getFinishedKarts() >= m_race_setup.getNumKarts() ) if(race_manager->getFinishedKarts() >= m_race_setup.getNumKarts() )
{ {
m_phase = FINISH_PHASE; m_phase = FINISH_PHASE;
if(user_config->m_profile<0) // profiling number of laps -> print stats if(user_config->m_profile<0) // profiling number of laps -> print stats
{ {
float min_t=999999.9f, max_t=0.0, av_t=0.0; float min_t=999999.9f, max_t=0.0, av_t=0.0;
for ( Karts::size_type i = 0; i < m_kart.size(); ++i) for ( Karts::size_type i = 0; i < m_kart.size(); ++i)
{ {
max_t = std::max(max_t, m_kart[i]->getFinishTime()); max_t = std::max(max_t, m_kart[i]->getFinishTime());
min_t = std::min(min_t, m_kart[i]->getFinishTime()); min_t = std::min(min_t, m_kart[i]->getFinishTime());
av_t += m_kart[i]->getFinishTime(); av_t += m_kart[i]->getFinishTime();
printf("%s start %d end %d time %f\n", printf("%s start %d end %d time %f\n",
m_kart[i]->getName().c_str(),(int)i, m_kart[i]->getName().c_str(),(int)i,
m_kart[i]->getPosition(), m_kart[i]->getPosition(),
m_kart[i]->getFinishTime()); m_kart[i]->getFinishTime());
} }
printf("min %f max %f av %f\n",min_t, max_t, av_t/m_kart.size()); printf("min %f max %f av %f\n",min_t, max_t, av_t/m_kart.size());
std::exit(-2); std::exit(-2);
} }
} } // if all karts are finished
// 2) All player karts are finished --> wait some // 2) All player karts are finished --> wait some
// time for AI karts to arrive before finishing // time for AI karts to arrive before finishing