Adaptive AI & the Tool, How-To

Discussion in 'Community Workshop' started by CheerfullyInsane, Mar 20, 2019.

  1. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Okay, so the usual argument against using the Adaptive AI (AAI), is that it takes too long to set up.
    Personally, I don't agree with that, but I can see the merit of the argument.
    So what if you could get someone else (in this case, me) to do the setting up for you?
    It's actually pretty easy, all you have to do is use the AI Primer Tool by @pixeljetstream .

    Normally, I'd do this as a video but I've just bought a new PC and I have neither webcam, mics nor OBS set up on it yet so a text-version will have to suffice.

    A brief bit on the theory behind it, and we'll get to the good part.
    The AAI works by comparing the players lap-times to a database of AI laptimes, and picking the appropriate level. If there are no entries for that particular car/track combo, it'll use the average of all entries for the car in use. If there are none of those it'll use the average of all entries for that track. If none of those exist either. it'll average all entries the player has, and start there.
    With me so far?
    Good. So the basic premise is that the more entries you have, the better an average you're going to get, and thus the higher chance you have of the AAI picking the right level for any new combos you try.
    In my experience, once you have 4-5 tracks done for any particular class, the AAI gets it right in pretty much the first try.
    The problem though is that the database is local, so each player has to do each combo for himself before it works.
    Which is where the Primer Tool comes in.
    Not only can it generate approximate laptimes for any given combo (given enough information) it can also use other players database as a seed. All you need is a decent sampling-base, which is where yours truly comes in.

    So you're going to need two things: An XML-file from someone else (see attached), and a copy of the Primer Tool (https://github.com/pixeljetstream/r3e-adaptive-ai-primer)
    Also, I strongly suggest you back up your aiadaption.xml file before doing any of this, just in case.

    So, the Primer Tool is completely unintrusive. It doesn't install anything.
    Just extract it to a folder of choice, and we're about ready to go.
    Next, put the base.xml file into the seeds sub-folder.
    [​IMG]

    Then fire up the Primer Tool, and you'll see something like this (only without the colored boxes)
    [​IMG]
    The red box is that car-class. If the desired class doesn't show up here, it's because there are no entries in the database for it.
    The blue box is the track. If there are no entries listed here, either there are no entries in the database, or there aren't enough for the Tool to work. It needs a minimum of two entries, with a minimum of 5 levels between them. If there is an entry, but no player best, it means there are entries in the database, but no player lap-time has been registered. This is completely normal if you e.g. use other peoples files as seeds.
    The green box contains approximate lap-times for any given AI level. Again, it's dependent on having at least two entries with 5 levels between them.

    Okay, so how do we use the Tool with a seed-file?
    Well, first of all, while I can supply AI lap-times, there's one thing I can't tell you; how fast you are. :)
    So for any given combo, you need your own lap-times.
    Easiest way is to simply do a race with the desired combo, and using 0 AI opponents. Do 4-5 flying laps, and you now have a decent average lap-time to work with.
    Alternatively, if you know your average lap-time, you can simply input the correct AI levels. While having a player best in the database is preferable, it's not strictly necessary.

    Once you have all the above, it's 4 mouse-clicks to apply the AI levels.
    [​IMG]

    Select the class, select the car, select the desired level to center on, and hit apply. :)
    One thing to be aware of is that the database lists the player BEST and compares with AI AVERAGE.
    So unless you happen to be absurdly consistent, I strongly suggest that you move it down a 2 levels.

    So what do you do if the desired track isn't listed?
    Insert the appropriate levels for the tracks that ARE listed, then run the desired track using AAI.
    With 4-5 previous track-entries, there's a very good chance it'll hit the right level straight away assuming that you're reasonably consistent.

    Couple of details to be aware of:
    • Any corrections made to the XML file while R3E is running will be overwritten. So you never have the Tool and R3E open at the same time.
    • Consistency wins in this particular case. We're trying to get the AI to adapt to you, which is impossible if your lap-times are all over the place. So make sure you can run consistent laps, within two seconds of each other and preferably within one second.
    • The approximate lap-times generated by the Tool are just that, approximate. They are, for lack of a better phrase, educated guesses. Usually they're pretty precise, but you will get the odd weird thing happening from time to time. Not a big deal since the AAI is dynamic and thus keeps adapting. Just be aware that this is not an exact science.
    • The lap-times are build upon 'real' lap-times, which means that the closer you are to the level of the seed you're using, the less guesswork is involved. It will probably work at either extreme, but being at roughly the right level in the first place is better.
    • Lucky for us, I'm about as common as muck. :) I usually run around 95-110 depending on the combo so the XML seed should fit the vast majority of users.

    As I said, it usually requires 4-5 tracks for any given car to make the AAI hit the right spot.
    Right now the XML-seed contains at least 5 entries for the following classes:
    GT Masters 15 & 18, Acquila CR1, Audi TT 16, BMW235i, DTM 92* , FRX, FRJ, Group 4, GTR 1, GTR 3, Porsche Carrera Cup.
    I'll continue to update the file as and when I do the various combos. Just be aware that I'll be doing them in order of preference for me. So if you're looking for modern DTMs, you're going to have to wait a while since I hate the bloody things. :D
    Also, I usually use the same 5 tracks as a baseline; Zandvoort GP, Zolder GP, Nürburgring GP, Road America and Mid-Ohio Full.
    No particular reason aside from these are 5 tracks I know pretty well, so they make a good baseline. But if you're looking for a specific class, you may want to get some laps in on those tracks.

    * Careful with the DTM92, GTO and Touring Classics. They're due a physics update, so they'll probably need a new seed-file once they're released.

    Edit 240319: Added FR3, WTCR 18, Audi TT RS and GT4 to base.xml
    Edit 040419: Updated assets.txt enabling Group C and Carrera Classic
    Edit 070419: Added GTR2, Group C, FR2, P1 and P2.
    Edit 200419: Added DTM 15.
    Edit 050619: New assets.txt enabling the FR90. Added FR90 and FRUS to the database.
    Edit 121019: New assets.txt enabling Bilster Berg and Dubai. Added Cayman Trophy, KTM X-Bow, TCR19.
     

    Attached Files:

    • Like Like x 4
    • Love it! Love it! x 3
    • Informative Informative x 2
    • Wonderful Wonderful x 1
    Last edited: Oct 12, 2019
  2. Ablaze

    Ablaze Well-Known Member

    Joined:
    Mar 16, 2018
    Ratings:
    +82 / 0 / -0
    This is exactly what I was looking for. A text-based tutorial with extra candy in form of an attached xml file. :D
     
    • Like Like x 1
  3. Bull Shark

    Bull Shark Well-Known Member

    Joined:
    Mar 14, 2019
    Ratings:
    +68 / 0 / -0
    Thanks for the tutorial. Will test it asap..
    I love the adaptive AI in RR3. The developers did a great job. For me the best AI from all the racegames I have.
     
  4. Goffik

    Goffik Active Member

    Joined:
    Jun 30, 2017
    Ratings:
    +43 / 0 / -0
    Thanks for this. It looks like I'll be taking my sim-racing offline in the near future, so this will come in very handy!
     
  5. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Updated the XML-file.
    See OP.
     
  6. Neil Bateman

    Neil Bateman Well-Known Member

    Joined:
    Mar 27, 2016
    Ratings:
    +47 / 0 / -0
    Quick question, in the instructions from the GitHub link part of it reads: To enhance the database with results from other players, dump as many "aiadaptation.xml" files as you can find in the "/seeds" directory.
    So obviously you need to rename the file so it does not overwrite your own, if you do that will the primer tool read the xml file regardless of what you rename it?
     
  7. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Yep, the Tool doesn't care what it's called.
    Presumably there might be a limit on the allowed number of characters, but that aside, you're golden.
     
  8. Bull Shark

    Bull Shark Well-Known Member

    Joined:
    Mar 14, 2019
    Ratings:
    +68 / 0 / -0
    Quick question. When you update the file, do I need to start all over again as in the first time I altered the AI?
     
  9. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    No, no.
    Just replace the base.xml in your seedfolder with the new one.
    It contains exactly the same info as the previous version, the only thing changed is that I've added X number of new classes for each version.

    The only thing you shouldn't do is have more than one version of it in your seedfolder. Having multiple entries with exactly the same laptimes tends to give odd results. :)
     
    • Like Like x 1
  10. Bull Shark

    Bull Shark Well-Known Member

    Joined:
    Mar 14, 2019
    Ratings:
    +68 / 0 / -0
    Ok, so the info I change in that file will be exported to a game filecontainer of RaceRoom. It is more like a temporary storage with info. Once updated again, the new info wil be exported to RaceRoom again?

    Or do I miss something.:oops:
     
  11. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Actually, the base.xml doesn't change anything on its own. It's basically a copy of my aiadaptation.xml that is being used by the Tool as a seed.
    Once you fire up the Tool the laptimes in the base.xml is then transferred to the Tool database.
    And you can then use the Tool to insert those laptimes into your own R3E aiadaptation.xml.
    Make sense?

    Now, if your next question is "why don't we just use the base.xml as our aiadaptation.xml and skip the tool altogether?", the answer is simple.
    Your pace may not be the same as mine, making the whole thing pointless.
    The reason for using the Tool is that it can extrapolate approximate laptimes for any given level (and thus player-pace) based on the information in the base.xml
     
  12. Bull Shark

    Bull Shark Well-Known Member

    Joined:
    Mar 14, 2019
    Ratings:
    +68 / 0 / -0
    thanks for the explanation.. I'm gonna install the tool. Thanks for your effort of course much appreciated.
     
    • Like Like x 1
  13. Bull Shark

    Bull Shark Well-Known Member

    Joined:
    Mar 14, 2019
    Ratings:
    +68 / 0 / -0
    Ahh I understand the road behind all this I believe.

    The base file generates the classes in the left column of the tool. The track times are my track times and the right AI times are the levels I should pick from?
     
  14. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Yep, pretty much.
    But as I stated in the OP, it compares players best to AI average, so it's usually a good idea to go down a notch or two.
     
    • Like Like x 1
    • Agree Agree x 1
  15. Bull Shark

    Bull Shark Well-Known Member

    Joined:
    Mar 14, 2019
    Ratings:
    +68 / 0 / -0
    Stupid question but why do I not see any AI times?

    Capture.PNG
     
  16. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    ;)
     
    • Like Like x 1
  17. 82charlie

    82charlie New Member

    Joined:
    Mar 21, 2019
    Ratings:
    +2 / 0 / -0
    Somebody has been spending a lot of time with Porsche Carrera Cup class:), according to new base.xml file. But where is Group C class?
     
  18. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    It's a little hard to do AI tuning before the cars are released. ;)
    And yeah, the Carrera Cup is probably my fav car right now. :)
     
  19. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Added updated assets.txt to the OP, enabling both the Group C, and the Carrera Cup Classic for the Tool.
    Still working on getting some sample laptimes for them. Should have something uploadable Saturday/Sunday.
     
    • Like Like x 1
    • Love it! Love it! x 1
  20. CheerfullyInsane

    CheerfullyInsane Well-Known Member

    Joined:
    Oct 24, 2015
    Ratings:
    +336 / 0 / -0
    Strike that. My C-drive decided to get corrupted, couldn't even boot from the bloody thing. :mad:
    Got the basics back up and running again, but there's a lot of re-downloading, setting up, and generally getting back to normal before I'll be able to play anything. :rolleyes:
    So if you're waiting for an updated base.xml, you'll need a little patience. :)