Added 4 spots requirement
This commit is contained in:
parent
8a01e3f3bd
commit
0fab824709
@ -50,11 +50,19 @@ namespace Parking
|
||||
|
||||
int maxCount = 0;
|
||||
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...");
|
||||
foreach (int[] comb in Combinations) {
|
||||
int res = TryFillCombination(comb.ToArray(), spotCountsPerpendicular, spotCountsParallel, counts,
|
||||
spotsCreated);
|
||||
spotsCreated, drivers);
|
||||
if (res > maxCount) {
|
||||
maxCount = res;
|
||||
maxComb = comb;
|
||||
@ -62,13 +70,13 @@ namespace Parking
|
||||
}
|
||||
|
||||
TryFillCombination(maxComb, spotCountsPerpendicular, spotCountsParallel, counts,
|
||||
spotsCreated, true);
|
||||
spotsCreated, drivers, true);
|
||||
|
||||
return maxCount;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
@ -91,7 +99,8 @@ namespace Parking
|
||||
};
|
||||
|
||||
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};
|
||||
if (driver.Size == Size.C)
|
||||
laneIds.Reverse();
|
||||
|
@ -55,7 +55,7 @@ namespace Parking
|
||||
$"Duże: {_rejectedDrivers[2]}";
|
||||
GenerateEmergencyPlan();
|
||||
|
||||
DataImporter.ReadFile("Assets/Data/Tablica3.csv");
|
||||
DataImporter.ReadFile("Assets/Data/Tablica4.csv");
|
||||
InitialConfigurationGenerator generator = new();
|
||||
_initialSolution = generator.FindSolution();
|
||||
ArrangeSpots(_initialSolution);
|
||||
@ -88,12 +88,6 @@ namespace Parking
|
||||
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()
|
||||
@ -312,6 +306,11 @@ namespace Parking
|
||||
foreach (var currentLaneSpots in _spotMap)
|
||||
foreach (Spot spot in currentLaneSpots) {
|
||||
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;
|
||||
|
||||
float diff = (_spotHeights[(int) spot.Size] - _spotHeights[size]) / 2.0f;
|
||||
@ -365,6 +364,17 @@ namespace Parking
|
||||
|
||||
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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user