public static List <Bloc> solution3dRandom() { const int BlocNb = 200, maxSize = 40, minSize = 1; List <Bloc> blocsToPlace = new List <Bloc>(); int width, height, depth; Debug.Log("start"); System.Random rand = new System.Random(); //Program.max_container = 50; for (int i = 1; i < BlocNb; i++) { width = rand.Next(minSize, maxSize); height = rand.Next(minSize, maxSize); //EN 3D : décommenter la ligne pour avoir le résultat en 2d ou en 3d depth = rand.Next(minSize, maxSize); //EN 2D :s //depth = 0; blocsToPlace.Add(new Bloc(width, height, depth)); } Container container = new Container(100, 100); blocsToPlace = PositionHelper.TriBloc(blocsToPlace); foreach (Bloc bl in blocsToPlace) { container.AddBloc(bl); Debug.Log(bl.X + " " + bl.Y + " " + bl.Z + " " + bl.Largeur + " " + bl.Hauteur + " " + bl.Profondeur); } return(blocsToPlace); }
public static List <Bloc> solution2d() { const int BlocNb = 100, maxSize = 40, minSize = 1; List <Bloc> blocsToPlace = new List <Bloc>(); int width, height, depth; Debug.Log("start"); System.Random rand = new System.Random(); //Program.max_container = 50; for (int i = 1; i <= BlocNb / 2; i++) { blocsToPlace.Add(new Bloc(10, 10, 0)); } for (int i = 1; i <= BlocNb / 2; i++) { blocsToPlace.Add(new Bloc(20, 20, 0)); } Container container = new Container(200, 200); blocsToPlace = PositionHelper.TriBloc(blocsToPlace); foreach (Bloc bl in blocsToPlace) { container.AddBloc(bl); } return(blocsToPlace); }
public static List <Bloc> solution3d() { const int BlocNb = 200; List <Bloc> blocsToPlace = new List <Bloc>(); int width, height, depth; Debug.Log("start"); System.Random rand = new System.Random(); for (int i = 1; i <= BlocNb / 2; i++) { blocsToPlace.Add(new Bloc(10, 10, 10)); } for (int i = 1; i <= BlocNb / 2; i++) { blocsToPlace.Add(new Bloc(15, 15, 15)); } Container container = new Container(100, 100); blocsToPlace = PositionHelper.TriBloc(blocsToPlace); foreach (Bloc bl in blocsToPlace) { container.AddBloc(bl); } return(blocsToPlace); }
public static List <Bloc> solution3dMultipleContainers() { int cpt = 0; int decalage = 0; int hoptn = -1; const int BlocNb = 400, maxSize = 50, minSize = 10; List <Bloc> blocsToPlace = new List <Bloc>(); List <Bloc> blocPlaced = new List <Bloc>(); int width, height, depth, cout; Debug.Log("start"); System.Random rand = new System.Random(); //Program.max_container = 50; for (int i = 0; i < BlocNb; i++) { width = rand.Next(minSize, maxSize); height = rand.Next(minSize, maxSize); //EN 3D : décommenter la ligne pour avoir le résultat en 2d ou en 3d depth = rand.Next(minSize, maxSize); cout = rand.Next(minSize, maxSize); //EN 2D :s //depth = 0; blocsToPlace.Add(new Bloc(width, height, depth, cout)); } while (cpt < BlocNb) { Container container = new Container(100, 100, 100, decalage); hoptn++; blocsToPlace = PositionHelper.TriBloc(blocsToPlace); blocsToPlace = PositionHelper.TriBlocCout(blocsToPlace); bool flag = true; while (flag == true) { flag = false; foreach (Bloc bl in blocsToPlace) { if (!bl.Placed && container.AddBloc(bl, true)) { Bloc tmp = new Bloc(bl); tmp.X += decalage; blocPlaced.Add(tmp); flag = true; bl.Placed = true; cpt++; Debug.Log(bl.X + " " + bl.Y + " " + bl.Z + " " + bl.Largeur + " " + bl.Hauteur + " " + bl.Profondeur); } } } decalage += container.Width + 100; Debug.Log("Decalage : " + decalage + " cpt : " + cpt + " cntner : " + container.Blocs.Count + " blocPlaced : " + blocPlaced.Count); container = null; } return(blocPlaced); }