Deadlock release - Vehicles could have different release priority lists
Prerequisites
-
I have Confirmed this bug myself. -
I have checked the documentation and found no answer. -
I checked to make sure that this issue has not already been filed.
- Prerequisites
- What is the current bug behaviour?
- Steps to reproduce the bug
- What is the expected correct behaviour?
- Relevant logs and/or screenshots
- Context for bugs on live / demo environments
- Confirmation
- Possible fixes
What is the current bug behaviour?
Currently vehicles will check their own radius for the release priority list causing different lists to be made. For the deadlock system to be decentralised and accurate, all release priority lists must be the same on every vehicle in the deadlock.
The deadlockPriorityModifier
is also a float between 0 to 1 which could have possible collisions causing the lists to become inaccurate as well.
Steps to reproduce the bug
How can a developer or user reproduce the issue? Please provide detailed steps:
- Run the simulation with two junctions.
- Create a deadlock situation in both junctions.
- The release priority list may not be the same as vehicles are further spread apart.
- It's then possible that vehicles will try and release themselves when other vehicles are releasing as well causing collisions
What is the expected correct behaviour?
All vehicles release priority list should be exactly the same.
Relevant logs and/or screenshots
This is the method where the release priority list is calculated for each vehicle.
vehiclesInArea
is the list
/// <summary>
/// Checks if the vehicle should release the deadlock
/// </summary>
/// <returns>True if the deadlock should be released</returns>
private bool ShouldReleaseDeadlock()
{
VehicleSettings vehicleSettings = this.vehicle.vehicleSettings;
if (currentDeadlockSeconds < vehicleSettings.releaseDeadlockAfterSeconds)
{
return false;
}
List<Vehicle> vehiclesInArea = GameObject.FindObjectsOfType<Vehicle>().Where(v => Vector3.Distance(v.transform.position, vehicle.transform.position) <= vehicleSettings.mergeRadiusCheck).OrderByDescending(v => v.vehicleDriver.vehicleSensors.GetSensor<DeadlockSensor>().GetDeadlockPriority()).ToList();
List<Vehicle> vehiclesInAreaOriginal = new List<Vehicle>(vehiclesInArea);
while (vehiclesInArea.Count > 0)
{
Vehicle vehicleToCheck = vehiclesInArea.First();
if (vehicle.vehicleDriver.Equals(vehicleToCheck.vehicleDriver))
{
return true;
}
if (vehicleToCheck.vehicleDriver.vehicleSensors.GetSensor<DeadlockSensor>().IsReleasingDeadlock() || !vehicleToCheck.vehicleDriver.isWaitingOnSensorRays)
{
return false;
}
vehiclesInArea.Remove(vehicleToCheck);
}
// This is the last vehicle so should release
return true;
}
Context for bugs on live / demo environments
If the bug was found on a live or demo deployment, state the time and date on which it occurred (this helps in searching web server or operating system logs for more information).
-
The simulation was run on Windows. -
The simulation was run on Linux. -
The simulation was run on MacOS (unsupported). -
The simulation was run on iOS (unsupported). -
The simulation was run on Android (unsupported).
Please also state the version number of your platform.
Confirmation
Please provide any relevant context about this bug report.
-
Marked with Priority:High, Priority:Medium, or Priority:Low, according to the needs of the client. -
This bug has been reported by the client or product owner. -
This bug has been reported by an end-user (who is not the client). -
This bug has been Confirmed, by a developer, running the develop branch locally. -
This bug has been Confirmed, by a developer, on the live system. -
This bug has been Confirmed, by a developer, on the demo deployment.
Possible fixes
If you know the code-based well, what would you first do to try and fix this bug?
There should be two changes here.
Firstly, remove the deadlockPriorityModifier
value
Secondly, change the way the release priority list is generated. Each vehicle needs the same list meaning a radius approach will not work. It may be possible to just use vehicles that are currently in a deadlock. Then to order the list, use the Unity game object id which is the GetInstanceID
method from the gameObject