WIP Initial state generator - Ensured filling top row with 5s
This commit is contained in:
parent
bdd2907107
commit
6fa142e817
@ -43,7 +43,7 @@ public class ParkingManager : MonoBehaviour
|
|||||||
|
|
||||||
int[,] spotsCreated = new int[4, 4];
|
int[,] spotsCreated = new int[4, 4];
|
||||||
|
|
||||||
int start = 20;
|
int start = 80;
|
||||||
int count = start;
|
int count = start;
|
||||||
|
|
||||||
int maxCount = 0;
|
int maxCount = 0;
|
||||||
@ -204,7 +204,7 @@ public class ParkingManager : MonoBehaviour
|
|||||||
private bool TestCombination(int[] sizeIds, int[] spotCountsPerpendicularRef, int[,] spotCountsParallelRef, int[] requiredCountsRef, int[,] spotsCreated)
|
private bool TestCombination(int[] sizeIds, int[] spotCountsPerpendicularRef, int[,] spotCountsParallelRef, int[] requiredCountsRef, int[,] spotsCreated)
|
||||||
{
|
{
|
||||||
float[] sizes = sizeIds.Select(x => AvailableSizesCombinations[x]).ToArray();
|
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 i = 0; i < spotsCreated.GetLength(0); i++)
|
||||||
for (int j = 0; j < spotsCreated.GetLength(1); j++)
|
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 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
|
if (AvailableSizesCombinations[sizeIds[laneId]] <= spotSizes[spotSize] && spotCountsPerpendicular[laneId] != 0) { // parking perpendicular
|
||||||
int spotsTaken = Math.Min(requiredCounts[spotSize], spotCountsPerpendicular[laneId]);
|
int spotsTaken = Math.Min(requiredCounts[spotSize], spotCountsPerpendicular[laneId]);
|
||||||
@ -284,7 +284,10 @@ public class ParkingManager : MonoBehaviour
|
|||||||
// combinations.Add(new[] {arr[chosen[0]]});
|
// combinations.Add(new[] {arr[chosen[0]]});
|
||||||
var tempArr = new List<int>(r);
|
var tempArr = new List<int>(r);
|
||||||
for (var i = 0; i < r; i++) tempArr.Add(arr[chosen[i]]);
|
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());
|
combinations.Add(tempArr.ToArray());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user