Example #1
0
        public List <Container> PlaceNormal(List <Container> normalContainers)
        {
            List <Container> unplaced = new List <Container>();

            foreach (var container in normalContainers)
            {
                ShipSide  side      = ShipSides[GetMostEmptySide()];
                ShipSlice shipslice = side.ShipSlices[side.GetMostEmptySlice()];
                ShipTower tower     = shipslice.Towers[shipslice.GetMostEmptyTower()];

                if (!tower.ContainerFits(container))
                {
                    unplaced.Add(container);
                }
                else
                {
                    ContainerSpot spot = tower.ContanerSpots[tower.GetFirstEmptySpot()];
                    if (!spot.AddContainer(container))
                    {
                        unplaced.Add(container);
                    }
                }
            }

            Console.WriteLine("Containers not placed " + unplaced.Count);
            return(unplaced);
        }
Example #2
0
        public List <Container> PlaceCooled(List <Container> cooledContainers)
        {
            List <Container> unplaced = new List <Container>();

            foreach (var container in cooledContainers)
            {
                ShipSide  side  = ShipSides[GetMostEmptySide()];
                ShipSlice slice = side.ShipSlices[side.GetMostEmptyCooledSlice()];
                ShipTower tower = slice.Towers[0];
                if (!tower.ContainerFits(container))
                {
                    unplaced.Add(container);
                }
                else
                {
                    ContainerSpot spot = tower.ContanerSpots[tower.GetFirstEmptySpot()];
                    if (!spot.AddContainer(container))
                    {
                        unplaced.Add(container);
                    }
                }
            }
            Console.WriteLine(unplaced.Count + " Containers not placed");
            return(unplaced);
        }
 private void GenerateShipSlices(int width, int length, int height)
 {
     for (int i = 0; i < width; i++)
     {
         ShipSlice slice = new ShipSlice(length, height);
         ShipSlices.Add(slice);
     }
 }