//Place the cooled containers
        private void PlaceCContainers()
        {
            //Get al list with containers sorted on weight (reverse because it will sort on the lowest container).
            List <CooledContainer> containerSortedWeight = cList.OrderBy(c => c.weight).Reverse().ToList();

            //Get the first row, cooled containers can only be placed on the first row. 0 will always be the first row.
            Row firstRow = ship.ReturnRow(0);

            //Sort the Row stacks on the LOWEST weight, i will place the heaviest container on the lowes weight to compensate.
            ContainerStack stack = SortStacksOnWeight(firstRow.Stacks).FirstOrDefault();

            foreach (var container in containerSortedWeight)
            {
                if (container != null)
                {
                    if (stack != null && stack.CanAddContainer(container))
                    {
                        if (container.placeLow)
                        {
                            stack.AddContainerToStackLow(container);
                        }
                        else
                        {
                            stack.AddContainerToStack(container);
                        }
                    }
                    else
                    {
                        AddContainerToFalseList(container);
                    }
                }
                stack = SortStacksOnWeight(firstRow.Stacks).FirstOrDefault();
            }
        }
Exemplo n.º 2
0
 public Row(int StacksAnmount, int _rownumber)
 {
     Stacks = new List <ContainerStack>();
     row    = _rownumber;
     size   = StacksAnmount;
     for (int i = 0; i < StacksAnmount; i++)
     {
         var stack = new ContainerStack(i);
         Stacks.Add(stack);
     }
 }
Exemplo n.º 3
0
 private void AddContainerStacks()
 {
     for (int i = 0; i < Columns; i++)
     {
         for (int ii = 0; ii < Convert.ToDecimal(Rows); ii++)
         {
             Side           side           = DecideSideOfStack(ii);
             ContainerStack containerStack = new ContainerStack(ii, i, side);
             ContainerStacks.Add(containerStack);
         }
     }
 }
Exemplo n.º 4
0
        private void PlaceValuableContainers(ContainerStack containerStack)
        {
            List <Container> valuedContainers = ContainersToBeAdded.FindAll(c => c.Valuable);

            foreach (var container in valuedContainers)
            {
                if (containerStack.IsContainerAble(container, Ship.Columns))
                {
                    containerStack.AddContainerToStack(container);
                    ContainersToBeAdded.Remove(container);
                }
            }
        }
Exemplo n.º 5
0
        private void PlaceRegularContainers(ContainerStack containerStack)
        {
            List <Container> regularContainers = ContainersToBeAdded.FindAll(c => !c.Cooled && !c.Valuable);

            foreach (var container in regularContainers)
            {
                if (containerStack.IsContainerAble(container, Ship.Columns))
                {
                    containerStack.AddContainerToStack(container);
                    ContainersToBeAdded.Remove(container);
                }
            }
        }
        //Place valuable containers.
        private void PlaceVContainers()
        {
            //Sort the valuable containers on weight. Reverse to get the heaviest.
            List <ValuableContainer> containerSorted = vList.OrderBy(c => c.weight).Reverse().ToList();

            //Get the last row
            Row lastRow = ship.rows.Last();

            //Get the stack with lowest weight
            List <ContainerStack> sortedStacks = SortStacksOnWeight(lastRow.Stacks);
            ContainerStack        stack        = sortedStacks.FirstOrDefault();

            foreach (var container in containerSorted.ToList())
            {
                if (container != null)
                {
                    if (stack != null && stack.CanAddContainer(container))
                    {
                        stack.AddContainerToStackHigh(container);
                    }
                    else
                    {
                        //Get first row and stacks
                        Row firstRow = ship.ReturnRow(0);
                        //Check if container can be placed on first row
                        foreach (var frstack in firstRow.Stacks)
                        {
                            if (frstack.CanAddContainer(container))
                            {
                                frstack.AddContainerToStackHigh(container);
                            }
                            else
                            {
                                continue;
                            }
                        }
                        AddContainerToFalseList(container);
                    }
                }
                stack = SortStacksOnWeight(lastRow.Stacks).First();
            }
        }