Forums

Full Version: AI driver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm still able to spank the AI by 8.5 seconds on Jarama in G4s from a standing start on my first try, but it drives respectably. It reminds me of the conservative driving style of the gran turismo AI, where it never messes up but never really pushes it, either.
I just checked in a fix that makes the game start in STATE_STAGING instead of STATE_PLAYING, so the player will hold the brakes until time to go. I made the AI hold the brakes too so at least the player gets a fair chance to start now. It is a little funky though that the cars are literally on top of each other.
I've committed some enhancement to the AI. Now it's able to navigate Monaco and Circuit de Pau using a G4.

Currently the biggest handicap AI has is the tire model. It's using a very much simplified version to calculate the friction force,

Friction = mu * Weight

The friction coefficient mu is taken from the track definition - treaded friction coefficient (0.9). This value seems a bit low for a car like G4, resulting a lower speed limit (hence slower) around the corner. However, it's too high for some other cars.

I'm not sure how to improve this, short of doing the full Pacejka calculation, which maybe overly complicated.
Check out:

Code:
double sp = (*it)->GetTire()->GetSigmaHat(); //ideal slip ratio given tire loading

double uhat = (*it)->GetTire()->GetFx(sp); //maximum tire friction given ideal slip ratio

This should give you a better approximation than the equation you're currently using. You might want to back off of the ideal value somewhat. Also, you should take uhat and multiply it by ((1.0-tread)*friction1 + tread*friction2) where tread is the tire's tread and friction1 and friction2 are the friction coefficients for the track surface.
Just on a sidenote, I now get a linker error when compiling on windows in Dev cpp about AI here it is:
Code:
[Linker error] undefined reference to `AI::update(float, float, TRACK*)'
Nathan looked at the code and couldn't find anything wrong with it.
kcid Wrote:Just on a sidenote, I now get a linker error when compiling on windows in Dev cpp about AI here it is:
Code:
[Linker error] undefined reference to `AI::update(float, float, TRACK*)'
Nathan looked at the code and couldn't find anything wrong with it.
Can you check whether ai.h and ai.cpp are part of your dev cpp project?
Commited a change to calculate friction coefficient base on Joe's suggestion. This takes into consideration individual car's tire data. So it should be better than the previous code using a fixed value for all cars.
Thanks rookie1 that worked, the ai.cpp and ai.h where not added to the file yet, I've uploaded a updated dev cpp project file into svn. Thankx
Pages: 1 2