Dedicated Server - Dynamic Race Bot [DRB]

Discussion in 'Automobilista 2 - General Discussion' started by Svenny, Dec 25, 2023.

  1. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    [DELETED]
     
    Last edited: Dec 29, 2024
  2. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    I'll make a start on that soon..

    Yes very strange, it works for me and Diesels...Silly question but are you updating the config values in the /lua_config/ams2_drb_config.json file?

    There is also a small bug...it's dymaically selecting the class count regardless of the config value. I'll add to the todo...

    Now this is going to be tricky...there will be a need for a full set a vehicle class params and track params, essentially need to select track and then select suitable classes. My first pass is to try and figure out how to extract new data from DS and update existing vehicle, classe and track lists then also get additional data in.. A good example is cars with headlights and night races...currently you couldn't do that without excluding all the vehicles/classes that don't have headlights and set the session start and end hours values in the config.

    It would be fantastic if this extra data was somehow available from within the DS instead of relying on manual ouside data (eg: AMS2 Car Info sheet).
     
    Last edited: Dec 29, 2024
    • Like Like x 1
  3. Mikk Schleifer

    Mikk Schleifer Active Member AMS2 Club Member

    Joined:
    Nov 30, 2019
    Messages:
    209
    Likes Received:
    182

    Have to say thank you first for these great tools, got it working :)
    I am old, took some time to understand it, but now i am in for more!:cool:
     
    • Like Like x 1
  4. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    Good news, I found the issue and I've put in safe guards from it occuring again. Bad news is I have a few more additions (Adding/Removing AI from sessions, updating vehicles, classes and tracks dynamically removing the need to update manually on new updates and maybe a inchat kick function) to add and test before the next release.
    In the meantime, one thing that might help you weather sceanrio is ensuring the below setting in the config matches one of the later weather options that has a weight (Foggy or HeavyFog). By default it's set to "LightRain" which isn't one that you've added a weight to.

    Defaults in config..
    Code:
    "dynamic_weather_forecast" : "LightRain",
    
    PS: Still haven't found the bug where no weather is found for Race Slot.....frustrating
    EDIT: I found the issue with the Race Slot not being applied....silly mistake...trying to assign a variable before it was assigned a value!!!:oops:
     
    Last edited: Dec 31, 2024
    • Like Like x 1
  5. Diesels

    Diesels New Member

    Joined:
    Dec 27, 2024
    Messages:
    13
    Likes Received:
    3
    You are doing great work, so if it takes a bit of time, no problem! :)

    Is there a way to have different time progression in weather an sesson time?
    If time progression is set to X5 in all sessions, then weather will also be x5 if it has more than 1 slot.
     
    • Like Like x 1
  6. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    Thanks..From my experience, if these aren't in sync you could have a time progression of 1x for time and 30x for weather. This scenario creates unrealistic weather plus from memory it also has some weird side affects to the weather system.
    At the moment, I'm trying to keep it simple.
    PS: From what I've read, weather slots are as a min hourly which is where I believe having both time progression different to each other can cause strange conditions.
     
    • Like Like x 1
  7. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    New Update v0.4 now available - See opening post, changelog and config for more details. Fingers crossed!

    EDIT: New Update v0.4.1. Had a couple of issues with the cars with lights not working plus AI adding/removing between sessions/lobby not working as intended. Can add them but removing them seems bugged...
     
    Last edited: Jan 2, 2025
    • Winner Winner x 1
  8. Mikk Schleifer

    Mikk Schleifer Active Member AMS2 Club Member

    Joined:
    Nov 30, 2019
    Messages:
    209
    Likes Received:
    182
    • [Added]: Update track,classes and vehicles into a peristent file. (lua_config/ams2_drb_data.json).
    This will update as new additions to the game are added.Updated on Server Start.
    New vehicle/classes/tracks will be enabled by default
    This is now the place to enable/disable vehicles/classes/tracks by setting the enabled value to true/false.

    So I edited some values but not it did change anything...
    This while first lines tell me not to edit anything anyway?:

    // Persistent data for addon 'ams2_drb', addon version 0.4
    // Automatically maintained by the addon, do not edit!
     
  9. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    In order to make changes, ensure server is not running, make changes (don't delete things just change the enabled flag), save and restart server should do the trick..
    As for that comment at the top, you can disregard it. It's a message that I can't modify.
    UPDATE: As of version 0.4.4, changes can now be done live as file reloads after each combo.
     
    Last edited: Jan 15, 2025
    • Like Like x 1
  10. Diesels

    Diesels New Member

    Joined:
    Dec 27, 2024
    Messages:
    13
    Likes Received:
    3
    0.4 looks great so far, random weather is now working and no error or anything.:)
    Is this still on the todo list? I have set Multi_classes_count to 3 and allowed exactly 3 classes in the data file, but sometimes its just 2 or 1 available. Not a big problem, i just set this to 10 for now, and 90% of the time it is all 3 classes.
     
    • Like Like x 1
  11. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    Yes it is. What currently happens is it will randomly select a class for each slot, however if the same class is selected for 2 or more of these slots, the code doesn't go back and try to find another class not assigned already..
    basically I need to store these classes in a slot array and check this array if the newly select class is in that array, if it is go back and select another...rinse and repeat..

    Adding/removing AI is a little broken...trying to find issue. It's fine when you leave lobby and come back, however transitions between lobbies (without leaving server) doesn't change to new AI/MaxPlayer values...
     
    • Like Like x 1
  12. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    I've updated this now so it won't duplicate classes and will adhere to the class count in the config.
    See opening post for new download version 0.4.2. All that is changed is the "ams2_drb.lua" so this is all you need to copy and replace in you lua/ams2_drb folder.
     
    • Winner Winner x 1
  13. Diesels

    Diesels New Member

    Joined:
    Dec 27, 2024
    Messages:
    13
    Likes Received:
    3
    If i just change this lua file the server starts but stops at:
    Code:
    [DRB]: Rotation disabled. Using Dynamic Selectors for sessions indefinitely
    normally it is followed by this and more:
    Code:
    INFO: Saving persistent data for addon 'ams2_drb' into 'lua_config\ams2_drb_data.json'
    changing back to the lua file from 0.4.1 and the server works again.
     
  14. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    The first snippet is normal and info only - It would be the same in all prior versions although I've changed the format of the console outputs in this release as well, so looks different.

    I removed in several spots throughout the code the SavePersistent function call as it isn't required that often, really only needed once on server start but the fact your not seeing it at all, does suggest failure to start.
    I'll check my end, but in the meantime in the ams2_drb.lua file can you set the below and see what errors come up in console output..warning this prints alot of info (on my list to clean up).

    Code:
    local debug = true
    
     
  15. Diesels

    Diesels New Member

    Joined:
    Dec 27, 2024
    Messages:
    13
    Likes Received:
    3
    The only error seems to be with the debug itself when i set this to true:
    Code:
    [2025-01-04 00:44:03] WARNING: Lua: lua\ams2_drb\ams2_drb.lua:49: attempt to call a nil value (global 'log')
    [2025-01-04 00:44:03] ERROR: Failed to read addon Lua file from 'lua\ams2_drb\ams2_drb.lua'
     
  16. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    mmm..I should stop coding late at night...Updated now - check opening post for new download. 0.4.3
    https://forum.reizastudios.com/attachments/ams2_drb_v0-4-3-zip.38285/
     
    • Like Like x 2
  17. Diesels

    Diesels New Member

    Joined:
    Dec 27, 2024
    Messages:
    13
    Likes Received:
    3
    This is what i get when i start the server:
    Code:
    Setting breakpad minidump AppID = 1066890
    [2025-01-04 23:42:49] INFO: HttpApi disabled
    [2025-01-04 23:42:49] INFO: Loading LuaApi addon 'sms_base'...
    [2025-01-04 23:42:49] INFO: Loading LuaApi addon 'ams2_drb'...
    [2025-01-04 23:42:49] INFO: Loading LuaApi addon 'lib_rotate'...
    [2025-01-04 23:42:49] INFO: Saving persistent data for addon 'ams2_drb' into 'lua_config\ams2_drb_data.json'
    [2025-01-04 23:42:49] INFO: Saving persistent data for addon 'ams2_drb' into 'lua_config\ams2_drb_data.json'
    [2025-01-04 23:42:49] INFO: Saving persistent data for addon 'ams2_drb' into 'lua_config\ams2_drb_data.json'
    [2025-01-04 23:42:49] [DRB]: 10% change of MediumCloud
    [2025-01-04 23:42:49] INFO: Saving persistent data for addon 'ams2_drb' into 'lua_config\ams2_drb_data.json'
    [2025-01-04 23:42:49] [DRB]: Found Probability Weather Type in Weatherstore! and has a weight of 10
    [2025-01-04 23:42:49] [DRB]: Weather weight sum = 71.Per Factor is 100 / wws = 1.4084507042254
    [2025-01-04 23:42:49] [DRB]: Session stages = 3
    [2025-01-04 23:42:49] [DRB]: Weather weight sum = 71.Per Factor is 100 / wws = 1.4084507042254
    [2025-01-04 23:42:49] [DRB]: Weather weight sum = 71.Per Factor is 100 / wws = 1.4084507042254
    [2025-01-04 23:42:49] [DRB]: Rotations = 10. Sessions = 3. Weather Index # = 4. Weather Range Value = 59.154929577465. probablity_value = 10RWR Value is 100 - (pv / ( Rotations + Sessions)) / WeatherRangeValue = 1.6735714285714
    [2025-01-04 23:42:49] [DRB]:  Total weather weight - dwr = 71 and 59.154929577465
    Index#  Name            Weight          AccumW          Range
    1       Hazy    5       5       11.785714285714
    2       Clear   15      20      47.142857142857
    3       LightCloud      12      32      75.428571428571
    4       MediumCloud     10      42      99.0
    5       HeavyCloud      9       51      99.310344827586
    6       Overcast        7       58      99.551724137931
    7       LightRain       6       64      99.758620689655
    8       Foggy   4       68      99.896551724138
    9       HeavyFog        3       71      100.0
    [2025-01-04 23:42:49] INFO: LuaApi started
    [2025-01-04 23:42:49] INFO: Dedicated server is starting...
    [2025-01-04 23:42:51] INFO: Connection to Steam established
    [2025-01-04 23:42:51] INFO: Received public IP 84.189.8.172
    [2025-01-04 23:42:51] INFO: Server logged in with Steam id 90239071372026892 ; server is secure
    [2025-01-04 23:42:51] INFO: Server startup finished: AppId 1066890, public IP 84.189.8.172, Steam id 90239071372026892 ; switching to running state
    [2025-01-04 23:42:51] [DRB]: Rotation disabled. Using Dynamic Selectors for sessions indefinitely
    [2025-01-04 23:42:51] [DRB]: Session: 0
     
  18. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    You can turn debug back to false now. Does the server appear in the game MP list?
     
  19. Diesels

    Diesels New Member

    Joined:
    Dec 27, 2024
    Messages:
    13
    Likes Received:
    3
    It does not appear in the server list.
     
  20. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    49
    Likes Received:
    38
    OK - Can you try the new ams2_drb.lua file in the attached and see if that one works?
     

    Attached Files:

    • Like Like x 1

Share This Page