1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Training the adaptive AI

Discussion in 'RaceRoom Racing Experience' started by Lars Hansen, Apr 27, 2016.

  1. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    We all know that racing fellow humans is more fun, but sometimes there aren't any around when you feel like racing.
    Which is why sims come with an AI.
    The R3E AI has a rather bad reputation, which in my opinion is ill-deserved.
    It works just fine, assuming you treat it right.

    First off, forget about the percentage settings.
    Nobody is equally adept at all car/track combinations, so you can't use one setting for all of them.
    You could in theory write down the settings for each combo, but.......
    So use the adaptive AI.

    As you may have surmised, the adaptive AI adapts to your skill-level.
    But it needs a baseline in order to work properly.
    Here's what you do:

    Step 1: Start a race with the desired combo, and run qualifying. The AI skill varies with the combos, and we need to find out whether you're faster or slower than the AI baseline.

    Step 2: Quit out, and start a series of 10 minute races without qualifying. If you were faster than the AI, start at the front. If you were slower than the AI, start at the back.
    The idea here is to be able to run consistent laps without interference from the AI.

    EDIT: Scratch the above. I'll rewrite it once I figure out the best way to train it.

    How many races you need to run in Step 2 is actually up to you.
    The more consistent your lap-times are, the faster the AI will find your pace, and adapt to it.
    For me it usually takes 2-3 races, and then I can get a good fight out of the AI.

    Couple of things to note.
    It's still an AI, and it's not perfect. Like most other AIs (and most sim-racers btw) it doesn't do particularly well in a crowd, so you need to be a little careful on the first lap.The further back you start the worse it is.

    The adaptive AI constantly adapts. Which is good, because as you gain experience and improve your lap-times the AI will follow suit.
    But if you've been down at the local for a few pints and a bit of a sing, and then run a race with adaptive AI, not only will you not be able to catch it, the next sober race will be ridiculously easy because it has adapted to your now slower lap-times. :D

    But to show-case what it can do, here's a short 10 minute race for illustration purposes.
    I've done 3 races before this one to get the AI to adapt to my pace, and put myself in 6th position.
    Look out for:
    1. The AI is not robotic, it makes mistakes. Observe the blue/red car in 4th position, and watch it fishtail as he locks the brakes.
    2. The AI doesn't give up after being passed. Near the end I screw up, the AI takes advantage and I lose P2.
    3. The only time there is contact (when I move to P2) it is my own fault. Not once do I get dive-bombed or rammed in to.

    So if you're willing to do a little 'homework' to get the AI to adapt, R3E can certainly provide single-player entertainment.
    EDIT: Fine-tuned the OBS settings.
    Much improved video-quality.
    Driving still sucks though. :D
    Last edited: Apr 28, 2016
    • Like Like x 15
    • Love Love x 1
  2. RaceWasGood

    Premium Member

    Interesting reading. Thanks for the tip!
    • Agree Agree x 2
  3. psynusoid

    Premium Member

    I must admit to being very impressed with the AI once it has been trained.

    Less impressed with my ability to do consistent lap times.
    • Like Like x 3
    • Haha Haha x 1
  4. Kenny Paton

    Kenny Paton
    Backmarker Champion 2015 & so far this year. Staff Premium Member

    I have barely played this with the AI, maybe give it a go.
  5. jimortality

    Premium Member

    Do you have to do this for every track and combo or will one track cover all?
  6. psynusoid

    Premium Member

    Digging through the adaptive AI file it looks a per car/track combo.
    • Like Like x 1
  7. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    Yep, it's for every combo.
    So obviously it'll take a while to do them all. :D
    What I'm doing is picking one car (in my case the Acquila) and going through a handful of tracks that I want to use later in a championship.

    EDIT: And I think it's per CLASS/track combo, not car/track.
    I doubt there's a need to go through it for every car in the GTR3 class.
    One should be enough.
    Last edited: Apr 27, 2016
    • Like Like x 3
  8. kamackeris

    Premium Member

    can we not download 'trained' ai ??? there should be a database setup
  9. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    The whole point of an adaptive AI is that it adapts to your skill-level.
    So unless you know someone who is exactly as fast as you in all classes, it would be an exercise in futility.
    It might be possible to copy someone elses file over, but I haven't tried.
    If you want to experiment, you'll find the file in:
    D:\Documents\My Games\SimBin\RaceRoom Racing Experience\UserData\Player1\aiadaptation.xml
  10. Simon Fillingham

    Simon Fillingham
    Premium Member

    Is it wise to delete this file (aiadaption.xml) before ' training' the ai so to start a fresh? Or will a few 10min races override what has already been learnt by the ai?
  11. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    It'll adjust to your level after 2-3 races, maybe a few more depending on how consistent you are.
    The only reason I can think of to delete it would be if there's a massive overhaul, like a physics change.
    And even then I still think I'd just run some races and let it adapt.
    • Like Like x 1
    • Agree Agree x 1
  12. jimortality

    Premium Member

    Good question, I'd like to know that as well
    • Like Like x 1
  13. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    Tell you all what, I've still got one more track to do, so I'll see if I can't hack together a post describing the process and the results a little more clearly.
    Probably won't be until tomorrow though.
    • Love Love x 1
  14. RaceWasGood

    Premium Member

    Not sure if it can be described more clearly. Any further description will probably make me very confused :D
    • Agree Agree x 2
  15. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    First I hit a snag, and then things got complicated.
    Bloody computers. :roflmao:

    This section is going to be a somewhat technical, and knowing my style of writing there's every chance it'll be insanely verbose.
    Just bear with me, there is actually important information hidden in there. ;)

    To start with, we need to understand that there are three basic rules governing the AI.
    1. The basis for the AI is the average of your last 10 laps.
    2. It only adapts BETWEEN sessions, it doesn't adapt DURING a race.
    3. The AI adapts gradually when your average changes. So if you have one bad session, it doesn't immediately go down to that level, it just takes it down a notch until such a time as the AI and the average are roughly equal again.

    Rule 2 and 3 is the reason you should do short races. Ordinarily you would think that if the basis is the average of your 10 last laps, then one 10-lap race would be better than five 2-lap races, since that would mean there's only one starting lap in there.
    But since the AI only adapts between sessions, and only adapts gradually, you need to do short races in order for it to catch up in the first place.
    Rule 1 is what truly f*cked me up. :D

    The 'three short races' format had worked beautifully on both Zandvoort and Nürburgring, but I simply couldn't get it to work at Spa. No matter how many races I did, the AI obstinately refused to improve.
    After a little research, I found out that there were two reasons for that problem.

    First, I've never been very good at Spa. I enjoy driving it, but I couldn't do a fast lap there if my life depended on it.
    So what happened was that as I was doing lap after lap trying to train the AI, I got more comfortable with the track, and my own lap-times started to improve.
    Or in other words, I was improving faster than the AI. :D
    Okay, so that one was me being stupid. But it does illustrate the need to be fairly consistent when you're doing laps.

    But even then, after six 10 minute races I was doing 2:32-2:31s (yes, I suck at Spa. I have always sucked at Spa. I know this. Moving on.....), while the AI kept doing 2:33s, and for the life of me I couldn't figure out why.
    So I took a look at the aiadaptation.xml file:

    <key type="int32">4543</key>
    <!-- Index:0 -->
    <key type="int32">253</key>
    <!-- Index:1 -->
    <key type="int32">255</key>
    <!-- Index:0 -->
    <custom type="float32">155.78283691</custom>
    <!-- Index:1 -->
    <custom type="float32">153.02120972</custom>
    <!-- Index:2 -->
    <custom type="float32">152.37628174</custom>
    <!-- Index:3 -->
    <custom type="float32">153.11471558</custom>
    <!-- Index:4 -->
    <custom type="float32">155.46817017</custom>
    <!-- Index:5 -->
    <custom type="float32">151.91989136</custom>
    <!-- Index:6 -->
    <custom type="float32">152.44479370</custom>
    <!-- Index:7 -->
    <custom type="float32">151.92858887</custom>
    <!-- Index:8 -->
    <custom type="float32">155.43629456</custom>
    <!-- Index:9 -->
    <custom type="float32">152.73019409</custom>

    The bold 4543 is the code for the track, in this case Spa Combined. The bold 255 is the code for the Aquilas. The remaining entries are my lap-times in seconds, so 152.44 equals 2:32.44, okay?
    And this is when it hit me.
    The longer the track is, the fewer laps you get to do in a 10-minute race.
    The fewer laps you run, the more influence the start-lap has on your average.
    Looking at the times above, you see a pattern of a starting lap of around 2:35, followed by 3 hot-laps of around 2:32.
    So if I'm doing 2:32s why is the AI only capable of doing 2:33s?
    Here's the kicker.
    Disregarding the decimal-points, if you average the ten lap-times listed, you end up with 152,9....Or 2:32.9 :)
    Or in other words, my problem was that the 10-lap average contained too many start-laps that were dragging the average down.

    So there's a couple of things we can learn from this.
    Aside from the fact that it'll be a while before I ever run at Spa again. Man, I'm sick of that track by now. :D
    First, you need to do short races in order for the AI to adapt to your base-level.
    How many you need to do depends on how far you are from the AI starting-point.
    If you're within a second of it, 1 or 2 is probably enough. More than that I'd say at least 3.
    Second, when you're training the AI always use rolling starts.
    A standing start means an even slower Lap 1, and thus a lower average.
    Third, once the AI has roughly caught up, you need a race with at least 5 hot-laps in it, so you only have one starting lap to drag your average down.

    Now, if you're sitting there thinking "Man, I have to do 2-3 short races, and then a long race in order for it to catch up?! Bugger me, far too much work!", things aren't all that bad.
    To start with, the whole start-lap issue is only a problem when you're doing the initial training.
    Once you start racing, most people will be doing 30+ minute races, and unless you're running the Nords, that'll be ample time for 10 hot-laps. Remember that the average is based on your last 10 laps, so once you do 10 hot-laps the start-lap disappears and your average increases to your race-pace.
    If you feel like it, you can simply do 'proper' 30 minute races from the beginning and the AI will gradually adapt to your pace. The only reason for starting out with short races is for the AI to catch up faster.
    Besides, no-one is saying that you have to do AI training as a stand-alone option.
    One thing I figured out is that you can do races against the AI, set it to 0 opponents, and the lap-times will still be collected by the aiadaptation-xml.
    What's the point of that, you may ask.
    Well, if you're planning on doing practice for a Club race anyway, instead of doing it in a practice session, use an adaptive AI race-session, and set the opponents to 0.
    You get the same amount of practice, plus you get average lap-times for the AI to aim for.
    • Like Like x 6
    • Love Love x 3
  16. Simon Fillingham

    Simon Fillingham
    Premium Member

    I guess a rolling start would slightly improve the average if only doing 10 minute races?

    Good job though Lars, very informative
  17. kamackeris

    Premium Member

    it only improves the ai in terms of matching your pace.....correct?? not in terms of it being smarter ??
  18. kamackeris

    Premium Member

    copied and pasted from the same thread on sector 3 but.....

    could you not just run quali at say 100 %, end the session and check the times. if they are competitive to what you can do then thats the setting to use, if not change it up, run quali then end the session straight away till you are seeing competitive times....surely this will be quicker than 'training' the ai every time ??
  19. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    Same answer as on the S3 forums.
    Yes, you could. But you'd still have to do it for every combo, and you'll have to adjust it every time you start to improve.
    But it's a free country, nobody can tell you how to run your sim-racing. :)
  20. Lars Hansen

    Lars Hansen
    RDs Ion-Engine....0-60 in six days. Staff Premium Member

    Correct, it's still the same AI.
    Adaptive only applies to the pace of it.