The new adaptive AI

Discussion in 'General Discussion' started by Paradox Agi, Apr 18, 2016.

  1. aloaz

    aloaz New Member

    Joined:
    Feb 24, 2017
    Ratings:
    +3 / 0 / -0
    Exactly! It did not make much sense to me either, it should have worked, but ...
    I edited and checked the file 3 times (looking for typing errors) and the error continued.
     
  2. Neil Bateman

    Neil Bateman Well-Known Member

    Joined:
    Mar 27, 2016
    Ratings:
    +48 / 0 / -0
    Been having some wonderful races with the adaptive AI now i have worked out exactly what t do with the xml file.

    I dont really do much if any training of the AI but by finding out what my level is, which is between 112 and 116 depending on the track and car, using 114 as an average, i can simply manually edit the xml file.

    As suggested i found i needed a few AI lap time entries below and above my level, i drove a few of my favorite tracks and recorded my best laps on each track in the xml file, i then entered AI level lap times from 110 up to 118, below 110 is too slow and 118 is too fast, each entry was about 3 tenths difference which meant an overall spread of about 3 seconds from slowest to fastest and made the entry at 114 my fastest lap time, its quite easy as its all copy and paste then lap time adjustments.
    That 3 second spread on the lap time gives me a chance on tracks i suck at and for me this works really well because there are some tracks i can win on and some tracks i am mid pack and some tracks i am nearer the rear, i dont want to win every race or lose every race, i just want to have cars to race with regardless of where we are in the field.

    Thanks to all those who have put so much time into figuring all this out and made it easier for those of us who dont have much time to spend trying to find the ideal settings that work best.:grinning:
     
    • Like Like x 1
  3. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +402 / 0 / -0
    Yep, I use much the same technique myself although I usually run a few races against fixed AI to get a decent starting point before inserting lap-times.
    But hey, if it works for you, so much the better. :)
    The Primer tool is mainly for those who can't and/or are uncomfortable with editing the file manually.
    But for those who do edit the file manually, here's one warning of gargantuan proportions.
    Never, ever try to insert more than 10 AI levels into the file, and be absolutely sure of the syntax.
    Otherwise, you end up like me. I accidentally deleted my back-up, there was a flaw in the syntax in the main one, so Raceroom deleted the whole thing and started over. :D :eek::oops:
    It's not that big a deal since I still have the database file, but still.....
    Just one of those things where you want to go out and find a man in a suit of armour to hit you with a rubber chicken. :p
     
  4. Neil Bateman

    Neil Bateman Well-Known Member

    Joined:
    Mar 27, 2016
    Ratings:
    +48 / 0 / -0
    I think I put 9 entries in for the AI on each track I have raced on, if I set 114 on strength I am very rarely under or over 2 seconds away from the AI times on my best and worst tracks so wanted to use that as a base. If I do encounter any issues I can always take the slowest and fastest entries out.
    Believe me I paid a lot of attention to making sure the entries are 100% accurate, but you do have to check, check and check again as 1 letter, number, dot or bracket missing or in the wrong place and its useless.
     
  5. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +402 / 0 / -0
    (answer to another thread......)

    Please note, all of this may or may not apply to the latest patch (April 5th).
    I haven't had time to play with it yet, so I have no idea how much the AI speed has improved.
    Also bear in mind that what I know about the AI system is based on reverse-engineering, info from the devs, trial'n'error and a few half-assed guesses. So don't take anything I say as gospel, and be aware that I may revise anything previously stated if I stumble across new info. That being said, for once I'm reasonably sure I'm right.

    Should you or should you not delete your AI index-file after an AI patch?
    Short answer, you shouldn't. But you may want to reset it.
    I know the usual response is not to delete it, because even if there is significant improvements in the AI, your old times will still be closer to your actual level than starting fresh.
    And that is very true. But there's a snag.
    Unfortunately, in order to explain WHY this is, we're going to have to do some math. :D
    I'll try to make this as geek-free as I possibly can, so please just bear with me.

    So, without going into too much detail, a brief intro to the AI adaption system. All the system does is take an average of your ten last laps for any given combo, and compare them to a set of indexes from earlier races.
    If it finds one that fits, it'll use that AI level for the next race. If it doesn't find one, it'll move the level up or down as need be trying to find the correct pace for the AI.
    After a while you end up with a file of a lot of different entries, hopefully centred around your true level.
    There's more to it than that, since the AI also uses entries from other combos, but all that isn't relevant to this particular question.
    So let's just assume that you already have a fairly decent padded index-file, and go from there.

    When you click 'Race', the AI, as mentioned, goes hunting through the index-file and looks for a corresponding AI entry for that combo with a lap-time that fits the pace of the player based on the last ten laps.
    Each entry consist of three things: the AI level, a lap-time, and a counter. And it's the counter who's the culprit in this case.
    But since it works in conjunction with the lap-time, we'll have to look at them both and see what happens AFTER each race.
    First of all, the lap.time listed isn't a lap-time of any specific car. It's the average of the fastest lap of the entire grid.
    Which means that if the player is running the same lap-times, he should be somewhere mid-pack where the fun is.
    So far, so good.
    However, in order to avoid sudden shifts in the AI level, as you run more races against the same AI level (and thus the same entry), the lap-times are averaged. So the first race results in a lap-time. The second race results in the average of the two lap-times. The third race, however, isn't the average of all three lap-times. It can't be, since the file only contains one lap-time.
    And here's where the counter comes into play. The lap-time written into the index after the third race is the average of the new lap-time and the original lap-time TIMES TWO.
    And the fourth race will result in the average of the new lap-time plus the old lap-time times three.
    So the formula is as follows:

    Lap-time written = ((old lap-time X counter) + new lap-time)/ counter + 1

    Which is great as long as there isn't any major changes in the AI speed.
    However, here's what happens when we, like in the January patch, significantly increase the AI speed.

    Keeping the numbers easy, let's say the player has run laptimes of 120 seconds, and the AI has adapted to run at the same speed at level 100. Let's also assume that the player has run 10 races against this combo.
    So the AI entry will look like this (without all the XML code).
    100
    120.0000
    10
    AI level 100, 120 seconds, and a counter of 10. With me so far?
    Good.
    Here comes the January patch, and the AI gets 5 seconds faster, but the player still runs at 120 seconds. What happens to the lap-times written?
    Well, the formula states that the new lap-time written for that AI level will be:
    ((120 X 10) + 115)/11 = 119.5
    Or in other words, even though the AI ran at 115 seconds, the lap-time listed for that AI level will still be 119.5.

    Okay, so the lap-times in the index-file are no longer correct, why is this a problem?
    It's a problem because the AI uses those lap-times to find the appropriate AI level to run at.
    In the above example, the AI will continue to use level 100, even though it's now 5 seconds faster than the player, because the index-file lists the lap-time as 119.5
    Yes, eventually it'll get nearer the correct lap-time, but more entries you have the longer it'll take to re-adapt.
    And given the law of averages, it'll never reach the actual lap-time the AI runs at.
    Combine this with the fact that the R3E AI is kinda dependant on having the right AI level set to get good racing, and we have a slight prob.....er, challenge to be solved.

    So what can we do about this?
    Well, the obvious solution is to delete the index-file and start over.
    And while that will certainly work, it'll also mean having to re-train the AI across the board.
    It's a bit like curing a headache by cutting off the head. :)

    Second option is to use @pixeljetstream 's tool found here: https://forum.sector3studios.com/in...tabase-prototype-call-for-participation.5632/ and delete all the AI lap-times.
    A better option, since that way you still keep the player lap-times. But it still means having to do a lot of retraining.
    Unless you're very clever, and you kept the old database from the tool and re-insert the AI times as needed. ;)
    The tool inserts entries with a counter of zero, which leads us to........

    The final and most elegant solution, we can just reset the counter. Take a look at the equation mentioned.
    If the counter is zero, there's no averaging made, and the entry written after the race will be whatever the AI ran at.
    If you're a very patient man, you can do this manually by going through the index-file.
    Maybe we can talk @pixeljetstream into coding an option for the tool that does just that.
    Personally, I use a text-editor with a 'search and replace' function to do the job.
    But whatever option you use, once the counters are reset, you keep the AI levels at their current values, without contaminating the lap-times with the old AI values.
     
    • Like Like x 2
    • Informative Informative x 1
    • Creative Creative x 1
  6. pixeljetstream

    pixeljetstream Well-Known Member Beta tester

    Joined:
    Jan 29, 2015
    Ratings:
    +412 / 0 / -0
    @CheerfullyInsane can you please tell me what option I should add ;) (what pattern to search, reset etc.?). We could also optionally limit resetting to certain classes, if that makes any sense.
     
  7. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +402 / 0 / -0
    Well, an AI entry looks like this:
    <!-- Index:0 -->
    <key type="uint32">102</key>
    <custom>
    <custom type="float32">130.89179993</custom>
    <custom type="uint32">12</custom>
    </custom>

    What we're looking to replace is the bit in red (12 in this case)
    So anything between <custom type="uint32"> and </custom> should do the trick.
    The only other integer I can find is the AI level, and that's between <key> tags, so that shouldn't be affected.
    Not sure how wild-cards work in XML, but one issue is that it should be replaced no matter if it's 1,2 or 3 digits.
    Okay, 3 digits is unlikely, but still. :D

    But you can use the button that is currently being used for deleting the AI times. As it turns out, that's unnecessary. (sorry about that. :oops: )
    By resetting the counter, the AI ignores the lap-time but keeps the level, meaning it'll start in the same place without getting the average screwed in the process.
    As it turns out, if the laptime for one entry drops below the laptime for the next level, there's a bit of code in place that simply scoots the entire thing downwards (or upwards if needed), so there shouldn't be any problems with overlapping.

    And I don't think we need an option for separate classes.
    I mean, if the AI hasn't changed for that particular combo and you reset the counter, all you've done is knock the average back a bit. If there's no change in speed, the next race should be fairly close to the same lap-time and the whole aggregate averaging simply starts over.
    I realize I'm tempting hubris here, but I can't see a downside to simply resetting the counters across the board.
    Famous last words. :D
     
    • Funny Funny x 1
  8. pixeljetstream

    pixeljetstream Well-Known Member Beta tester

    Joined:
    Jan 29, 2015
    Ratings:
    +412 / 0 / -0
    done
     
    • Like Like x 2
  9. Balrog

    Balrog Well-Known Member

    Joined:
    Apr 10, 2015
    Ratings:
    +466 / 0 / -0
    I tested the new McLaren last weekend in Bathurst and noticed the AI behind me followed me into the slipstream when I tried to break the tow ahead of him and I moved off the racing line. This is such a cool feature, but I haven't seen it before the last patch on other tracks. I don't have the time to test it, so may I ask is this a new/returning behaviour of the AI, or is it not yet implemented on every circuit?
     
  10. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +402 / 0 / -0
    I think it's always been there in some way, shape or form.
    I've noticed it a couple of times at least, so I don't think it's restricted to certain tracks.
    Doesn't mean that it hasn't happened more often, just that I haven't noticed it more often. :D
    But in this case, this is pure guesswork.
     
  11. jimortality

    jimortality Active Member

    Joined:
    Jun 11, 2015
    Ratings:
    +39 / 0 / -0
    I don't seem to have any AI data for Hungary DTM16. I've followed the normal procedure, 2 lap race but it doesn't seem to give any AI times.
     
  12. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +402 / 0 / -0
    Check your assets-file and see if the DTM16s are actually there.
     
  13. jimortality

    jimortality Active Member

    Joined:
    Jun 11, 2015
    Ratings:
    +39 / 0 / -0
    Yes they are and there are ai entries for a few other tracks but not for Hungary.
     
  14. Matthew_Wheeler

    Matthew_Wheeler Member

    Joined:
    Apr 20, 2016
    Ratings:
    +17 / 0 / -0
    Wait, is that all you need to do to? Or are there other steps?
     
  15. jimortality

    jimortality Active Member

    Joined:
    Jun 11, 2015
    Ratings:
    +39 / 0 / -0
    Sorted it, my fault. I watched the 10 min video again on the previous page.
     
  16. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +402 / 0 / -0
    Nope, two laps will give you an AI entry.
     
  17. GregoryLeo

    GregoryLeo Well-Known Member

    Joined:
    Feb 22, 2015
    Ratings:
    +360 / 0 / -0
    OK, You all convinced me to give the adaptive AI another try. I've been somewhat frustrated with getting a good setting on the AI in championships.
    So I deleted the AI file, picked a couple of my favorite cars. And did a few 5 lap races against just one ai. That way there was no battling and I could just do laps.
    OMG what a difference!:flushed::) I just had one of the closest set of races I've ever had in this sim.:grinning: The battles were tighter and more intense than ever. The AI just aggressive enough to keep me on the tips of my toes:smilecat:. There were a couple of racing incidents that knocked me back a couple of positions but nothing terrible. In fact it kept me in the pack fighting for position. Which I love!;)
    The first race I qly'd 5th and managed p7 after totally blowing the pit stop. (don't get me started on that:mad:) But that put me in p2 on the second race. 5 minutes into that race I was in p7:confounded:. With no incidents, just fast competitors.
    Came out of the pits in p11, GRRR.:confused: SO I tightened my focus, settled in, and started seriously racing. No more screw ups!:rolleyes:
    Well I took p1 on the third to last lap:p. And had to fight to keep the position. I finished the race with p2 only a half a second behind me.:D
    I'm hoping the rest of the six track champ is equally challenging.:cool::tongueout:
    Thanks for the inspiration I really do appreciate it.:grinning:
     
    • Like Like x 1
  18. Eisprinzessin

    Eisprinzessin Well-Known Member

    Joined:
    Dec 7, 2015
    Ratings:
    +315 / 0 / -0
    No more hitting from behind?

    I get hit every single race 3-4 times from behind (driving adaptive AI). Its really frustrating.

    And no, the dont hit me because i am so slow, i am in the lead or second and drive the corners like always ;-)
     
    • Funny Funny x 1
  19. fl0wf1r3

    fl0wf1r3 Well-Known Member

    Joined:
    Apr 24, 2016
    Ratings:
    +235 / 0 / -0
    wow, do we have to become coders to use the AI in Raceroom? isn't it something that Sector3 could/should fix in the AI?
     
  20. Eisprinzessin

    Eisprinzessin Well-Known Member

    Joined:
    Dec 7, 2015
    Ratings:
    +315 / 0 / -0
    No critism please