Training the adaptive AI

Lars Hansen

Buggered if I know.....
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:
Question: when there is no AI time stored in the file, only your last 10 lap times, I don't think the AI is able to 'adjust in small steps'. Adjust from where?

Another question: is the adaptive AI used in practice sessions without race, where you don't assign the AI strength? I always wonder what determines their pace. Sometimes I am much faster, sometimes they are all over me.

I just put the AI level on my average fighting pace (which is between 105 and 110 at the moment), and then I adjust it maybe when I am faster or slower than all of them in practice. Meanwhile I am thinking that some time I will be able to use adaptive AI, because they are adapting anyway.
 
Question: when there is no AI time stored in the file, only your last 10 lap times, I don't think the AI is able to 'adjust in small steps'. Adjust from where?
You're assuming that the XML file is the only place that holds information regarding the AI.
If that were the case, the first race you ran with a combo would have the AI sit completely inert since there are no lap-times to start with. So there must be a baseline, presumably adjustable, somewhere.
Don't get me wrong, what I've found out is a mixture of observation, deduction and no small amount of half-assed guesswork. :D
But in my head it makes sense that the player-data is filed in an open format, whereas the algorithms that control the AI behaviour is encrypted somewhere in the system-files.

Another question: is the adaptive AI used in practice sessions without race, where you don't assign the AI strength? I always wonder what determines their pace. Sometimes I am much faster, sometimes they are all over me.
Excellent question, and I have no idea to be honest.
I'll see if I can get some sort of answer out of S3.

Speaking of S3, I've had a little chat with one of their beta-testers, and can clear a few things up.
1. There's no need to delete your XML-file ever.
Even if there's a massive physics-update, the odds are your stored lap-times are closer to your pace than the baseline. So it'll be faster to simply let the AI adapt from the current level, rather than to start over.
The beta-tester in question has been using the same XML-file for the past 6 months with no problems.
2. Somewhere in one of the patches, something got changed. Beforehand the slowest lap of any race (that is, the start lap) was discarded keeping only the flying laps in the file.
They've added it to the bug-list, and if can be fixed without a major rewrite, they will.
Until then, it's just something to be aware of.
3. @kamackeris and this is where you may want to perk up your ears and listen..... :D
The XML-file collects data from ALL AI races, not just the ones done with adaptive AI.
So what this means is that you can run fixed-percentage races at your preferred settings, and if you ever want to increase the challenge a bit, switch over to adaptive, and it'll start from your current baseline.
4. And this is one for the aliens among you. With adaptive AI you're no longer maxed out at 120%
Granted, this is unconfirmed simply because neither he nor I are able to push the AI that far. :D
 
Okay, a night of further testing resulted in something of a find.
As it turns out, if you're willing to do some manual editing of the XML, you can actually train the AI to your level by doing six laps. ...*ahem*...That was a blatant lie.
You can get the AI up to speed in 12 laps, not six.
Little hard to explain through text though, so I'll attempt doing a video describing the process some time this week-end, and if that fails I'll see if I can't hack together a forum-post instead.
 
Last edited:
A little disclaimer: I agree with a lot of what's being said on other threads.
The AI in its present condition is a little sterile, and usually doesn't fight other AI racers much.
There's also the collision-problem, and the magical brakes at the end of a brake-zone.
That said, I have full faith and confidence that these issues will be fixed. Considering the leaps of improvement we've seen in other areas of this sim, it would seriously surprise me if we didn't see AI improvement as well.
All that however, is not the point of this thread, which is about the adaptive AI specifically.
So we now return to our regularly scheduled broadcast, which revolves around getting the adaptive AI up to player-speed quicker.

To start with, I will say that there won't be a video on how to use XML editing to get faster adaptive AI.
Why not?
Because I'm a f*cking moron, that's why. :D
I spent 2 hours testing some ideas, then a further 4 hours getting game-footage, doing narration explaining all this stuff, editing and so on.
Then after I was happy with the final edit, I decided to test out a few other things mentioned earlier in the thread to see if I could answer everything at once.
Bad news: The video was outdated before I had even rendered it...... *sigh*
Good news: I figured out a way to get a fully trained adaptive AI in 12 laps, without having to edit anything.
All you have to do is 12 laps without ever leaving R3E.

Technical section and a wall of text ahead.
If you have no interest in what I did or why it works, scroll down until you see another dotted line to find out HOW to do it.
-----------------------------------------------------------------------------------------------------------------------------------

The first thing I decided to test was whether you were better off training the AI without actually having AI on the track.
You're definitely not. In fact, you CAN'T train the AI without having AI on track.
I'll tell you why in a moment.

The second thing I wanted to test was whether you can train the AI using races against fixed AI.
Again, no you can't. Or rather, not directly.
But you can most certainly use fixed AI in another way to get the result you want.

As it turns out the lap-times in the XML are utterly useless to the initial training of the AI, they only come into play AFTER the AI is trained. What you should be looking for is the AI indexes just below them.
How it works......... correction, how I think it works is that the adaptive AI writes an index after each race.
The number of indexes vary a bit (not sure why) but the average seems to be six indexes for each car/track combo.
DURING the race the AI then uses these indexes to vary it's lap-times. If you start to fall behind, it goes to the next lowest index for the next lap. If you still fall behind, it steps down again and so on.
Obviously vice-versa if you're faster than the AI.
If you're still too fast after the AI uses its fastest index, it'll write a new one after the race, upping the ante the next time you race that combo. If the maximum number of indexes are already used, it'll delete the least used one.
Short version, if you outran the AI, after the race it'll delete the slowest index, and write a new index with a higher AI level than the current highest.
Fairly simple algorithm, no surprises there.

Okay, but the problem still remains. Since the AI start at 80% by default, It'll take a lot of races to get competitive, especially considering that the closer it gets to your lap-times, the smaller increments it'll increase by.
So my initial idea was that if you 'hacked' the XML and fooled the AI into thinking you were actually much faster, it would increase its speed in larger increments.
What I did was take my personal best for a combo, subtract a second from that, and enter that manually into the XML.
First hurdle I ran in to was making the mistake that one lap was enough to count as a race.
I mean, it's enough to get a lap-time into the XML so that should train the AI as well, right?
Nope, doesn't work like that. As I said, the lap-times are useless in training the AI.
What happens is that the AI compares your last lap-time to its last AI level, and if that isn't fast enough it tries a higher level next lap.
But the kicker is that it can't know whether it was successful until after the lap is finished.
And it won't discard its base-line until it has a new one to try.
Pure Boolean logic:
After Lap 1 it asks "I tried at 80%, was that enough?"
After Lap 2 it asks "I tried at 90%, was that enough?"
But unless it knows that the next level failed as well, it won't abandon the first one.
So you need to do two laps per session, otherwise you won't get anywhere.

It also explains why you can't train the AI without having AI on track.
Without AI, no comparisons are made, and thus no new indexes are written.

Alrighty then.
So I started doing two lap races, then edited the XML manually, and watched what happened to the AI indexes.
This is an example from my old XML file, showing Aquilas at Brands Hatch.

<custom>
<custom>
<!-- Index:0 -->
<custom type="float32">48.78387451</custom>
<!-- Index:1 -->
<custom type="float32">48.79570007</custom>
<!-- Index:2 -->
<custom type="float32">48.69625854</custom>
<!-- Index:3 -->
<custom type="float32">49.31530762</custom>
<!-- Index:4 -->
<custom type="float32">48.94433594</custom>
<!-- Index:5 -->
<custom type="float32">48.60922241</custom>
<!-- Index:6 -->
<custom type="float32">49.06225586</custom>
<!-- Index:7 -->
<custom type="float32">49.31475830</custom>
<!-- Index:8 -->
<custom type="float32">49.27456665</custom>
<!-- Index:9 -->
<custom type="float32">48.91101074</custom>
</custom>
<custom>
<!-- Index:0 -->
<key type="uint32">90</key>
<custom>
<custom type="float32">57.20594025</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:1 -->
<key type="uint32">106</key>
<custom>
<custom type="float32">51.62752914</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:2 -->
<key type="uint32">109</key>
<custom>
<custom type="float32">51.53813934</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:3 -->
<key type="uint32">111</key>
<custom>
<custom type="float32">51.20059204</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:4 -->
<key type="uint32">112</key>
<custom>
<custom type="float32">51.15437317</custom>
<custom type="uint32">2</custom>
</custom>
<!-- Index:5 -->
<key type="uint32">114</key>
<custom>
<custom type="float32">50.68688202</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:6 -->
<key type="uint32">120</key>
<custom>
<custom type="float32">49.31999588</custom>
<custom type="uint32">2</custom>
</custom>
</custom>
</custom>

This one is after 8 two-lap races if memory serves, and I've only edited the first 6 of those, so we're already seeing some adjusting.
The Index goes 90 - 106 - 109 - 111 - 112 - 114 - 120.
By this point I was extremely pleased with myself. :D
I had after all gotten the AI up to speed in very few laps.
Only....
When I subsequently tried racing it, it behaved oddly with wild variations in lap-times.
In hindsight it's pretty obvious why, since there are some large gaps between the indexes.
So if you fall behind the AI goes to the next lower index, and if that index is 10-12 percent lower....Well....

Okay, so by now I'd figured out that a good adaptive AI has tightly grouped indexes, making it possible for it to make small adjustments in tempo, both up and down.
But I couldn't figure out how to make it do that AND get up to speed quicker. As far as I could see you had to do race after race after bloody race to get the tight groupings.
So I thought I'd do a video showing how to at least get it up to speed quickly, and make the caveat that it would still need further races in order to become good at varying speeds.

After doing the video, as mentioned earlier, I decided to test AI training both without AI and with fixed AI.
Obviously, without AI, no indexes, and thus no training. Scratch that idea.
The fixed AI does however write an index. It's a fixed index obviously, but it does get written.
And this is the Heureka moment.
Also know as the "Why the f*ck didn't I think of that earlier?!" moment. :confused:

If you...
  • know your approximate AI level
  • know that good adaptive AI needs tight groupings
  • know how to get a specific AI index written
wouldn't it be possible to 'design' a tightly grouped index for the AI to follow?

I knew my AI level with NSUs at Brands was about 115% (give or take).
So I did two laps each at 113, 114, 115, 116, 117, and 118, with one AI opponent to write the index.
Which resulted in this index:

<custom>
<!-- Index:0 -->
<key type="uint32">113</key>
<custom>
<custom type="float32">61.74826813</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:1 -->
<key type="uint32">114</key>
<custom>
<custom type="float32">61.53697968</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:2 -->
<key type="uint32">115</key>
<custom>
<custom type="float32">61.08876038</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:3 -->
<key type="uint32">116</key>
<custom>
<custom type="float32">60.94928741</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:4 -->
<key type="uint32">117</key>
<custom>
<custom type="float32">60.79580688</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:5 -->
<key type="uint32">118</key>
<custom>
<custom type="float32">60.15036011</custom>
<custom type="uint32">1</custom>
</custom>
</custom>
A nice tightly grouped index, with about 1,5 seconds spread.
Purrrrfect. ;)
Then I did a full 8 minute race with 10 opponents and got a very serious fight (see video at end of post).
Even better, I re-checked the index after the race, and got this:
<custom>
<!-- Index:0 -->
<key type="uint32">113</key>
<custom>
<custom type="float32">61.74826813</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:1 -->
<key type="uint32">114</key>
<custom>
<custom type="float32">61.53697968</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:2 -->
<key type="uint32">115</key>
<custom>
<custom type="float32">61.08876038</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:3 -->
<key type="uint32">116</key>
<custom>
<custom type="float32">60.79580688</custom>
<custom type="uint32">2</custom>
</custom>
<!-- Index:4 -->
<key type="uint32">117</key>
<custom>
<custom type="float32">60.58061218</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:5 -->
<key type="uint32">118</key>
<custom>
<custom type="float32">60.15036011</custom>
<custom type="uint32">1</custom>
</custom>
</custom>
Note that when compared to the 'artificial' one, the AI indexes are exactly the same.
There are some small variations in the lap-times of level 115 and 116, but apart from that the adaptive AI didn't feel the need to change anything.

One more thing to mull over, and that needs further testing.
Below the lap-times, there's an integer key.
The sequence is 1, 1, 1, 2, 1, 1.
Now, this is admittedly a very small sample-base, and one should be careful drawing conclusions on such a small data-set.
But I think it's the number of laps the AI used that particular level, in order to weigh each level.
So if it needs to change a level to adapt, it'll change the one that got used the least.
Furthermore, there are only seven laps, even though I did eight laps.
Which leads me to believe the AI only used the seven fastest laps, discarding the start lap.
So why did I complain earlier in the thread that the start-laps were dragging the average lap-times down?
Again, careful with the conclusions, but I would suggest that it only starts discarding laps once it has enough new laps to fill the entire index.
Earlier I only did two-lap races, and since that wasn't enough for each index to get a comparison, the AI never discarded any of them.

EDIT: Scratch that. Poor logic on my part.
The reason it only shows 7 integers, is the same reason you need two laps to write a new index.
It's not the number of laps, it's the number of comparisons.
The AI only does comparisons after each lap, and only does so if there's a new lap ahead to adapt to.
And since the last lap obviously doesn't have a lap following it, there's no comparison made.
This also explains why the start-laps in two-lap adaptive races never increased the AI speed.
Since I stopped after the first flying lap, there was no lap after that, and thus the flying lap never got a comparison, meaning I've been trying to teach the AI based on starting laps. *sigh*
I swear, one of these days I'm going to actually use my noggin before jumping to conclusions. :D

Anyway....
Job done, that's how you can browbeat the AI to your level very quickly.
(And now I'm going to sleep for a friggin' fortnight....)
----------------------------------------------------------------------------------------------------------------------------------------

So to recap for those who didn't want to follow the geek-speak:

Two major rules to remember:
1. The more consistent your lap-times are, the more fun you will have.
2. The better your initial level-assessment is, the quicker you'll get good racing.

Step 1.
So, you first need to establish your approximate AI level at a given car/track combo.
If you're already fighting fixed-percentage AI you already have a good idea of where you're at.
If not, you need a little patience to do some qualifying sessions.
Use races against 8 AI opponents, select an fixed-percentage AI level, and use qualifying. Never actually enter the track yourself, just take note of the lap-times the AI does. And let them run at least 2 laps, preferably 3.
Keep changing the AI level and keep doing this until your best time would've placed you around 3rd or 4th.

Step 2.
The way adaptive AI works is that it needs to be able to slightly vary its speed in the race.
In order to build up the AI database, we need to run a series of two-lap races (6 of them to be exact).
Each of these are to be run with only 1 AI opponent, and without qualifying. Just place yourself in first, and off you go.
What you do is run two laps at your AI level from step 1.
The you need to run two more laps each at level -2, -1, +1, +2 and +3.

Example: Let's say your AI level is 112%.
The you need to run two laps each at AI 110, 111, 112, 113, 114, and 115.
And that's it, you're done.
You now have a fully-trained adaptive AI for that car/track combo.
You're welcome. :)

And just to illustrate it.....
I deleted my aiadaptation.xml file so I could start fresh.
I knew my AI level was about 115, so I ran two laps with one AI opponent at level 113, 114, 115, 116, 117 and 118.
That's the ONLY thing I did. I never edited anything, nor did any other technical magic.
Then I did a 'real' race with adaptive AI and I got this:

Now, if you're sitting there thinking "Pfft. 60 seconds a lap? You call that a fast AI, mate?"...
Then you're completely missing the point.
The object of the exercise is to get an AI that is adapted to YOUR level, not necessarily a FAST level.
If you want a fast AI, crank it up to 120% and have at it.
But the point is that even though the race may look slow to some of you, and many of you could probably beat my lap-times blindfolded........
In order to keep up with the top three guys, I'm driving my tits off.
 
Last edited:
A little disclaimer: I agree with a lot of what's being said on other threads.
The AI in its present condition is a little sterile, and usually doesn't fight other AI racers much.
There's also the collision-problem, and the magical brakes at the end of a brake-zone.
That said, I have full faith and confidence that these issues will be fixed. Considering the leaps of improvement we've seen in other areas of this sim, it would seriously surprise me if we didn't see AI improvement as well.
All that however, is not the point of this thread, which is about the adaptive AI specifically.
So we now return to our regularly scheduled broadcast, which revolves around getting the adaptive AI up to player-speed quicker.

To start with, I will say that there won't be a video on how to use XML editing to get faster adaptive AI.
Why not?
Because I'm a f*cking moron, that's why. :D
I spent 2 hours testing some ideas, then a further 4 hours getting game-footage, doing narration explaining all this stuff, editing and so on.
Then after I was happy with the final edit, I decided to test out a few other things mentioned earlier in the thread to see if I could answer everything at once.
Bad news: The video was outdated before I had even rendered it...... *sigh*
Good news: I figured out a way to get a fully trained adaptive AI in 12 laps, without having to edit anything.
All you have to do is 12 laps without ever leaving R3E.

Technical section and a wall of text ahead.
If you have no interest in what I did or why it works, scroll down until you see another dotted line to find out HOW to do it.
-----------------------------------------------------------------------------------------------------------------------------------

The first thing I decided to test was whether you were better off training the AI without actually having AI on the track.
You're definitely not. In fact, you CAN'T train the AI without having AI on track.
I'll tell you why in a moment.

The second thing I wanted to test was whether you can train the AI using races against fixed AI.
Again, no you can't. Or rather, not directly.
But you can most certainly use fixed AI in another way to get the result you want.

As it turns out the lap-times in the XML are utterly useless to the initial training of the AI, they only come into play AFTER the AI is trained. What you should be looking for is the AI indexes just below them.
How it works......... correction, how I think it works is that the adaptive AI writes an index after each race.
The number of indexes vary a bit (not sure why) but the average seems to be six indexes for each car/track combo.
DURING the race the AI then uses these indexes to vary it's lap-times. If you start to fall behind, it goes to the next lowest index for the next lap. If you still fall behind, it steps down again and so on.
Obviously vice-versa if you're faster than the AI.
If you're still too fast after the AI uses its fastest index, it'll write a new one after the race, upping the ante the next time you race that combo. If the maximum number of indexes are already used, it'll delete the least used one.
Short version, if you outran the AI, after the race it'll delete the slowest index, and write a new index with a higher AI level than the current highest.
Fairly simple algorithm, no surprises there.

Okay, but the problem still remains. Since the AI start at 80% by default, It'll take a lot of races to get competitive, especially considering that the closer it gets to your lap-times, the smaller increments it'll increase by.
So my initial idea was that if you 'hacked' the XML and fooled the AI into thinking you were actually much faster, it would increase its speed in larger increments.
What I did was take my personal best for a combo, subtract a second from that, and enter that manually into the XML.
First hurdle I ran in to was making the mistake that one lap was enough to count as a race.
I mean, it's enough to get a lap-time into the XML so that should train the AI as well, right?
Nope, doesn't work like that. As I said, the lap-times are useless in training the AI.
What happens is that the AI compares your last lap-time to its last AI level, and if that isn't fast enough it tries a higher level next lap.
But the kicker is that it can't know whether it was successful until after the lap is finished.
And it won't discard its base-line until it has a new one to try.
Pure Boolean logic:
After Lap 1 it asks "I tried at 80%, was that enough?"
After Lap 2 it asks "I tried at 90%, was that enough?"
But unless it knows that the next level failed as well, it won't abandon the first one.
So you need to do two laps per session, otherwise you won't get anywhere.

It also explains why you can't train the AI without having AI on track.
Without AI, no comparisons are made, and thus no new indexes are written.

Alrighty then.
So I started doing two lap races, then edited the XML manually, and watched what happened to the AI indexes.
This is an example from my old XML file, showing Aquilas at Brands Hatch.

<custom>
<custom>
<!-- Index:0 -->
<custom type="float32">48.78387451</custom>
<!-- Index:1 -->
<custom type="float32">48.79570007</custom>
<!-- Index:2 -->
<custom type="float32">48.69625854</custom>
<!-- Index:3 -->
<custom type="float32">49.31530762</custom>
<!-- Index:4 -->
<custom type="float32">48.94433594</custom>
<!-- Index:5 -->
<custom type="float32">48.60922241</custom>
<!-- Index:6 -->
<custom type="float32">49.06225586</custom>
<!-- Index:7 -->
<custom type="float32">49.31475830</custom>
<!-- Index:8 -->
<custom type="float32">49.27456665</custom>
<!-- Index:9 -->
<custom type="float32">48.91101074</custom>
</custom>
<custom>
<!-- Index:0 -->
<key type="uint32">90</key>
<custom>
<custom type="float32">57.20594025</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:1 -->
<key type="uint32">106</key>
<custom>
<custom type="float32">51.62752914</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:2 -->
<key type="uint32">109</key>
<custom>
<custom type="float32">51.53813934</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:3 -->
<key type="uint32">111</key>
<custom>
<custom type="float32">51.20059204</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:4 -->
<key type="uint32">112</key>
<custom>
<custom type="float32">51.15437317</custom>
<custom type="uint32">2</custom>
</custom>
<!-- Index:5 -->
<key type="uint32">114</key>
<custom>
<custom type="float32">50.68688202</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:6 -->
<key type="uint32">120</key>
<custom>
<custom type="float32">49.31999588</custom>
<custom type="uint32">2</custom>
</custom>
</custom>
</custom>

This one is after 8 two-lap races if memory serves, and I've only edited the first 6 of those, so we're already seeing some adjusting.
The Index goes 90 - 106 - 109 - 111 - 112 - 114 - 120.
By this point I was extremely pleased with myself. :D
I had after all gotten the AI up to speed in very few laps.
Only....
When I subsequently tried racing it, it behaved oddly with wild variations in lap-times.
In hindsight it's pretty obvious why, since there are some large gaps between the indexes.
So if you fall behind the AI goes to the next lower index, and if that index is 10-12 percent lower....Well....

Okay, so by now I'd figured out that a good adaptive AI has tightly grouped indexes, making it possible for it to make small adjustments in tempo, both up and down.
But I couldn't figure out how to make it do that AND get up to speed quicker. As far as I could see you had to do race after race after bloody race to get the tight groupings.
So I thought I'd do a video showing how to at least get it up to speed quickly, and make the caveat that it would still need further races in order to become good at varying speeds.

After doing the video, as mentioned earlier, I decided to test AI training both without AI and with fixed AI.
Obviously, without AI, no indexes, and thus no training. Scratch that idea.
The fixed AI does however write an index. It's a fixed index obviously, but it does get written.
And this is the Heureka moment.
Also know as the "Why the f*ck didn't I think of that earlier?!" moment. :confused:

If you...
  • know your approximate AI level
  • know that good adaptive AI needs tight groupings
  • know how to get a specific AI index written
wouldn't it be possible to 'design' a tightly grouped index for the AI to follow?

I knew my AI level with NSUs at Brands was about 115% (give or take).
So I did two laps each at 113, 114, 115, 116, 117, and 118, with one AI opponent to write the index.
Which resulted in this index:

<custom>
<!-- Index:0 -->
<key type="uint32">113</key>
<custom>
<custom type="float32">61.74826813</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:1 -->
<key type="uint32">114</key>
<custom>
<custom type="float32">61.53697968</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:2 -->
<key type="uint32">115</key>
<custom>
<custom type="float32">61.08876038</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:3 -->
<key type="uint32">116</key>
<custom>
<custom type="float32">60.94928741</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:4 -->
<key type="uint32">117</key>
<custom>
<custom type="float32">60.79580688</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:5 -->
<key type="uint32">118</key>
<custom>
<custom type="float32">60.15036011</custom>
<custom type="uint32">1</custom>
</custom>
</custom>
A nice tightly grouped index, with about 1,5 seconds spread.
Purrrrfect. ;)
Then I did a full 8 minute race with 10 opponents and got a very serious fight (see video at end of post).
Even better, I re-checked the index after the race, and got this:
<custom>
<!-- Index:0 -->
<key type="uint32">113</key>
<custom>
<custom type="float32">61.74826813</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:1 -->
<key type="uint32">114</key>
<custom>
<custom type="float32">61.53697968</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:2 -->
<key type="uint32">115</key>
<custom>
<custom type="float32">61.08876038</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:3 -->
<key type="uint32">116</key>
<custom>
<custom type="float32">60.79580688</custom>
<custom type="uint32">2</custom>
</custom>
<!-- Index:4 -->
<key type="uint32">117</key>
<custom>
<custom type="float32">60.58061218</custom>
<custom type="uint32">1</custom>
</custom>
<!-- Index:5 -->
<key type="uint32">118</key>
<custom>
<custom type="float32">60.15036011</custom>
<custom type="uint32">1</custom>
</custom>
</custom>
Note that when compared to the 'artificial' one, the AI indexes are exactly the same.
There are some small variations in the lap-times of level 115 and 116, but apart from that the adaptive AI didn't feel the need to change anything.

One more thing to mull over, and that needs further testing.
Below the lap-times, there's an integer key.
The sequence is 1, 1, 1, 2, 1, 1.
Now, this is admittedly a very small sample-base, and one should be careful drawing conclusions on such a small data-set.
But I think it's the number of laps the AI used that particular level, in order to weigh each level.
So if it needs to change a level to adapt, it'll change the one that got used the least.
Furthermore, there are only seven laps, even though I did eight laps.
Which leads me to believe the AI only used the seven fastest laps, discarding the start lap.
So why did I complain earlier in the thread that the start-laps were dragging the average lap-times down?
Again, careful with the conclusions, but I would suggest that it only starts discarding laps once it has enough new laps to fill the entire index.
Earlier I only did two-lap races, and since that wasn't enough for each index to get a comparison, the AI never discarded any of them.
Again....I think. :)

Anyway....
Job done, that's how you can browbeat the AI to your level very quickly.
(And now I'm going to sleep for a friggin' fortnight....)
----------------------------------------------------------------------------------------------------------------------------------------

So to recap for those who didn't want to follow the geek-speak:

Two major rules to remember:
1. The more consistent your lap-times are, the more fun you will have.
2. The better your initial level-assessment is, the quicker you'll get good racing.

Step 1.
So, you first need to establish your approximate AI level at a given car/track combo.
If you're already fighting fixed-percentage AI you already have a good idea of where you're at.
If not, you need a little patience to do some qualifying sessions.
Use races against 8 AI opponents, select an fixed-percentage AI level, and use qualifying. Never actually enter the track yourself, just take note of the lap-times the AI does. And let them run at least 2 laps, preferably 3.
Keep changing the AI level and keep doing this until your best time would've placed you around 3rd or 4th.

Step 2.
The way adaptive AI works is that it needs to be able to slightly vary its speed in the race.
In order to build up the AI database, we need to run a series of two-lap races (6 of them to be exact).
Each of these are to be run with only 1 AI opponent, and without qualifying. Just place yourself in first, and off you go.
What you do is run two laps at your AI level from step 1.
The you need to run two more laps each at level -2, -1, +1, +2 and +3.

Example: Let's say your AI level is 112%.
The you need to run two laps each at AI 110, 111, 112, 113, 114, and 115.
And that's it, you're done.
You now have a fully-trained adaptive AI for that car/track combo.
You're welcome. :)

And just to illustrate it.....
I deleted my aiadaptation.xml file so I could start fresh.
I knew my AI level was about 115, so I ran two laps with one AI opponent at level 113, 114, 115, 116, 117 and 118.
That's the ONLY thing I did. I never edited anything, nor did any other technical magic.
Then I did a 'real' race with adaptive AI and I got this:

Now, if you're sitting there thinking "Pfft. 60 seconds a lap? You call that a fast AI, mate?"...
Then you're completely missing the point.
The object of the exercise is to get an AI that is adapted to YOUR level, not necessarily a FAST level.
If you want a fast AI, crank it up to 120% and have at it.
But the point is that even though the race may look slow to some of you, and many of you could probably beat my lap-times blindfolded........
In order to keep up with the top three guys, I'm driving my tits off.
Bloody brilliant Lars and thank you for going to all that effort
 
So I've found my skill level but when i go to set up a race with one AI, how can I run laps instead of timed races? Cheers
You can't, but it doesn't matter.
Perhaps I should've rephrased it. You need to run two laps under race-conditions. :)
Simply start the race as normal,then after you've done the second lap, quit out.

I've deleted my AI file as mine don't look anything like your Lars. Where yours show 113, 114 etc mine has 4 numbers ffs lol
:O_o: ?
Are you absolutely, positively sure that you're looking at the right file?
 
AiAdaptation ID="/aiadaptation">
<latestVersion type="uint32">0</latestVersion>
<custom>
<!-- Index:0 -->
<key type="int32">263</key>
<value>
<!-- Index:0 -->
<key type="int32">253</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:1 -->
<key type="int32">255</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:2 -->
<key type="int32">1685</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:3 -->
<key type="int32">1687</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:4 -->
<key type="int32">1703</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:5 -->
<key type="int32">1704</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:6 -->
<key type="int32">1706</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>
<!-- Index:7 -->
<key type="int32">1707</key>
<custom>
<custom>
</custom>
<custom>
</custom>
</custom>

This is just a part of my ai file
 
What about this

<custom type="float32">131.45152283</custom>
<!-- Index:1 -->
<custom type="float32">128.29748535</custom>
</custom>
<custom>
<!-- Index:0 -->
<key type="uint32">96</key>
<custom>
<custom type="float32">128.17712402</custom>
<custom type="uint32">1</custom>
</custom>
</custom>
I had ai set at 96 and I've done a 2 mins 8 sec
 
What about this

<custom type="float32">131.45152283</custom>
<!-- Index:1 -->
<custom type="float32">128.29748535</custom>
</custom>
<custom>
<!-- Index:0 -->
<key type="uint32">96</key>
<custom>
<custom type="float32">128.17712402</custom>
<custom type="uint32">1</custom>
</custom>
</custom>
I had ai set at 96 and I've done a 2 mins 8 sec

Hard to tell with only a section of the file.
Tell you what, give me an hour or two, and I'll do a quick'n'dirty vid describing both the process and the XML-file in detail.
Fair enough? :)
 
Yes brilliant thanks :)
Still uploading at the time of writing so give it a good 30 minutes or so.

Very quick and dirty one-take video showing the entire process from start to finish.
Pretty poor sound-quality, but I honestly couldn't be arsed to either edit or clean it.

For your particular combo, the primary key for Slovakia Ring is 2064, and the sub-key for the GT3 class is 1703.
 

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top