There are times when programming can just beat you up. I spent a large portion of my weekend working on the AI project, I did make a little progress, but not nearly as much as I desired. The reference point manager will now save a "processed" file to disk including the track edges, center line, racing line, etc. This drastically increases load time and I no longer need to do the ugly code changing/copy file contents hacks in order to change tracks.
However in the process of doing that I ran into troubles left and right. Finally got it working. The next step planned was to break down the curve by estimated segment lengths, which is actually not working as expected. I'm still debugging that portion of code. I will eventually need to save that in the processed information also.
I've done a bit of reading on neural networks and am still at a loss of how to go about implementing this. In some manner it sounds pretty straight forward, a set of inputs, random weights, a set of outputs.... How that will help the AI drive at all is so far above my head I stopped searching for the moment.
I need to section the curve by length for an optimization, I also need to find the point on the curve that is closest to the drivers position, which is actually a very troublesome problem it appears, and my math knowledge at this time is unfortunately too low, need to level that up a bit. I do have ways to make it work, but it will be slower and slightly less accurate - the accuracy in this particular situation shouldn't effect much, it is essentially the "drive to point" on the racing line.
Once I get that curve broken down for the optimization, I should be able to get the driver to look further ahead and realize when he is on a straight section, and maybe improve his logic a bit from what it is now. It is actually miraculous that he can drive a high 1:09.92 at FE1 in the XRG. I realize that is not a special or fast time by any means, but his logic is pretty dumb at the moment.
So I've finally have the ability to [u]roughly[/i] break down the curve based on a distance from start. I went ahead and tried using this without the optimized lookup table, and it actually works... for the first third of FE1. So now I need to process the curve into a more optimized structure like I was expecting but hoping I didn't need to do.
I am still running into the same issues with the memory/prediction units that I had a few months ago. I'm not sure the artificial driver will be able to rely on using the prediction unit for determining over steer / understeer or "at the limit" like I had previously planned and hoped for.
Just added a little bit of code so that instead of always
looking 20 meters ahead, the artificial driver will now look from 10 meters to more than 40 meters ahead depending on vehicle speed. This has not proven to help lap times yet, because with the performance issues for two thirds of the track the artificial driver weaves back and forth over correcting like a maniac... Caused by low sample/simulation rates, not of LFS).
A little later. . .
So, I have succeeded!! In making the artificial driver [u]even slower!!![/u]
His best laps around FE1 are now in the mid 1:23s... Awesome. I was attempting to change the way he used the throttle and brake, attempting to make him a little smoother. It is tricky though, I certainly need to find a better way to perform this logic. Currently I'm using angles of points along the racing line, essentially a tighter radius turn results in higher angles and using this I've been attempting to modify the throttle/braking inputs. With little success.
Obviously there is more to just the radius of the turn to take into account, such as over/under steer. But this is very similar to the approach I had previously and yet working so much worse. Maybe it was simply better to treat the throttle a little more like an on/off switch... Let me try making him have a heavier foot.
Backing up a bit...
I've now added a new supported track for the AI drive, I use the term track loosely. It is actually the skidpad.
The prediction and memory units are still having troubles and I've temporarily run out of ideas on how to solve that. I am going to attempt to use the skidpad and maybe an autocross layout, if I can figure out how to do a multiple lap playout,
to with any luck
create the logic to sort out if the car is at the limit, and if not, push harder... As well as get it back under control if it is over... This will be challenging to say the least and at this moment I don't know exactly where to begin.