AI Racing Championship - ETK Series

Discussion in 'Videos, Screenshots and other Artwork' started by Peregrinus, Jun 29, 2024.

  1. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    Hi everyone!!

    I pretty much enjoy random outcomes and BeamNG in-game AI helps me leverage it for my own amusement, I decided to create this championship as a way to express my analytical creativity. So
    I'd like to share my creation. It is a WIP and when I post a new video, I'll add it to this first thread. You don't have to keep coming to the first thread though. I also add as an answer to this post when the episode is ready.

    Main Idea: Use the in-game AI in BeamNG.Drive to create a championship of Virtual Characters created by myself. Their stories will be developed as the championship envelops.

    Race Rules: There's no rule other than 1st to finish wins. 2nd is second and so on. Pointing system is as follows:
    Code:
    || ---- Group 1 ---- || ---- Group 2 ---- || ---- Group 3 ---- ||
    || Position | Points || Position | Points || Position | Points ||
    || -------- | ------ || -------- | ------ || -------- | ------ ||
    || 1st      | 15     || 1st      | 14     || 1st      | 13     ||
    || 2nd      | 12     || 2nd      | 11     || 2nd      | 10     ||
    || 3rd      | 9      || 3rd      | 9      || 3rd      | 9      ||
    || 4th      | 8      || 4th      | 8      || 4th      | 8      ||
    || 5th      | 6      || 5th      | 6      || 5th      | 6      ||
    || 6th      | 4      || 6th      | 4      || 6th      | 4      ||
    || 7th      | 2      || 7th      | 2      || 7th      | 2      ||
    || -        | -      || -        | -      || 8th      | 1      ||
    || DNF      | 0      || DNF      | 0      || DNF      | 0      ||
    
    For each 2 laps, the RISK factor will change (check AI Config below)

    I do not have a very fast computer to race all the 22 competitors at the same time, so I divided them in 3 groups based on their qualifying positions as follows:
    Group 1 - 1st, 4th, 7th, 10th, 13th, 16th, 19th,
    Group 2 - 2nd, 5th, 8th, 11th, 14th, 17th, 20th
    Group 3 - 3rd, 6th, 9th, 12th, 15th, 18th, 21st and 22nd
    :
    've been using the console to define their "aptitude", or basically, how they drive. The config used is the same as the one available at the AI UI called "Risk". For each moment of the Qualifying and Races I used different random numbers using the following formula in Excel
    Code:
    =randbetween(70,90)/100
    
    To define the Path of the AIs, I first created a track using the Race Tool inside the F11 button (I forgot what it is called). Then, I used the Test Race app inside the Race Tool to get access to the path of my track. Once I got the path, I used the following code in the console for EACH driver:
    Code:
    ai.driveUsingPath{
        wpTargetList = {
            'xx',
            'yy'
        },
        driveInLane = 'off',
        avoidCars = 'on',
        noOfLaps = 4,
        aggression = <risk_value_as_defined_above>
    }
    
    For the races, I used the same code above and added a Risk Bonus as follows:
    Code:
    If a player has qualified from the 16th place, no bonus is applied.
    If the player qualified between 10th and 15th, a bonus of 0.01 is granted.
    If the player qualified between 05th and 09th, a bonus of 0.02 is granted.
    If the player qualified between 01st and 04th, a bonus of 0.04 is granted.
    
    But don't pay attention to that Risk Bonus as it only made things worse lol. I won't apply this bonus in future races.

    Observations:
    1. The AI Config will change in future races as I discovered some "hidden" parameters in the code which I'm still playing with.
    2. The "hidden" parameter mentioned above made the awareness of the AI very shallow, so they were basically driving blind on the races I'll post below.
    3. The videos are Game Sound only. I didn't add narration or music to it.
    4. The plates stopped working as expected in the last video, for an unknown reason, so I created a skin for each driver that will be shown in the next race
    Extra Bonus:
    I also automated the method of deploying a car, to make it faster and easier by using the following code (this code is the real one I used to deploy one of my characters):
    Code:
    core_vehicles.spawnNewVehicle('etk800', {config = 'vehicles/etk800/844_250_A.pc', paintName = 'Jet Black'}); core_vehicles.setPlateText('J-Fraga')
    

    Before we jump into the videos, I'd like to know your ideas and constructive feedback for improving the AI in BeamNG and make them a bit more interesting to watch, with big crashes and other potential funny things, as long as they manage to finish the race. :D

    Thank you for taking your time!

    LET'S STOP AND JUMP TO THE RACES
    Edit (2024-11-07)
    : As I can't add more than 15 pieces of media in a single post, the links for the Automation Test track have been removed, but you can still find within the thread, or going to my YT channel.



    Edit (2024-12-22): As I can't add more than 15 pieces of media in a single post, the links for the Big Ring track have been removed, but you can still find within the thread, or going to my YT channel.



    Edit (2025-02-09): As I can't add more than 15 pieces of media in a single post, the links for the Redwood Forest track have been removed, but you can still find within the thread, or going to my YT channel



    Forth Circuit: East Coast of the USA
    Civetta Exposition


    Qualifying Bottom 8


    Qualifying Mid 7


    Qualifying Top 7


    Group Distribution + My lap


    Race Day - Group 3


    Race Day - Group 2


    Race Day - Group 1



    LAST EVENT - SERIES CONCLUSION
    Fifth Circuit
    : Hirochi Raceway at the East Coast of the USA

    Qualifying Bottom 8



    Qualifying Mid 7


    Qualifying Top 7



    Group Distribution



    Race Day - Group 3


    Race Day - Group 2


    Race Day - Group 1
     
    #1 Peregrinus, Jun 29, 2024
    Last edited: Feb 25, 2025
    • Like Like x 3
  2. N o W a r

    N o W a r
    Expand Collapse

    Joined:
    May 16, 2017
    Messages:
    15
    What an awesome project <3 thanks for sharing it. The Small Island Loop is so much fun to do laps.

    Have you tried using the UI APP - AI Control? It allows you to change certain settings such as target speed or awareness

    I could be wrong, but I think the AI is more accident prone when you have other vehicles (AI or human) on track and around them. For example, when doing an AI race I find the AI will lock up the brakes more if you are close behind them. AI reacting to each other on track is how you get more 'interesting' driving with accidents ect. There is an 'aggression' setting I have seen somewhere but cant remember at the moment.

    Another way to have more variety in the racing would simply to have cars with differing performance. If every car can brake and accelerate at the same pace, not much interaction between the cars will happen. Maybe give some cars more boost, others with brake upgrades etc etc will mix it up more

    Good luck, looking forward to seeing the Small Island race :cool:
     

    Attached Files:

    • AI.png
    • Like Like x 1
  3. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    Thank you for your reply and interest.
    I went with the approach I mentioned above due to the lack of functionality of the UI APP - AI Control you mentioned. For some reason, when I have more than 3 spawned AI cars, the UI APP starts to misbehave and not update the Risk setting to what is currently set up on the car, leaving me kind of blind to what config was set in a specific car. Which bring me to your next suggestion.

    To spicy things up, I was only using the Risk settings, but it just determines how "aggressive" the car is. The awareness means that the car will behave like you said, locking up the brakes, or even just pretending like there's nothing on the road and ramming into other cars.

    However, after spending some many hours reading the AI file and trying to understand what is happening, I discovered some interesting configs that I'm actually eager to see how it will play out. The recordings of the qualifying have been already made.

    SPOIL Alert:
    The AI has, on average, completed the Ring in about 1m40seconds.

    What is delaying me is that I accidentally deleted my car introductions when organizing the files for this next step (my cloud provider duplicated folders automatically, and when deleting that "duplicated folder", it wasn't duplicated after all... :mad:) Anyway....

    I'm working on it and I'm glad that there are people liking it

    PS: I'm a horrible driver in BeamNG.
     
  4. N o W a r

    N o W a r
    Expand Collapse

    Joined:
    May 16, 2017
    Messages:
    15
    I am very interested in this! Keep us posted what you learn. :D
    I am currently, and slowly trying to learn from available documents about all things BeamNG. I would like to create my own championships with progression from folk racing to top level GT stuff, almost like a racing career.

    I think the AI has been lacking for the last few updates, or more? I made a thread and got one reply saying they think an AI update is one of the next big overhauls soon coming.
    Racing in BeamNG is so much fun, and if the AI could be tweaked or altered to customize the experience it would only be icing on my cupcake.
    It feels like you have to trick the AI into racing, but even then they tend to act as traffic.

    I think my best time on the Small Island Ring road with the Ibishu BX LS (M) is around 1:38.
     
    • Like Like x 2
  5. ArsPro

    ArsPro
    Expand Collapse

    Joined:
    Oct 13, 2022
    Messages:
    1,040
    Oh hey man, i enjoyed your ETK championship, it is awesome :cool:

    Do you plan to make Small Island race with ETKs too or something different?:rolleyes:
     
    • Like Like x 2
  6. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    I'll address all your points NoWar, because they are all valid, including a re-address of an older point you made on the other messages that I liked a lot and now that I learned how to programmatically deploy cars with the .pc file extension (thanks to some YT video I learned from, I think it is DavidInArk channel), I think I can do it. Thinking about giving upgrades to the losers, so they can "catch up" with the winners and keep things interesting :p

    You should create a championship indeed, it is way more work than it seems to be, but it is fun :D
    I'm doing AI ones because I lack the time to keep organizing people, so I can do at my own pace.

    For the AI point, I think I kind of found a great fine tunning, look at the Save Reinaldo Cabral did in his qualifying lap:



    The usual AI behavior (default in the code) makes the AI stop and restart from where it stopped, but with the fine tunning (also in the code, but not default), it made the AI correct and keep racing, kind of risking more. It was a surprise when I saw it today. Simply amazing.

    But there are no other competitors in the track, so I'm not sure how well it will play out with the other AI in the track yet.

    About racing in BeamNG, yesterday I gave it a go on the race track inside the East Coast map. I suck. I only have my keyboard and I started driving with my mouse (same as on ETS 2), it worked quite well, but I need to train lol. I'm not good lol
    --- Post updated ---
    Hey ArsPro!!
    Thanks for the word that you enjoyed it.
    I'm doing an ETK championship only, but I would like to do many different brands in a future series. For now, they are all stock ETK 250 Automatic. I only found 3 models that shared a similar build.

    Regarding the championship, I guess I'll probably do 6 tracks. If you have any suggestions of tracks, I'm all ears.

    My idea is to do the 3rd track in a race track, I tested the East Coast already (as we are in the US for the Small Island race), but the track is too big. I found a small one within it, but still uncertain.

    I also would like to do city track like in the Italy or West Coast (San Francisco jumps), maybe both. But speaking out loud, I would like to do a "round the world" tour. I already started in New Zealand, flying to a Small Island in the US which is near California, then fly to both coasts (West and then East). Fly to Europe in Italy and then conclude in the Pacific, at that Jungle Island. But there's also Hirochi Raceway, which is very nice too....so, yeah, I'm still rambling in ideas :D But at least I can share and rethink them through afterwards.
     
    • Like Like x 2
  7. ArsPro

    ArsPro
    Expand Collapse

    Joined:
    Oct 13, 2022
    Messages:
    1,040
    Oh, that's very nice :cool:
    I suggest putting myself in a race lol (Ari Sorrentino from Italy), if possible of course :rolleyes:
     
    • Like Like x 1
    • Agree Agree x 1
  8. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    I never thought about adding people to the championship. That's a great idea :D
    But I'll add you in a future championship, or create an ascension type of competition for the Main Championship if many people would like to take part into it too. But no promises, not sure when I'll be able to do it
     
    • Like Like x 2
  9. N o W a r

    N o W a r
    Expand Collapse

    Joined:
    May 16, 2017
    Messages:
    15
    Interesting, I love it. The video was great to see. I wonder how that will translate into them racing side by side.


    One of the most frustrating things about trying to race the AI in BeamNG is being brake checked by the AI just because you are close behind them. Again, them acting more like traffic instead of competing for a position in a race. This post has the video and time stamps to show an example.


    Ill drive if given the opportunity!
    I have a few track suggestions ;)
    The new island dock and oil refinery area in West Coast USA has some great looping roads
    The handling circuit at the Automation even tho you started there. It is smaller, tons of hills, twists, and guard rails to keep them in check lol.
    Hirochi is a classic too, with lots of configs, and the old version is available.
    Industrial Site map has some potential.
     
    • Like Like x 2
  10. N o W a r

    N o W a r
    Expand Collapse

    Joined:
    May 16, 2017
    Messages:
    15
    I thought I would bring us back here so our conversation wouldn't overtake his thread.

    This is the first time I have used the console in Beam.
    I was reading just earlier this weekend about the different consoles. I assume the "for vid, veh in activeVeh..." (top most) code should be input into the GE LUA console?
    I tried this and it felt successful. There was still some instances of an odd flow (not a proper racing line) lets say, and maybe this comes down to the actual path that has been built into the map. This was a mod map, but I know the same issues occur on WC USA and Hirochi race tracks.
    Maybe that is something I should learn more about next.

    I should only have to input the command once per loaded map/scene correct? If I reset physics for all vehicles that should not affect the input?
     
    • Like Like x 1
  11. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113

    I would like to keep this thread regarding my championship, that's why I replied over there.

    As I'm about to finish the Qualifying (Missing some takes from the track and of all the drivers), I didn't want to reply to you yet.
    Maybe you could create a new thread about this AI thing somewhere else?
    I'm quite new to using forums, so I get lost very easy here.

    Quote me there and I'll reply to you with what I know.
     
  12. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    Hi again, NoWar!!
    Sorry for not replying you earlier about this, I wanted to get the qualifying video ready, which I just finished. Now it is rendering, and will take the rest of the day, so I'll be able to upload tomorrow.

    Regarding the tracks, now it is time for me to start looking for the next track (and build it). I think I'll take the West Coast and I'll investigate the areas you mentioned. I'm looking for something that would take not more than 2 mins to finish, the best would be 1.5 minutes like the Big Ring.

    Thank you so much for interacting with me on this creation of mine!
    --- Post updated ---
    I guess I'll reply to you here. I don't know how to keep consistent in different threads lol. I'm kind of behind on Forum's matters :p

    The first thing I did when I opened BeamNG was to open the console, not even drive lol. It was from a video I found by accident on YT a few months ago.
    The assumption you made is correct, you have to use the "MAIN" console when you are iterating between vehicles. But the beauty of what the Devs did is that there are individual consoles for each deployed car, so you can personalize them, specially when applying the AI configs.

    To you last question, yes, you do it once. If you reload the physics (I think it is the Ctrl+L shortcut). If I'm correct, then you'll probably have to input the command again. I'll confess that I never had to do that before, so I can't guarantee. But I have a way to discover if it works:
    Code:
    -- run the code below in the "MAIN" console. It will create a table in memory of all the parameters of the active car
    tbl1 = core_vehicle_manager.getPlayerVehicleData()
    -- it will look as nothing happened, then run the line below to print the items on the console screen
    for k, v in pairs(tbl1) do print(k) print(v) end
    -- do not run anything that has the double dashes at the beginning of a sentence.
    -- as I'm rendering my episode, I can't open my game to check myself. But give it a try as you will learn something new.
    -- run this BEFORE and AFTER reloading the physics. You'll be able to understand if the command persists after the reloading.
    
    Let me know if it worked
     
  13. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    I'd like to announce that the Qualifying has been completed.
    All drivers are now ready for the race.

    The link to the video is at the first post in this thread
     
    • Like Like x 1
  14. GamerRukky

    GamerRukky
    Expand Collapse

    Joined:
    May 3, 2022
    Messages:
    122
    Ay man just wondering were you able to change the target speed and ai mode using the race ai editor? I've been having an issue with not being able to change the ai settings just mentioned using the editor.
     
  15. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    I just noticed that the pointing system written in the first post of this thread was wrong. I made a change but didn't update my own documentation.
    Now it is correct :D
    --- Post updated ---
    Hi GamerRukky!
    I didn't set up a target speed. I let the AI decide the speed on its own based on other parameters, which is the 'avoidCar = 0' and 'Risk = math.random(70,90)/100'. These values can be set this way only through the console as highlighted in my first post in this thread.
    For the ai.mode, once you use the console, it understand that it was set up to 'manual'. So, to your question, I'm using it as 'manual'

    PS: I'm not using the "Create Mission" button or any other UI in the game. I'm using the Race Tool found at the World Editor (F11):
    Window > Gameplay > Race/Path Editor
     
    • Like Like x 1
  16. GamerRukky

    GamerRukky
    Expand Collapse

    Joined:
    May 3, 2022
    Messages:
    122
    Yeah I'm using the race tool as well for my own scenario. I've been trying to figure out how to change those values but to no avail. If we were able to find out how to the AI would be a lot more faster and won't unnecessarily break on straights etc. as the AI isn't the best at determining that.
    --- Post updated ---
    Oh and how do you arrange the checkpoints?
     
  17. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    I found that the only way to fix the AI behaviour is to manually use the code, which is exactly what I'm doing.
    When you use the "Debug Tools > Open Test Race Window" and select "AI Drive All vehicles in scene", still with the physics paused, open the console. You will see the code that it is applied.
    This is where it will show all the details. Then, you'll have to copy that code somehow (I take a screenshot and convert that to text online) and manually update the DrivePath of all cars. Kind of "too much", I know, but that's how I ensure my AI drive well. (See the big gray window that opens when I hover over the code in the console).
    What you need to change is the "wpSpeeds", but using the Race Tool, I haven't yet found where and how.
    upload_2024-7-16_13-53-22.png

    To your question regarding checkpoints, I don't have a proper checkpoint like the races in the game. I think you set them up using a different tool, probably the Mission one, but I'm unsure. Here's how I create my "checkpoints".
    1st, I create my pathnodes. I place them as far apart as possible, see the highlighted ones in the screen.
    upload_2024-7-16_13-57-5.png

    2nd, I create "Segments" between each Pathnode as the image below. It helps the AI to keep on track and not try to make shortcuts. There are 2 modes, Waypoint and Capsules. I use capsules as the AI behaves better (my test was on my previous video. The first Race was using waypoints while the other 2 were using capsules. It is possible to see a bit difference on how they drive, very subtle, but changes a lot in my opinion)
    upload_2024-7-16_13-58-46.png

    I usually test the track with the correct car when setting up the capsules. What I find kind of upsetting is that the AI always try to stay in the center. But I suspect I have broken this behaviour by looking at my last qualifier video. The AI is trying to cut through the corners properly, so I believe I'm not far from satisfying my desires with the AI.

    PS: Please bear in mind that on my videos, there's no player, only AI driving, so I can't compare a player with an AI here.
    PS.2: I use the manual approach because the tools I found do not allow me to properly config the races. It is a chore, but one that I like :D
     
    • Like Like x 1
  18. GamerRukky

    GamerRukky
    Expand Collapse

    Joined:
    May 3, 2022
    Messages:
    122
    Ah okay. Regarding the capsules and waypoints what do they change necessarily? Also i'm using the Race Tool as well just to let you know.
     
  19. Peregrinus

    Peregrinus
    Expand Collapse

    Joined:
    Mar 29, 2024
    Messages:
    113
    I understood that you are using the Race Tool too :D

    With the capsules, you can define the width of the "allowed area" a driver can go. With the waypoint, you just tell the driver where it is and it will figure a way to reach it.
    For example, when the AI misses a curve and "accidentally" passes through a waypoint, it will reverse almost the entirety of that path (check my race video at the Automation track. It is called Race Day - Group 3. @2:08 Juliana starts to reverse or @5:03 Reinaldo does the 180 to reach the waypoint it missed. It also happened at the Group 2 race @2:22 with Donna going back).
    But with the capsules, if there are no PathNodes within the curve, it will just go back to the track and continue from there. I noticed this when testing this new track AFTER I had already recorded the Automation track.
    So I expect a huge improvement for this Race, with many AI drivers together.
     
  20. GamerRukky

    GamerRukky
    Expand Collapse

    Joined:
    May 3, 2022
    Messages:
    122
    Oh damn that's pretty cool. So how do you use em? because uh when i try to it opens the other menu saying create and im not sure where to go from there. Either way thank you so much bro
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice