WIP Initial state generator - Ensured filling top row with 5s

This commit is contained in:
Dawid Pietrykowski 2022-08-29 23:15:18 +02:00
parent bdd2907107
commit 6fa142e817

View File

@ -43,7 +43,7 @@ public class ParkingManager : MonoBehaviour
int[,] spotsCreated = new int[4, 4];
int start = 20;
int start = 80;
int count = start;
int maxCount = 0;
@ -204,7 +204,7 @@ public class ParkingManager : MonoBehaviour
private bool TestCombination(int[] sizeIds, int[] spotCountsPerpendicularRef, int[,] spotCountsParallelRef, int[] requiredCountsRef, int[,] spotsCreated)
{
float[] sizes = sizeIds.Select(x => AvailableSizesCombinations[x]).ToArray();
Debug.Log($"Testing: {sizes[0]} {sizes[1]} {sizes[2]} sum: {sizes.Sum()}");
Debug.Log($"Testing: {sizes[0]} {sizes[1]} {sizes[2]} {sizes[3]} sum: {sizes.Sum()}");
for(int i = 0; i < spotsCreated.GetLength(0); i++)
for (int j = 0; j < spotsCreated.GetLength(1); j++)
@ -225,7 +225,7 @@ public class ParkingManager : MonoBehaviour
for (int spotSize = 2; spotSize >= 0; spotSize--)
{
for (int laneId = 0; laneId < 4; laneId++)
for (int laneId = 3; laneId >= 0; laneId--)
{
if (AvailableSizesCombinations[sizeIds[laneId]] <= spotSizes[spotSize] && spotCountsPerpendicular[laneId] != 0) { // parking perpendicular
int spotsTaken = Math.Min(requiredCounts[spotSize], spotCountsPerpendicular[laneId]);
@ -284,7 +284,10 @@ public class ParkingManager : MonoBehaviour
// combinations.Add(new[] {arr[chosen[0]]});
var tempArr = new List<int>(r);
for (var i = 0; i < r; i++) tempArr.Add(arr[chosen[i]]);
if (tempArr.Select(x => AvailableSizesCombinations[x]).Sum() < height - 11)
bool hasEnoughSpace = tempArr.Select(x => AvailableSizesCombinations[x]).Sum() < height - 11;
bool contains5 = tempArr.Contains(4);
tempArr.Sort();
if (hasEnoughSpace && contains5)
combinations.Add(tempArr.ToArray());
return;