Potential for AI modding: what do we know?

In this thread from a while ago, Stereo wrote the following:

AC's fairly completely visible, though not quite publically. It was shipped with a debug file included, so every function header & most of the structs include original variable names & offsets in the exe, which means a dll can add code pretty much anywhere in the game (also why when it crashes it can print a stack trace, instead of just saying some unreadable memory dump). Most of what CSP does with this is add in graphics functions that weren't originally in the game, like it built an entire new structure of lights that just reads off car/track position and adds lights into the rendering process.

Despite all the progress made on 24h day/night cycle, improved graphical features, rain, and so on, as I understand it, there hasn't been a ton to improve AI behaviour. Mostly trackday or traffic-oriented features like flood AI.

However, to have a more rewarding single player experience, more basic improvements to the AI are needed. It's arguably the thing preventing AC from being the ultimate sim. For example:
  • Rolling starts
  • AI pit strategy logic based on more than running out of fuel
  • Multiclass passing logic
To those who have been adding code to the game through CSP, I'm curious: what understanding is there of variables and so on relating to AI behaviour? Is there potential for achieving any of the above (or other) AI-related features? What are your thoughts?

An example: I feel like improved AI pit strategy should be achievable through a Python app in some way. For example, run in the background, take data from variables for each car on fuel and tyre usage, relate to any rules (e.g. tyre and stop requirements) you've defined for the series, set the laps at which each AI should pit, then force them to do it. Would be difficult I'm sure, but seems like it should, in theory, be achievable enough!
 
Changing it in the ways you mention would pretty much mean a complete rewrite, so it’s more or less a non-starter. Strategy stuff might be more reasonable, but anything having to do with the actual driving would be quite difficult/involved.
 
Thanks so much for the response! :)

Changing it in the ways you mention would pretty much mean a complete rewrite, so it’s more or less a non-starter. [...] anything having to do with the actual driving would be quite difficult/involved.
This is exactly why I wanted to ask knowledgeable people like yourself. No sense in thinking up ideas or getting one's hopes up for nothing! It's kinda sad, but... it is what it is.

Some people implemented better "blue flag" behaviour for the original rFactor by applying temporary weight penalties to slower classes/lapped cars, which forces the faster car (which normally pulls out to pass, but rarely overtakes in a straight line) to actually go by. But it seems unlikely this sort of hacky solution would work in AC given the particular behavioural quirks of AC AI that lead to issues in a multiclas context.

Strategy stuff might be more reasonable
Interesting. It would certainly be a useful feature to add to the sim. With well-crafted AI lines and corridors, the AI in a single class race are quite solid! So better pit strategy logic would at least allow AC to give a solid experience in long single class races -- and let's face it, most of the racing landscape is single class (much as I love multiclass). ;)

I may dig around, see what data can be gleaned from the sim on fuel and tyre usage by individual AI cars throughout the race. Would also need to figure out how you might force cars to pit at specified laps... this feels like something that could, with luck, use a hacky solution analagous to the rFactor hack described above. This also may be a wild goose chase or pipe dream, who knows.
 
Last edited:
I've only taken a couple small looks at how the AI functions in case there were low hanging fruit for new ideas, unfortunately not really, the AI flood stuff uses parts of the code that are easier to mess with. (modifying car position/velocity directly, and I think resetting the flag for whether an AI has retired)

I'd guess scheduled pits would be achievable, rolling starts not, and changing passing behaviour very unlikely. Unless it's a single file rolling start (which most series seem to only use on restarts) you need multiple AI lines and that's one of the major "it's just hardcoded to have 1 line" things that means a complete rewrite
 
Last edited:
Cheers @Stereo, interesting to know your insights, thanks for sharing. :)

unfortunately not really, the AI flood stuff uses parts of the code that are easier to mess with. (modifying car position/velocity directly, and I think resetting the flag for whether an AI has retired)
That's unfortunate, but makes sense. Oh well!

I must confess the batsh*t part of my brain reads "modifying car position and velocity directly" and goes wild with dumb (or entirely impractical) ideas. I start imagining a system that kicks in every now and again to continuously change the AI car's inputs and move its position to help with overtaking, for example. But then I think for a second about what that practically would entail in terms of work for minimal payoff (if it's even possible at all)... "no no, calm yourself down MJQT, you silly goose". :redface:
 
Last edited:
Yeah I mean, you could just swap the positions of 2 cars any time they want to pass, that would help AI filter through as well :p (maybe only do that when they're not onscreen...) I really don't think there's access to the AI's control inputs though.
 
Last edited:
Interesting thread and question, I often wondered if AI behaviour is somehow moddable in AC apart from making new ai lines and hints. Because…let’s face it: AI is one of the very few weak points in this title. They can't overtake when you drive slower, they don’t defend, they sometimes cannot make corners which are easy for humans etc etc. I wish AC had good AI this would clearly make it no 1 for me.

Bummer to read that it is probably never going to happen.
 
The one thing I'd love to see is dynamic AI difficulty like Raceroom has.
Makes for some of the best Singleplayer racing I've ever done.
Just coming back to this thread, and saw your comment. Upon further reflection, IMO this actually seems more achievable (within certain bounds) than other ideas using a yet-to-be-created add-on to Content Manager. In a given class of car, you'd need a look-up table of laptimes for AI at a track for various AI strengths, then could compare to info on player laptimes at that track in that class of car and "spit out" the roughly correct AI strength.

Thing is, you'd need a one-click (or few-clicks) procedure for the user to come up with those look-up tables for a given car and track that doesn't take too long. Raceroom has the advantage of a static non-moddable car and track selection, so the devs themselves can curate that information carefully. Whereas in Assetto you'd need a procedure for this to automatically happen for each new mod (car or track) that you add to the game. Not an easy problem to solve at all... and indeed it could be that the dev time required and the amount of time required for the look-up table to be created each time is just way too much...
 
After the recent news about AI fixes in CSP 1.80, I had to come back to this thread. For anyone not "in the know"...


So glad to see work being done to improve AI racing in AC. :) One thing stood out to me in particular, though: the "Use simpler AI spline for lower level AI" option, which provides AI cars with a level below 90% with simpler spline(s) to follow to help them not wander off-track and crash.

Why does this stand out? Because it means that it is possible to access and change the ideal line used by each specific AI car. This opens up truly massive possibilities.

For instance, multiclass racing could be improved by momentarily switching the faster class car to an alternate spline that helps them successfully pass in a straight line when approaching a slower class car. Or F1-style blue flags could be implemented by having a lapped car switch to a spline off the racing line to "get out of the way". In theory, all you'd need is Python app(s) detecting when a "blue flag" or "multiclass passing" situation is occurring, and temporarily making the necessary changes to AI spline(s)... right? Or is there additional complexity that I'm missing?

Also a quick shout-out to the amazing work being done through the "Rules and Race Enhancements" (RARE) mod. I'm especially excited by how quickly it is moving towards realizing my dream of having sensible pit stop logic for AI cars in AC. https://www.racedepartment.com/downloads/rare-rules-and-race-enhancements.52534/

Given my 3 dreams for AC AI were (1) rolling starts, (2) pitstop logic, and (3) multiclass overtaking... it's pretty cool to see developments that could, in the future, address two of these. I also feel like I've heard about people working towards rolling starts, but I can never find it in my web searches.
 
Last edited:
Haven't watched the video yet (still at work right now) but a better AI for Assetto Corsa would be fantastic. Right now it's just a hotlap sim for me (but great at that) because the AI is no fun at all.
 
Or is there additional complexity that I'm missing?
The additional complexity is that all of the stuff you mention is too variable to be possible. Cars don't drive perfectly on the racing line at all times, so you're still limited to the same detection algorithms that are in AC right now, which are the problem with multiclass.
 
I don't know, but I have always had fun racing the AI on Assetto Corsa. Maybe I am just slow? That is a possibility.. lol. But with CSP .179 or whatever...I have had some very fun times. Happy it could be improved, but I never had a issue anyway. AC rules in my opinion. I even made a video. Watch if you want..but it was a fun last lap.

 
Last edited:
The additional complexity is that all of the stuff you mention is too variable to be possible. Cars don't drive perfectly on the racing line at all times, so you're still limited to the same detection algorithms that are in AC right now, which are the problem with multiclass.
Understood. Makes sense, unfortunately.

I was hoping that by helping a faster class AI car to move the other side of the track (even if they don't follow the spline exactly) it could "be tricked" into getting alongside with and then driving by a slower class car (which would be taking the normal racing line) – basically putting the cars in a position so that the existing detection algorithms would not "kick in".

On the other hand, I can also understand how (as you think) the algorithms could "kick in" and cause hesitations or slowdowns regardless of where the individual cars or their AI splines were placed on track. All depends on precisely how those algorithms were programmed, I suppose.
 
Recently (as used by RARE) you can force AI control inputs so you might be able to prevent the AI from lifting off throttle. probably best to be careful with that though as AIs use the throttle for traction control.
 
Recently (as used by RARE) you can force AI control inputs so you might be able to prevent the AI from lifting off throttle. probably best to be careful with that though as AIs use the throttle for traction control.
Ooh... interesting to know. Thank you!

When you say "control inputs", would this include being able to force steering input as well? Just assembling information to try to understand the options that might be available.
 
Last edited:

Latest News

Shifting method

  • I use whatever the car has in real life*

  • I always use paddleshift

  • I always use sequential

  • I always use H-shifter

  • Something else, please explain


Results are only viewable after voting.
Back
Top