Added 4 spots requirement
This commit is contained in:
parent
8a01e3f3bd
commit
0fab824709
@ -51,10 +51,18 @@ namespace Parking
|
|||||||
int maxCount = 0;
|
int maxCount = 0;
|
||||||
int[] maxComb = {1, 1, 1, 1};
|
int[] maxComb = {1, 1, 1, 1};
|
||||||
|
|
||||||
|
|
||||||
|
List<Driver> drivers = new List<Driver>(DataImporter.Drivers.Count + 4);
|
||||||
|
drivers.Add(new Driver(Size.A, 0, ParkingPreference.Any, 2, 15));
|
||||||
|
drivers.Add(new Driver(Size.A, 0, ParkingPreference.Any, 2, 15));
|
||||||
|
drivers.Add(new Driver(Size.B, 0, ParkingPreference.Any, 2, 15));
|
||||||
|
drivers.Add(new Driver(Size.B, 0, ParkingPreference.Any, 2, 15));
|
||||||
|
drivers.AddRange(DataImporter.Drivers);
|
||||||
|
|
||||||
// Debug.Log("Printing top 5 combinations...");
|
// Debug.Log("Printing top 5 combinations...");
|
||||||
foreach (int[] comb in Combinations) {
|
foreach (int[] comb in Combinations) {
|
||||||
int res = TryFillCombination(comb.ToArray(), spotCountsPerpendicular, spotCountsParallel, counts,
|
int res = TryFillCombination(comb.ToArray(), spotCountsPerpendicular, spotCountsParallel, counts,
|
||||||
spotsCreated);
|
spotsCreated, drivers);
|
||||||
if (res > maxCount) {
|
if (res > maxCount) {
|
||||||
maxCount = res;
|
maxCount = res;
|
||||||
maxComb = comb;
|
maxComb = comb;
|
||||||
@ -62,13 +70,13 @@ namespace Parking
|
|||||||
}
|
}
|
||||||
|
|
||||||
TryFillCombination(maxComb, spotCountsPerpendicular, spotCountsParallel, counts,
|
TryFillCombination(maxComb, spotCountsPerpendicular, spotCountsParallel, counts,
|
||||||
spotsCreated, true);
|
spotsCreated, drivers, true);
|
||||||
|
|
||||||
return maxCount;
|
return maxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int TryFillCombination(int[] sizeIds, int[] spotCountsPerpendicularRef, int[,] spotCountsParallelRef,
|
private int TryFillCombination(int[] sizeIds, int[] spotCountsPerpendicularRef, int[,] spotCountsParallelRef,
|
||||||
int[] counts, int[,] spotsCreated, bool copyToArray = false)
|
int[] counts, int[,] spotsCreated, List<Driver> drivers, bool copyToArray = false)
|
||||||
{
|
{
|
||||||
int[,] spotsCreatedTemp = new int[4, 8];
|
int[,] spotsCreatedTemp = new int[4, 8];
|
||||||
|
|
||||||
@ -91,7 +99,8 @@ namespace Parking
|
|||||||
};
|
};
|
||||||
|
|
||||||
float[] spotSizes = {4, 4.5f, 5};
|
float[] spotSizes = {4, 4.5f, 5};
|
||||||
foreach (Driver driver in DataImporter.Drivers) {
|
|
||||||
|
foreach (Driver driver in drivers) {
|
||||||
var laneIds = new List<int> {0, 1, 2, 3};
|
var laneIds = new List<int> {0, 1, 2, 3};
|
||||||
if (driver.Size == Size.C)
|
if (driver.Size == Size.C)
|
||||||
laneIds.Reverse();
|
laneIds.Reverse();
|
||||||
|
@ -55,7 +55,7 @@ namespace Parking
|
|||||||
$"Duże: {_rejectedDrivers[2]}";
|
$"Duże: {_rejectedDrivers[2]}";
|
||||||
GenerateEmergencyPlan();
|
GenerateEmergencyPlan();
|
||||||
|
|
||||||
DataImporter.ReadFile("Assets/Data/Tablica3.csv");
|
DataImporter.ReadFile("Assets/Data/Tablica4.csv");
|
||||||
InitialConfigurationGenerator generator = new();
|
InitialConfigurationGenerator generator = new();
|
||||||
_initialSolution = generator.FindSolution();
|
_initialSolution = generator.FindSolution();
|
||||||
ArrangeSpots(_initialSolution);
|
ArrangeSpots(_initialSolution);
|
||||||
@ -88,12 +88,6 @@ namespace Parking
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find spot
|
|
||||||
// for (var j = 3; j >= 0; j--)
|
|
||||||
// foreach (Spot spot in _spotMap[j])
|
|
||||||
// if (!spot.Reserved && spot.Size != Size.D)
|
|
||||||
// Debug.Log("Spot not reserved");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AdvanceTime()
|
public void AdvanceTime()
|
||||||
@ -312,6 +306,11 @@ namespace Parking
|
|||||||
foreach (var currentLaneSpots in _spotMap)
|
foreach (var currentLaneSpots in _spotMap)
|
||||||
foreach (Spot spot in currentLaneSpots) {
|
foreach (Spot spot in currentLaneSpots) {
|
||||||
if (spot.Size > newSize && spot.Free && spot.Size != Size.D && !spot.Reserved) {
|
if (spot.Size > newSize && spot.Free && spot.Size != Size.D && !spot.Reserved) {
|
||||||
|
if (GetSpotCountOfSize(Size.A) <= 2 && spot.Size == Size.A)
|
||||||
|
continue;
|
||||||
|
if (GetSpotCountOfSize(Size.B) <= 2 && spot.Size == Size.B)
|
||||||
|
continue;
|
||||||
|
|
||||||
int size = (int) newSize;
|
int size = (int) newSize;
|
||||||
|
|
||||||
float diff = (_spotHeights[(int) spot.Size] - _spotHeights[size]) / 2.0f;
|
float diff = (_spotHeights[(int) spot.Size] - _spotHeights[size]) / 2.0f;
|
||||||
@ -366,6 +365,17 @@ namespace Parking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int GetSpotCountOfSize(Size size)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
foreach (var t in _spotMap)
|
||||||
|
foreach (Spot spot in t)
|
||||||
|
if (spot.Size == size)
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
private int[] GetFreeSpotCount()
|
private int[] GetFreeSpotCount()
|
||||||
{
|
{
|
||||||
int[] freeSpots = {0, 0, 0, 0};
|
int[] freeSpots = {0, 0, 0, 0};
|
||||||
|
Loading…
Reference in New Issue
Block a user