Assetto Corsa Realistic Trackday is an app for Assetto Corsa which alters the AI cars' behaviour to act like humans driving on a track day aware of other cars as opposed to bots with horse blinkers constantly driving the racing line.
Using this app, AI cars will yield to faster cars by driving to the side and only yielding to one pre-defined side (left or right) as is the way during trackdays, particularly on the Nordschleife. AI cars will also overtake other cars on the other side and return back to the racing line once it's safe to do so.
This provides the user a smooth single-player driving experience with AI cars where the vehicles respect each other while driving and act like real drivers do.
My main aim with this is to recreate the true Nordschleife Touristenfahrten experience where by law you are required to overtake only on the left and thus yielding cars always need yield to the right:
Source: https://nuerburgring.de/info/company/gtc/driving-regulations
Videos
Assetto Corsa Realistic Trackday v0.9.8 - Full Feldbergring lap:
Full Nordschleife lap on Realistic Trackday v0.9:
Short video of Realistic Trackday v0.5:
v0.9.8 - Major Update - Improvements across the board!
Realistic Trackday v0.9.8 brings a lot of new features over the previous v0.9.1 version, notably the number of tweakable options now available to the user.
Per-Track-Per-Mode Settings
One of the first important changes is that the app now saves settings Per-Track-Per-Mode where Mode can be any one of the following values depending on how the game is launched from the Content Manager:
- Practice
- Qualify
- Race
- Hotlap
- TimeAttack
- Drift
- Drag
App now starts disabled until enabled for the current Track-Mode combination
Another important change is that now, unless previously enabled for the current Track-Mode combination, the Realistic Trackday app starts disabled and you have to enable it from the Realistic Trackday Settings. This change was done so that the app doesn't modify the AI cars' behaviour unexpectedly.
The third important change involves the way the yielding and overtaking "lanes" are defined. In v0.9.1, you could define the yielding lane as either Left or Right and the overtaking lane will then be the other side of the track and how far the ai cars drive to the side of the track for both yielding and overtaking was defined by a single value. In v0.9.8, there are three slider values which define the default driving position, the yielding position and the overtaking position:
- Default Lateral Offset
- Yielding Lateral Offset
- Overtaking Lateral Offset
These three numbers are all in the range of [-1..1] where -1 represents the left-most side (edge) of the track, 0 is the middle of the track and 1 the right-most side of the track (edge).
All three specify the lateral position on the track width where each respective action should take place.
Nordschleife Touristenfahrten Trackday where driving normally is mostly done on the racing lane, overtaking happens on the left and yielding takes place on the right:
Default Lateral Offset: 0 (when the lateral offset is 0, the ai use the default racing line which is mostly at the center of the track)
Yielding Lateral Offset: 0.7 (we want the cars to yield to the right so an 0.7 will make them yield to the right but not going as far the edge of the track)
Overtaking Lateral Offset: -0.8 (we want the cars to overtake on the left so a -0.8 will make them overtake to the left but also not going as far the edge of the track)
Default Lateral Offset: 0.5 (an 0.5 will make the cars drive in the middle of the right lane)
Yielding Lateral Offset: 0.5 (since this is a road and not a track and the cars are already driving on the right lane by default, we can use the same value here we used for the Default Lateral Offset)
Overtaking Lateral Offset: -0.5 (to make the cars overtake by moving to the middle of the left lane, we can use a -0.5 value)
Default Lateral Offset: -0.5 (a -0.5 value will make the cars drive in the middle of the left lane)
Yielding Lateral Offset: -0.5 (since this is a road and not a track and the cars are already driving on the left lane by default, we can use the same value here we used for the Default Lateral Offset)
Overtaking Lateral Offset: 0.5 (to make the cars overtake by moving to the middle of the right lane, we can use a 0.5 value)
Many customizable options
The fourth important change is the amount of available tweakable values now available to the user. These tweakable values include dynamic changes to AI Caution, AI Aggression and AI Difficulty level.
There are also many individual settings for how to handle yielding and overtaking:
Hopefully all these tweakable values will better provide the user create the perfect trackday experience.
Better support for races
Although Realistic Trackday wasn't specifically for races, there are a number of values you can tweak about to make it work in a race. Follow these tips to get a better racing experience:
- Very important: Set a value in seconds in the "Defer yielding/overtaking for a while after session start" so that the yielding and overtaking logic doesn't start taking place until after some time so that the cars don't pile up when the race starts.
- Keep Caution values low so that the AI cars take more risks overall, but careful about dropping the Caution values below 1.
- Keep Aggression values high so that the AI cars drive more assertively on track.
- Keep Difficulty values high so that they go through corners faster.
- Keep the "Detect car behind distance" Yielding value low so that AI cars only yield if the overtaking car is very close to them
- Keep the "Detect car behind ahead" Overtaking value low so that AI cars only overtake if the yielding car is very close to them
- Set the top speed limit Yielding value to 1.0 so that no top speed limit is applied when a car is yielding
- Keep the throttle pedal limit Yielding value high so that yielding cars don't let go of the throttle too much while yielding, or nothing at all.
- Keep the "distance to overtaking car to apply speed limit" Yielding value low so that the yielding car only slows down, if you want it to slow down, while very close to the overtaking car.
In this version I've written better handling for users with outdated CSP versions by trying to identify all the required functions in the app and informing you if any of them are missing due to old CSP versions.
Installation
The app requires Custom Shaders Patch (CSP) extension installed and doesn't work online since it can, obviously, only control AI cars.
Stable
Download the zip file from the Releases page: https://github.com/dreasgrech/AssettoCorsaRealisticTrackday/releases
Copy the AssettoCorsaRealisticTrackday directory to \steamapps\common\assettocorsa\apps\lua\
Cutting Edge
If you want to install the app directly using the latest source code, you can download the entire repository and put all files in: \steamapps\common\assettocorsa\apps\lua\AssettoCorsaRealisticTrackday\
You should end up with this file structure once the files are copied:
How To Use
Once installed, the app will run automatically when Assetto Corsa is running.
To view the car list table in the window, open the app from the side bar in the game listed as Realistic Trackday:
I have tested this app mostly using the AI Flood setting which cycles the AI cars during a Trackday around the player so that there's a constant stream of cars behind and in front of the player car.
It can be enabled from Content Manager -> Settings -> Custom Shaders Patch -> New AI Behaviour:
That said, the app should theoratically work in all modes (except Online) on tracks that have an AI Spline set.
Here's a typical scenario which can be used:
Settings
The app offers a number of settings to allow for customizing the experience as much as possible, starting from the general driving of the AI to specific settings regarding yielding and overtaking:
There are also a number of settings that help with understanding what the app is doing under the hood. One of the main debugging tools is the custom UI table that shows the full relevent data about the cars:
This table shows you a lot of information about each other including the current state the car is in, if it's yielding or overtaking and who's the other car involved, and also reasons why they can't yield or overtake at the time beind. It's invaluable for understanding the behaviour of the cars.
How It Works
Each AI car is represented as a state machine where each car can be in one state at a time.
These are all the current states AI cars can be in:
Default Driving States
Driving Normally
The default state where cars are driving the normal racing line while not currently yielding or overtaking other cars. In this state, a car is constantly monitoring the cars around it to determine whether it needs to overtake the car in front or yield to the car in the rear. If a car needs to start yielding to a car behind, it will transition to the Easing In Yield state or the Easing In Overtake if it needs to overtake a car in front of it.
Easing In Yield
In this state cars are driving laterally from their current lateral position on the track to the yielding lane to let faster cars behind them overtake on the overtaking lane. To ease into the yielding lane, cars drive slowly to the side while checking to make sure there are no other cars on the side they are driving lateral to. If they encounter cars on their side while easing in yielding, they will slow down and wait for a gap to fit in on the yielding lane to let the overtaking car pass.
When a car has fully reached the yielding lane, they will move on to the Staying on Yielding Lane state.
Staying on Yielding Lane
When a car is in the Staying on Yielding Lane state, a car will keep driving on the yielding lane side as much as possible to let the overtaking cars pass . While in this state, cars will try drive a bit safer by keeping a two car gap on the yielding lane. When a car determines that there's no one else behind it that needs yielding, it will transition to the Easing Out Yield state.
When back to the Easing Out Yield state, a car will drive laterally from the yielding lane over to the normal racing line and will transition back to the Driving Normally state once it reaches the racing line spline. If it encounters a car on its side while driving laterally, it will stop driving to the side and wait until the car on the side has created a gap before it returns to the racing line.
Easing In Overtake
While in the Easing In Overtake, a car will drive laterally from their current lateral position on the track to the overtaking lane so that they can overtake the car or cars in front of them.
After a car overtakes another car, it will check if it should stay on the overtaking lane to continue overtaking the upcoming car before returning back to the normal driving line through the Easing Out Overtake state.
Once an overtaking car has determined it's far enough from the yielding car and there's no more close cars that can be overtaken, it will start returning back to the normal racing line via the Easing Out Overtake state.
When back on the Easing Out Overtake state, a car will drive laterally from the overtaking over to the normal racing line and will transition back to the Driving Normally state once it reaches the racing line spline. If it encounters a car on its side while driving laterally, it will stop driving to the side and wait until the car on the side has created a gap before it returns to the racing line.
Collided with Car (WIP)
Collided with Track (WIP)
Another Car Collided Into Me (WIP)
Troubleshooting
- If you don't see the car list table and want to enable it, you can enable it from the Settings called Draw Car List.
- If the AI cars are frequently going off track while yielding/overtaking, reduce the Max Side Offset value from the Settings:
- If nothing seems to be working, open the Lua Debug app:
Enable the Realistic Trackday app:
And check if there are any errors listed in the window (the yellow logs in the below image are from the Log fast AI state changes option):
- If when using the app in a Race, the cars all start trying to yield and overtake as soon as the race starts causing mayhem, increase the "Defer yielding/overtaking for a while after session start" value which determines the delay before the yielding/overtaking starts working after a session officially starts.
- If the cars start yielding while the overtaking car is still very far, decrease the "Detect car behind distance" value in the Yielding settings.
- If the cars start overtaking while the yielding car is still very far, decrease the "Detect car behind ahead" value in the Overtaking settings.
- If the cars are rear-ending each other frequently, increase the Caution values. Note that a caution value below 1 causes the cars to drive very assertively irrespective of what's in front of them.
- If the cars are very hesitant when trying to overtake, decrease the overtaking Caution values, increase Aggression values and increase Difficulty values. Also make sure that the overtaking lateral offset is far enough from the yielding lateral offset so that cars have enough space on the side to overtake.
- If the yielding cars are driving way too fast while yielding causing the overtaking cars to not be able to fully overtake them, adjust the speed limiting values in the Yielding section to tell the yielding cars to slow down a bit while yielding so that the overtaking car can overtake safely.
- If the cars are changing directions while yielding/overtaking too fast with jerky steering pulls, decrease the lateral offset increment/decrement step values in the Yielding and Overtaking sections so that the move to the target lateral offset happens more gradually.
- If the cars are hitting each other side-to-side when driving laterally to change lanes, make sure that the "Check sides while yielding" and "Check sides while overtaking" in the Yielding and Overtaking sections respectively are enabled.
- Some cars don't use the indicator lights when yielding or overtaking (like the Alfa Mito), and some cars (like the MX5) seem to have invertly-set indicator lights i.e. they turn on the left indicator light when going right and vice versa. This seems to be an issue either with the CSP API or with the specific individual cars.
- As of CSP v0.2.12-preview1, there seems to be a bug with the API in regards to speed-limit functions on the API cars (specifically the physics.setAIThrottleLimit and physics.setAITopSpeed functions) which prevents the AI cars slowing down while yielding to another car.
- Accident handling hasn't yet been enabled in the app, even though it's almost fully developed. This involves having the cars stop after accidents, a yellow flag being shown to the player indicating there's an accident, no overtaking of cars in yellow flag zone, everyone driving at 50km/h and also ai cars navigating around the cars in the accident on the track. But I haven't enabled it yet because of the issue in the current CSP v0.2.12-preview1 which doesn't have the ai speed limiting code working (see point above for more info) and I need the speed limiting to work for the cars to navigate accidents.
- Since accidents aren't implemented yet, cars will now sometimes drive back to the track after they crash so beware of that.
- More TODOs and issues listed on the Issues page: https://github.com/dreasgrech/AssettoCorsaRealisticTrackday/issues
This app has taken many many hours of development work to get it in the state it is today, so if you enjoy using it, please consider buying me a coffee. It will be immensely appreciated.