コード例 #1
0
        /// <summary>
        /// Returns the correct starting Y position for a valuable container based on the given mostOptimalWrapper parameter.
        /// </summary>
        /// <param name="mostOptimalWrapper"></param>
        /// <returns></returns>
        private int GetValuableContainerPlacementStartingPosY(WeightDirectionWrapper mostOptimalWrapper)
        {
            int startPosY = 0;

            if (mostOptimalWrapper.Y < 0)
            {
                startPosY = halfLength / 2;
            }
            else
            {
                startPosY = halfLength / 2 + 1;
            }

            return(startPosY);
        }
コード例 #2
0
        /// <summary>
        /// Returns the correct starting X position for a container based on the given mostOptimalWrapper parameter.
        /// </summary>
        /// <param name="mostOptimalWrapper">The most optimal wrapper.</param>
        /// <returns></returns>
        private int GetContainerPlacementStartingPosX(WeightDirectionWrapper mostOptimalWrapper)
        {
            int startPosX = 0;

            if (mostOptimalWrapper.X < 0)
            {
                startPosX = halfWidth;
            }
            else
            {
                startPosX = halfWidth + 1;
            }

            return(startPosX);
        }
コード例 #3
0
        /// <summary>
        /// Returns a list of WeightDirectionWrappers which are ordered in the most optimal order, starting with the most optimal.
        /// </summary>
        /// <returns></returns>
        private List <WeightDirectionWrapper> GetOptimalDirections()
        {
            int leftWeight   = GetLeftSideWeight();
            int rightWeight  = GetRightSideWeight();
            int topWeight    = GetTopSideWeight();
            int bottomWeight = GetBottomSideWeight();

            WeightDirectionWrapper topLeftContainer     = new WeightDirectionWrapper(leftWeight + topWeight, -1, 1);
            WeightDirectionWrapper topRightContainer    = new WeightDirectionWrapper(rightWeight + topWeight, 1, 1);
            WeightDirectionWrapper bottomLeftContainer  = new WeightDirectionWrapper(leftWeight + bottomWeight, -1, -1);
            WeightDirectionWrapper bottomRightContainer = new WeightDirectionWrapper(rightWeight + bottomWeight, 1, -1);

            List <WeightDirectionWrapper> weightDirectionContainers = new List <WeightDirectionWrapper>();

            weightDirectionContainers.Add(topLeftContainer);
            weightDirectionContainers.Add(topRightContainer);
            weightDirectionContainers.Add(bottomLeftContainer);
            weightDirectionContainers.Add(bottomRightContainer);

            return(weightDirectionContainers.OrderBy(x => x.Weight).ToList());
        }