The online racing simulator
Artificial Intelligence in Racing Simulations Project
(570 posts, started )
The Ai shifting will be the next step, and it shouldn't be too hard. Though that said; I am still limitting the setup to 40mph. The car went to 40mph not because the AI didn't shift, but because that was the limit I setup for it. I am quite astonished this worked the first try, with only 20 minutes of fiddling with what I completed the previous time - granted I hacked something in really quick so it is not completely appropriate! But, it is a first step!

That said I need to make the AI 'see' the DriveTo points through the visual sensor. As of now I hacked it to grab the DriveTo points through the world directly. Then I will need to look ahead and choose which point to drive towards. Currently it goes from cone to cone, as you can see it turns hard as it gets near the cone then continues on. I have a small radius around the cone. The car needs to be within 2.5 meters of the target, this will need to expand.

The primary test here was to see if the LFS layout format kept track of the object order. Meaning the first cone placed is the first DriveTo point, and so on. Currently if I was to go click in the middle to try adding another DriveTo point it would corrupt the 'ai' file and that wouldn't be good. So the tip here would be to add more DriveTo points than needed, and move them around as necessary, ALWAYS maintaining proper order and only deleting from the back if absolutely needed. But the test succeeded, and that is one less thing to worry about with the LFS to AIRS interface.

But yes, onto shifting and actually driving; which is the hard part. Do remember as I've said 100 times, competitive AI is a hope, but not the goal.
I dont think you need to aim the competitive AI stuff first
If you can get the right inputs, and can make outputs right, then you have two blocks checked and one big black block unknown stuff. Which you can divide into smaller blocks which you can hack/programm, and the unknow will be smaller and smaller at the and you will find yourself hacking the last one tiny little black box, and think it was't so hard.


Quote from blackbird04217 :The Ai shifting will be the next step, and it shouldn't be too hard. Though that said; I am still limitting the setup to 40mph. The car went to 40mph not because the AI didn't shift, but because that was the limit I setup for it. I am quite astonished this worked the first try, with only 20 minutes of fiddling with what I completed the previous time - granted I hacked something in really quick so it is not completely appropriate! But, it is a first step!

That said I need to make the AI 'see' the DriveTo points through the visual sensor. As of now I hacked it to grab the DriveTo points through the world directly. Then I will need to look ahead and choose which point to drive towards. Currently it goes from cone to cone, as you can see it turns hard as it gets near the cone then continues on. I have a small radius around the cone. The car needs to be within 2.5 meters of the target, this will need to expand.

The primary test here was to see if the LFS layout format kept track of the object order. Meaning the first cone placed is the first DriveTo point, and so on. Currently if I was to go click in the middle to try adding another DriveTo point it would corrupt the 'ai' file and that wouldn't be good. So the tip here would be to add more DriveTo points than needed, and move them around as necessary, ALWAYS maintaining proper order and only deleting from the back if absolutely needed. But the test succeeded, and that is one less thing to worry about with the LFS to AIRS interface.

But yes, onto shifting and actually driving; which is the hard part. Do remember as I've said 100 times, competitive AI is a hope, but not the goal.

very nice

EDIT: i get a oos error from the replay, but i can tell its nice
When do you get an OOS error near the end of the replay? One of my old replays was doing that to me, on my copy of LFS which had obviously not changed. And I wonder why that would happen?
I got that as well earlier today when I tried to watch it . It happens when the Al hits the first one/two cones.

By the way

Quote :New updates for the very few people following the progress here.

I think it is a lot more then you think!

This is a very interesting project.
right after it appears to finish the cone slolum

but thats irrelevant, i dont care that much, i get the point about the ai driving now, so continue, i have nothing but held up this project :hide:
Quote from MariusMM :I got that as well earlier today when I tried to watch it . It happens when the Al hits the first one/two cones.

By the way



I think it is a lot more then you think!

This is a very interesting project.

I still don't know, from number of views it looks like most people ignore the thread. Probably because I started it in the pre-design phase and that likely was too much reading that a lot of people just started not clicking on and by habit don't any more. I also think it might be the location of the programmer forum. This could belong here or in the Off-Topic I didn't really know where to put it. But maybe you're right, and in either case I am doing this for myself more than others - it's just nice when others are interested... Thanks for your support.
I got the oos message too. But very nice keep up the good work!
Quote from blackbird04217 :
That said I need to make the AI 'see' the DriveTo points through the visual sensor. As of now I hacked it to grab the DriveTo points through the world directly. Then I will need to look ahead and choose which point to drive towards. Currently it goes from cone to cone, as you can see it turns hard as it gets near the cone then continues on. I have a small radius around the cone. The car needs to be within 2.5 meters of the target, this will need to expand.

The primary test here was to see if the LFS layout format kept track of the object order. Meaning the first cone placed is the first DriveTo point, and so on. Currently if I was to go click in the middle to try adding another DriveTo point it would corrupt the 'ai' file and that wouldn't be good. So the tip here would be to add more DriveTo points than needed, and move them around as necessary, ALWAYS maintaining proper order and only deleting from the back if absolutely needed. But the test succeeded, and that is one less thing to worry about with the LFS to AIRS interface.

What about using route checkers for this? They have a diameter (2-30m) and an index that defines an order (0-255 I think). On top of that they'll work for real people too!
The radius is something I can change in my code. It just drives to where the cone is within a 2.5meter radius. I had to add the radius because with the first test when it came to some tighter turns the AI spun out and messed around trying to hit the exact spot. Though the idea of this radius thing was more of a quick way to indicate it is time to look for the next DriveTo point.

What really needs to happen is some algorithm for shifting up/down, braking and accelerating on a straight. For the moment I am on pause again while I consider my options as this is where 'intelligence' will start to come into play.
By the way all I am getting the same OOS when the AI hits about the fourth cone in... Strange.
Okay guys some more fun action! I hope this doesn't cause out of sync errors... I've watched it three times and restarted my copy of LFS...

Here is the update; the AI shifts up/down at predetermined RPM settings. When the RPM drops below 1000 the AI applies full clutch to avoid stalling. Again the false start is my fault, mostly lack of patience to run a test.

You get to see the AI do something almost every player did their very first time entering a corner... It also happens quite frequently in the online environment from what I hear, haven't been there in ages...

Enjoy!
Attached files
Woot!.spr - 11.9 KB - 177 views
wow, got to check from home!
Was the AI supposed to do a slalom?
Well, no - but yes all at the same time. The AI still has very limited knowledge / intelligence at this point. Here is a list of goals the AI does once it gets the 'green light'

Find Next DriveTo Target. If Target is to left, turn steering left, it Target is to the right, turn steering to the right. That as simple as that gets, but it does not look passed the next cone. Meaning, it always gets to cone A before going to cone B. Hence the subtle zig-zag you see.
(I say subtle because if you look at the very first replay posted you will see funny stuff)

Now that the AI knows where it is going it tries to maintain a speed of 80mph. Way too fast for turning, but the primary goal was to make sure the AI shifted during this test, which it did successfully. Basically if speed is < 70mph hit full throttle. If 70 < speed < 80 it will fade off the throttle and aim for ~80mph.

Now that the AI can turn, and keep a desired speed it starts checking the driving functions. Should I be shifting up? (RPM too high) Should it be shifting down? (RPM too low). While shifting it presses clutch, releases throttle and performs the shifting. (Currently sequential although I have a feeling H-Shifter would be far easier to implement. Gear = X and be done... But sequential is finally working.

The last thing the AI does is checks for the RPM dipping too low, indicating a point of stalling at which point it hits the clutch.

That is all the intelligence so far, so there isn't much - in fact, the AI can not start the car if it stalls, can not shift into reverse, can not even hit the brakes as demonstrated by that beautiful replay! All it can do is turn from cone to cone, maintain speed and shift up/down depending on the GaugeSensor.

I think my next step is to take this to the drag strip, and try racing against the LFS AI with my own. . . Hmmm. Going to edit an AI layout for the dragstrip, consisting of 1 cone to DriveTo and then it's all about the shifting... Oughta be interesting! Will likely edit in ~5 minutes with a replay here. So do check.

EDIT: Can't race against the AI because of my LFS to AIRS interface needs some work. InSim needs to know which car is which, and handle it properly... Also, my AI does outstandingly bad at driving in a straight line at high speed... Especially in my 'drag set'
I meant to, and thought I had posted an update awhile ago - unfortunately not an update of progress.

For the time being I think the AIRS project has gone as far as it can go with LFS. Certainly I could get the AI doing better laptimes in LFS but I can not get any form of grip value for the AI to know if the car is slipping. I've thought about playing around with OutSim, using the angular velocity and acceleration vectors to see if I could come up with a good approximation, but honestly with the time it would take to do that I could likely make a small, flat world with some basic physics for a car to drive around.

So the next step of the process is going to take awhile, but I plan on making my own world, some simplistic physics, and get the AIRS project working with that.

If someone can come up with a way to accurately detect that each of tires are Under, Near, At or Over the Limit of traction using InSim/OutSim/OutGauge interfaces, then please describe how and if it is accurate enough then I will implement that and continue using LFS as the testbed for the AIRS project.
The data available from real-time official LFS interfaces are very limited, so this problem looks difficult. However, RAF contains slip fraction.
Quote :Slip fraction
-------------
This is the dynamic value of the current combined slip ratio relative
to the combined slip ratio that would provide the greatest force.

0 to 254 - slip ratio increasing up to maximum force available
255 - slip ratio exceeds the maximum force slip ratio

Obviously, it's not real-time data, but maybe it could be used to construct a model of very high-level "distilled" grip characteristics of a given car and setup.

Such a model could be a function which takes:
  • linear acceleration vector,
  • angular acceleration vector,
  • linear speed (needed for cars with downforce),
  • car orientation (e.g. up-vector, needed to take driving on banked surfaces into account, and forward-vector to distinguish between cases of moving on the same trajectory with varying amounts of drift)
and returns the slip fraction values for all four wheels.

The above data (function inputs and outputs) can be logged quite easily with simple calculations from RAF of test runs of a given car and setup with near to optimal tyre temperatures. Then the hard part would be to find a mathematical expression that approximates the function with sufficient accuracy. The inputs of the function can be retrieved in real-time from OutSim (with some simple calculations) and the AI could use the approximating function to get "predictions" of slip fraction values when driving.

This ignores real-time tyre temperature and wear, but AI could deal with cold tyres by not using 100 % of the optimal grip at the beginning and gradually going closer to the limit as tyres warm up. Also, adding steering inputs to the parameters of the function may seem useful, however, they already influence existing function parameters.
I kinda see where you are aiming to go, and that might plausibly work - but like you said it would ignore tire temp - and any other dynamic changes; wind, drafting/downforce -etc.

The idea with retrieving the traction levels of each tire give the AI to know how close they are to the limit _without_ knowing the actual dynamics. Although some dynamics, at least the general rules, will need to be added to to the AI as general knowledge, but not needed to know values at all. Like we all know that getting behind another car, slip streaming, is a useful tactic - and we know why it works, as a general rule.
you could possibly make the program just assume that the tires are always slightly warmer then they should be, so they have less then optimal grip, so they dont go off the road
I think you missed this, or misread it:

The idea with retrieving the traction levels of each tire give the AI to know how close they are to the limit _without_ knowing the actual dynamics.

This means I don't want the AI to know about the tire heat or anything like that. Only to get input, sensations etc about the traction of the tires. Which is why I need to go the route of creating my own small racing application. It won't be completely simulation but I will try to incorporate as much as I can. At the minimum I need some, basic, traction/friction model for the tires. It may not include deformations, heat, dirt, tire wear etc... But enough that the tires can break traction and slide around.

I don't know though, I am having some serious issues with motivation on all my projects at the moment. I haven't really coded much for a long while, and it is annoying to me. It isn't the lack of desire either, just something else. Consider it something like writers block - hope that changes soon.
Don't forget the "blind faith" part of driving - you know the tyres take a couple of laps to warm up, it's been a couple of laps, so let's go for it and hope it sticks.

You aren't judging anything. If it doesn't work then you have a moment/off/crash. Hard to cope persistent, but believable, belligerence into an AI I would have thought.
yep i skimmed all the posts basically, i cant quite do anything but throw a few ideas around, so i have nothing better but to skim
we could kindly ask schumi to drive in lfs and then record the tlemetry and get pass to the a.i

im sure no one will ever beat the a.i they all will get crashed or they will die trying
Quote from giannhsgr1 :we could kindly ask schumi to drive in lfs and then record the tlemetry and get pass to the a.i

im sure no one will ever beat the a.i they all will get crashed or they will die trying

...Have you read the posts in this thread? I highly doubt it, he is trying to program a A.I not anything like your talking about.
Been ages since I've updated this thread. I have been stuck trying to make it so LFS was running on my laptop, while my AI and code was running on my desktop. However something strange wasn't letting that work. It seemed to be related to my UDP socket of sending the AI commands, as it sometimes doesn't work- but it is odd for many reasons that are too technical.

In any case for the past couple months I've been super busy, and even more busy now. I have yet to let this project die. I probably won't be able to do anything more until the end of July, as my free time is limited to 2hrs a night - and most of that gets used in the LFS Hotlap League, practicing for other events that I am taking part in. Sure I could quite those, but even then I there is so much stuff.

Who knows maybe this will slowly suffer, but I am trying not to let that happen.

Artificial Intelligence in Racing Simulations Project
(570 posts, started )
FGED GREDG RDFGDR GSFDG